bsd.own.mk revision 245606
1# $FreeBSD: head/share/mk/bsd.own.mk 245606 2013-01-18 15:57:09Z eadler $
2#
3# The include file <bsd.own.mk> set common variables for owner,
4# group, mode, and directories. Defaults are in brackets.
5#
6#
7# +++ variables +++
8#
9# DESTDIR	Change the tree where the file gets installed. [not set]
10#
11# DISTDIR	Change the tree where the file for a distribution
12# 		gets installed (see /usr/src/release/Makefile). [not set]
13#
14# COMPRESS_CMD	Program to compress documents.
15#		Output is to stdout. [gzip -cn]
16#
17# COMPRESS_EXT	File name extension of ${COMPRESS_CMD} command. [.gz]
18#
19# BINOWN	Binary owner. [root]
20#
21# BINGRP	Binary group. [wheel]
22#
23# BINMODE	Binary mode. [555]
24#
25# NOBINMODE	Mode for non-executable files. [444]
26#
27# LIBDIR	Base path for libraries. [/usr/lib]
28#
29# LIBCOMPATDIR	Base path for compat libraries. [/usr/lib/compat]
30#
31# LIBDATADIR	Base path for misc. utility data files. [/usr/libdata]
32#
33# LIBEXECDIR	Base path for system daemons and utilities. [/usr/libexec]
34#
35# LINTLIBDIR	Base path for lint libraries. [/usr/libdata/lint]
36#
37# SHLIBDIR	Base path for shared libraries. [${LIBDIR}]
38#
39# LIBOWN	Library owner. [${BINOWN}]
40#
41# LIBGRP	Library group. [${BINGRP}]
42#
43# LIBMODE	Library mode. [${NOBINMODE}]
44#
45#
46# KMODDIR	Base path for loadable kernel modules
47#		(see kld(4)). [/boot/kernel]
48#
49# KMODOWN	Kernel and KLD owner. [${BINOWN}]
50#
51# KMODGRP	Kernel and KLD group. [${BINGRP}]
52#
53# KMODMODE	KLD mode. [${BINMODE}]
54#
55#
56# SHAREDIR	Base path for architecture-independent ascii
57#		text files. [/usr/share]
58#
59# SHAREOWN	ASCII text file owner. [root]
60#
61# SHAREGRP	ASCII text file group. [wheel]
62#
63# SHAREMODE	ASCII text file mode. [${NOBINMODE}]
64#
65#
66# CONFDIR	Base path for configuration files. [/etc]
67#
68# CONFOWN	Configuration file owner. [root]
69#
70# CONFGRP	Configuration file group. [wheel]
71#
72# CONFMODE	Configuration file mode. [644]
73#
74#
75# DOCDIR	Base path for system documentation (e.g. PSD, USD,
76#		handbook, FAQ etc.). [${SHAREDIR}/doc]
77#
78# DOCOWN	Documentation owner. [${SHAREOWN}]
79#
80# DOCGRP	Documentation group. [${SHAREGRP}]
81#
82# DOCMODE	Documentation mode. [${NOBINMODE}]
83#
84#
85# INFODIR	Base path for GNU's hypertext system
86#		called Info (see info(1)). [${SHAREDIR}/info]
87#
88# INFOOWN	Info owner. [${SHAREOWN}]
89#
90# INFOGRP	Info group. [${SHAREGRP}]
91#
92# INFOMODE	Info mode. [${NOBINMODE}]
93#
94#
95# MANDIR	Base path for manual installation. [${SHAREDIR}/man/man]
96#
97# MANOWN	Manual owner. [${SHAREOWN}]
98#
99# MANGRP	Manual group. [${SHAREGRP}]
100#
101# MANMODE	Manual mode. [${NOBINMODE}]
102#
103#
104# NLSDIR	Base path for National Language Support files
105#		installation. [${SHAREDIR}/nls]
106#
107# NLSOWN	National Language Support files owner. [${SHAREOWN}]
108#
109# NLSGRP	National Language Support files group. [${SHAREGRP}]
110#
111# NLSMODE	National Language Support files mode. [${NOBINMODE}]
112#
113# INCLUDEDIR	Base path for standard C include files [/usr/include]
114
115.if !target(__<bsd.own.mk>__)
116__<bsd.own.mk>__:
117
118.if !defined(_WITHOUT_SRCCONF)
119SRCCONF?=	/etc/src.conf
120.if exists(${SRCCONF})
121.include "${SRCCONF}"
122.endif
123.endif
124
125# Binaries
126BINOWN?=	root
127BINGRP?=	wheel
128BINMODE?=	555
129NOBINMODE?=	444
130
131.if defined(MODULES_WITH_WORLD)
132KMODDIR?=	/boot/modules
133.else
134KMODDIR?=	/boot/kernel
135.endif
136KMODOWN?=	${BINOWN}
137KMODGRP?=	${BINGRP}
138KMODMODE?=	${BINMODE}
139
140LIBDIR?=	/usr/lib
141LIBCOMPATDIR?=	/usr/lib/compat
142LIBDATADIR?=	/usr/libdata
143LIBEXECDIR?=	/usr/libexec
144LINTLIBDIR?=	/usr/libdata/lint
145SHLIBDIR?=	${LIBDIR}
146LIBOWN?=	${BINOWN}
147LIBGRP?=	${BINGRP}
148LIBMODE?=	${NOBINMODE}
149
150
151# Share files
152SHAREDIR?=	/usr/share
153SHAREOWN?=	root
154SHAREGRP?=	wheel
155SHAREMODE?=	${NOBINMODE}
156
157CONFDIR?=	/etc
158CONFOWN?=	root
159CONFGRP?=	wheel
160CONFMODE?=	644
161
162MANDIR?=	${SHAREDIR}/man/man
163MANOWN?=	${SHAREOWN}
164MANGRP?=	${SHAREGRP}
165MANMODE?=	${NOBINMODE}
166
167DOCDIR?=	${SHAREDIR}/doc
168DOCOWN?=	${SHAREOWN}
169DOCGRP?=	${SHAREGRP}
170DOCMODE?=	${NOBINMODE}
171
172INFODIR?=	${SHAREDIR}/info
173INFOOWN?=	${SHAREOWN}
174INFOGRP?=	${SHAREGRP}
175INFOMODE?=	${NOBINMODE}
176
177NLSDIR?=	${SHAREDIR}/nls
178NLSOWN?=	${SHAREOWN}
179NLSGRP?=	${SHAREGRP}
180NLSMODE?=	${NOBINMODE}
181
182INCLUDEDIR?=	/usr/include
183
184# Common variables
185.if !defined(DEBUG_FLAGS)
186STRIP?=		-s
187.endif
188
189COMPRESS_CMD?=	gzip -cn
190COMPRESS_EXT?=	.gz
191
192.if !defined(_WITHOUT_SRCCONF)
193#
194# Define MK_* variables (which are either "yes" or "no") for users
195# to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the
196# make(1) environment.
197# These should be tested with `== "no"' or `!= "no"' in makefiles.
198# The NO_* variables should only be set by makefiles.
199#
200
201#
202# Supported NO_* options (if defined, MK_* will be forced to "no",
203# regardless of user's setting).
204#
205.for var in \
206    CTF \
207    INSTALLLIB \
208    MAN \
209    PROFILE
210.if defined(NO_${var})
211.if defined(WITH_${var})
212.undef WITH_${var}
213.endif
214WITHOUT_${var}=
215.endif
216.endfor
217
218#
219# Older-style variables that enabled behaviour when set.
220#
221.if defined(YES_HESIOD)
222WITH_HESIOD=
223.endif
224.if defined(MAKE_IDEA)
225WITH_IDEA=
226.endif
227
228__DEFAULT_YES_OPTIONS = \
229    ACCT \
230    ACPI \
231    AMD \
232    APM \
233    ASSERT_DEBUG \
234    AT \
235    ATF \
236    ATM \
237    AUDIT \
238    AUTHPF \
239    BIND \
240    BIND_DNSSEC \
241    BIND_ETC \
242    BIND_LIBS_LWRES \
243    BIND_MTREE \
244    BIND_NAMED \
245    BIND_UTILS \
246    BINUTILS \
247    BLUETOOTH \
248    BOOT \
249    BSD_CPIO \
250    BSNMP \
251    BZIP2 \
252    CALENDAR \
253    CAPSICUM \
254    CDDL \
255    CPP \
256    CRYPT \
257    CTM \
258    CVS \
259    CXX \
260    DICT \
261    DYNAMICROOT \
262    ED_CRYPTO \
263    EXAMPLES \
264    FLOPPY \
265    FORTH \
266    FP_LIBC \
267    FREEBSD_UPDATE \
268    GAMES \
269    GCC \
270    GCOV \
271    GDB \
272    GNU \
273    GPIB \
274    GPIO \
275    GROFF \
276    HTML \
277    INET \
278    INET6 \
279    INFO \
280    INSTALLLIB \
281    IPFILTER \
282    IPFW \
283    IPX \
284    JAIL \
285    KDUMP \
286    KERBEROS \
287    KERNEL_SYMBOLS \
288    KVM \
289    LEGACY_CONSOLE \
290    LIB32 \
291    LIBPTHREAD \
292    LIBTHR \
293    LOCALES \
294    LOCATE \
295    LPR \
296    LS_COLORS \
297    MAIL \
298    MAILWRAPPER \
299    MAKE \
300    MAN \
301    NDIS \
302    NETCAT \
303    NETGRAPH \
304    NIS \
305    NLS \
306    NLS_CATALOGS \
307    NS_CACHING \
308    NTP \
309    OPENSSH \
310    OPENSSL \
311    PAM \
312    PC_SYSINSTALL \
313    PF \
314    PKGBOOTSTRAP \
315    PKGTOOLS \
316    PMC \
317    PORTSNAP \
318    PPP \
319    PROFILE \
320    QUOTAS \
321    RCMDS \
322    RCS \
323    RESCUE \
324    ROUTED \
325    SENDMAIL \
326    SETUID_LOGIN \
327    SHAREDOCS \
328    SOURCELESS \
329    SOURCELESS_HOST \
330    SOURCELESS_UCODE \
331    SSP \
332    SYMVER \
333    SYSCONS \
334    SYSINSTALL \
335    TCSH \
336    TELNET \
337    TEXTPROC \
338    TOOLCHAIN \
339    USB \
340    UTMPX \
341    WIRELESS \
342    WPA_SUPPLICANT_EAPOL \
343    ZFS \
344    ZONEINFO
345
346__DEFAULT_NO_OPTIONS = \
347    ARM_EABI \
348    BIND_IDN \
349    BIND_LARGE_FILE \
350    BIND_LIBS \
351    BIND_SIGCHASE \
352    BIND_XML \
353    BMAKE \
354    BSDCONFIG \
355    BSD_GREP \
356    CLANG_EXTRAS \
357    CTF \
358    HESIOD \
359    ICONV \
360    IDEA \
361    INSTALL_AS_USER \
362    NMTREE \
363    NAND \
364    OFED \
365    OPENSSH_NONE_CIPHER \
366    SHARED_TOOLCHAIN
367
368#
369# Default behaviour of some options depends on the architecture.  Unfortunately
370# this means that we have to test TARGET_ARCH (the buildworld case) as well
371# as MACHINE_ARCH (the non-buildworld case).  Normally TARGET_ARCH is not
372# used at all in bsd.*.mk, but we have to make an exception here if we want
373# to allow defaults for some things like clang and fdt to vary by target
374# architecture.
375#
376.if defined(TARGET_ARCH)
377__T=${TARGET_ARCH}
378.else
379__T=${MACHINE_ARCH}
380.endif
381# Clang is only for x86 and powerpc right now, by default.
382.if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*}
383__DEFAULT_YES_OPTIONS+=CLANG
384.else
385__DEFAULT_NO_OPTIONS+=CLANG
386.endif
387# Clang the default system compiler only on x86.
388.if ${__T} == "amd64" || ${__T} == "i386"
389__DEFAULT_YES_OPTIONS+=CLANG_IS_CC
390.else
391__DEFAULT_NO_OPTIONS+=CLANG_IS_CC
392.endif
393# FDT is needed only for arm, mips and powerpc
394.if ${__T:Marm*} || ${__T:Mpowerpc*} || ${__T:Mmips*}
395__DEFAULT_YES_OPTIONS+=FDT
396.else
397__DEFAULT_NO_OPTIONS+=FDT
398.endif
399.undef __T
400
401#
402# MK_* options which default to "yes".
403#
404.for var in ${__DEFAULT_YES_OPTIONS}
405.if defined(WITH_${var}) && defined(WITHOUT_${var})
406.error WITH_${var} and WITHOUT_${var} can't both be set.
407.endif
408.if defined(MK_${var})
409.error MK_${var} can't be set by a user.
410.endif
411.if defined(WITHOUT_${var})
412MK_${var}:=	no
413.else
414MK_${var}:=	yes
415.endif
416.endfor
417.undef __DEFAULT_YES_OPTIONS
418
419#
420# MK_* options which default to "no".
421#
422.for var in ${__DEFAULT_NO_OPTIONS}
423.if defined(WITH_${var}) && defined(WITHOUT_${var})
424.error WITH_${var} and WITHOUT_${var} can't both be set.
425.endif
426.if defined(MK_${var})
427.error MK_${var} can't be set by a user.
428.endif
429.if defined(WITH_${var})
430MK_${var}:=	yes
431.else
432MK_${var}:=	no
433.endif
434.endfor
435.undef __DEFAULT_NO_OPTIONS
436
437#
438# Force some options off if their dependencies are off.
439# Order is somewhat important.
440#
441.if ${MK_LIBPTHREAD} == "no"
442MK_LIBTHR:=	no
443.endif
444
445.if ${MK_LIBTHR} == "no"
446MK_BIND:=	no
447.endif
448
449.if ${MK_BIND} == "no"
450MK_BIND_DNSSEC:= no
451MK_BIND_ETC:=	no
452MK_BIND_LIBS:=	no
453MK_BIND_LIBS_LWRES:= no
454MK_BIND_MTREE:=	no
455MK_BIND_NAMED:=	no
456MK_BIND_UTILS:=	no
457.endif
458
459.if ${MK_BIND_MTREE} == "no"
460MK_BIND_ETC:=	no
461.endif
462
463.if ${MK_SOURCELESS} == "no"
464MK_SOURCELESS_HOST:=	no
465MK_SOURCELESS_UCODE:= no
466.endif
467
468.if ${MK_CDDL} == "no"
469MK_ZFS:=	no
470MK_CTF:=	no
471.endif
472
473.if ${MK_CLANG} == "no"
474MK_CLANG_EXTRAS:= no
475.endif
476
477.if ${MK_CRYPT} == "no"
478MK_OPENSSL:=	no
479MK_OPENSSH:=	no
480MK_KERBEROS:=	no
481.endif
482
483.if ${MK_CXX} == "no"
484MK_CLANG:=	no
485MK_GROFF:=	no
486.endif
487
488.if ${MK_MAIL} == "no"
489MK_MAILWRAPPER:= no
490MK_SENDMAIL:=	no
491.endif
492
493.if ${MK_NETGRAPH} == "no"
494MK_ATM:=	no
495MK_BLUETOOTH:=	no
496.endif
497
498.if ${MK_OPENSSL} == "no"
499MK_OPENSSH:=	no
500MK_KERBEROS:=	no
501.endif
502
503.if ${MK_PF} == "no"
504MK_AUTHPF:=	no
505.endif
506
507.if ${MK_TEXTPROC} == "no"
508MK_GROFF:=	no
509.endif
510
511.if ${MK_TOOLCHAIN} == "no"
512MK_BINUTILS:=	no
513MK_CLANG:=	no
514MK_GCC:=	no
515MK_GDB:=	no
516.endif
517
518.if ${MK_CLANG} == "no"
519MK_CLANG_IS_CC:= no
520.endif
521
522#
523# Set defaults for the MK_*_SUPPORT variables.
524#
525
526#
527# MK_*_SUPPORT options which default to "yes" unless their corresponding
528# MK_* variable is set to "no".
529#
530.for var in \
531    BZIP2 \
532    GNU \
533    INET \
534    INET6 \
535    IPX \
536    KERBEROS \
537    KVM \
538    NETGRAPH \
539    PAM \
540    WIRELESS
541.if defined(WITH_${var}_SUPPORT) && defined(WITHOUT_${var}_SUPPORT)
542.error WITH_${var}_SUPPORT and WITHOUT_${var}_SUPPORT can't both be set.
543.endif
544.if defined(MK_${var}_SUPPORT)
545.error MK_${var}_SUPPORT can't be set by a user.
546.endif
547.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
548MK_${var}_SUPPORT:= no
549.else
550MK_${var}_SUPPORT:= yes
551.endif
552.endfor
553
554#
555# MK_* options whose default value depends on another option.
556#
557.for vv in \
558    GSSAPI/KERBEROS \
559    MAN_UTILS/MAN
560.if defined(WITH_${vv:H}) && defined(WITHOUT_${vv:H})
561.error WITH_${vv:H} and WITHOUT_${vv:H} can't both be set.
562.endif
563.if defined(MK_${vv:H})
564.error MK_${vv:H} can't be set by a user.
565.endif
566.if defined(WITH_${vv:H})
567MK_${vv:H}:=	yes
568.elif defined(WITHOUT_${vv:H})
569MK_${vv:H}:=	no
570.else
571MK_${vv:H}:=	${MK_${vv:T}}
572.endif
573.endfor
574
575#
576# MK_* options that default to "yes" if the compiler is a C++11 compiler.
577#
578.include <bsd.compiler.mk>
579.for var in \
580    LIBCPLUSPLUS
581.if defined(WITH_${var}) && defined(WITHOUT_${var})
582.error WITH_${var} and WITHOUT_${var} can't both be set.
583.endif
584.if defined(MK_${var})
585.error MK_${var} can't be set by a user.
586.endif
587.if ${COMPILER_FEATURES:Mc++11}
588.if defined(WITHOUT_${var})
589MK_${var}:=	no
590.else
591MK_${var}:=	yes
592.endif
593.else
594.if defined(WITH_${var})
595MK_${var}:=	yes
596.else
597MK_${var}:=	no
598.endif
599.endif
600.endfor
601
602.if ${MK_CTF} != "no"
603CTFCONVERT_CMD=	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
604.elif defined(.PARSEDIR) || (defined(MAKE_VERSION) && ${MAKE_VERSION} >= 5201111300)
605CTFCONVERT_CMD=
606.else
607CTFCONVERT_CMD=	@:
608.endif 
609
610.if ${MK_INSTALL_AS_USER} != "no"
611_uid!=	id -u
612.if ${_uid} != 0
613.if !defined(USER)
614USER!=	id -un
615.endif
616_gid!=	id -gn
617.for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE
618$xOWN=	${USER}
619$xGRP=	${_gid}
620.endfor
621.endif
622.endif
623
624.endif # !_WITHOUT_SRCCONF
625
626.endif	# !target(__<bsd.own.mk>__)
627