bsd.own.mk revision 241629
1# $FreeBSD: head/share/mk/bsd.own.mk 241629 2012-10-17 11:16:17Z attilio $
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# Compat NO_* options (same as above, except their use is deprecated).
220#
221.if !defined(BURN_BRIDGES)
222.for var in \
223    ACPI \
224    ATM \
225    AUDIT \
226    AUTHPF \
227    BIND \
228    BIND_DNSSEC \
229    BIND_ETC \
230    BIND_LIBS_LWRES \
231    BIND_MTREE \
232    BIND_NAMED \
233    BIND_UTILS \
234    BLUETOOTH \
235    BOOT \
236    CALENDAR \
237    CPP \
238    CRYPT \
239    CVS \
240    CXX \
241    DICT \
242    DYNAMICROOT \
243    EXAMPLES \
244    FORTH \
245    FP_LIBC \
246    GAMES \
247    GCOV \
248    GDB \
249    GNU \
250    GPIB \
251    GROFF \
252    HTML \
253    INET6 \
254    INFO \
255    IPFILTER \
256    IPX \
257    KDUMP \
258    KERBEROS \
259    LIB32 \
260    LIBPTHREAD \
261    LIBTHR \
262    LOCALES \
263    LPR \
264    MAILWRAPPER \
265    NETCAT \
266    NIS \
267    NLS \
268    NLS_CATALOGS \
269    NS_CACHING \
270    OPENSSH \
271    OPENSSL \
272    PAM \
273    PF \
274    RCMDS \
275    RCS \
276    RESCUE \
277    SENDMAIL \
278    SETUID_LOGIN \
279    SHAREDOCS \
280    SYSCONS \
281    TCSH \
282    TOOLCHAIN \
283    USB \
284    WPA_SUPPLICANT_EAPOL
285.if defined(NO_${var})
286#.warning NO_${var} is deprecated in favour of WITHOUT_${var}=
287WITHOUT_${var}=
288.endif
289.endfor
290.endif # !defined(BURN_BRIDGES)
291
292#
293# Older-style variables that enabled behaviour when set.
294#
295.if defined(YES_HESIOD)
296WITH_HESIOD=
297.endif
298.if defined(MAKE_IDEA)
299WITH_IDEA=
300.endif
301
302__DEFAULT_YES_OPTIONS = \
303    ACCT \
304    ACPI \
305    AMD \
306    APM \
307    ASSERT_DEBUG \
308    AT \
309    ATM \
310    AUDIT \
311    AUTHPF \
312    BIND \
313    BIND_DNSSEC \
314    BIND_ETC \
315    BIND_LIBS_LWRES \
316    BIND_MTREE \
317    BIND_NAMED \
318    BIND_UTILS \
319    BINUTILS \
320    BLUETOOTH \
321    BOOT \
322    BSD_CPIO \
323    BSNMP \
324    SOURCELESS \
325    SOURCELESS_HOST \
326    SOURCELESS_UCODE \
327    BZIP2 \
328    CALENDAR \
329    CAPSICUM \
330    CDDL \
331    CPP \
332    CRYPT \
333    CTM \
334    CVS \
335    CXX \
336    DICT \
337    DYNAMICROOT \
338    ED_CRYPTO \
339    EXAMPLES \
340    FLOPPY \
341    FORTH \
342    FP_LIBC \
343    FREEBSD_UPDATE \
344    GAMES \
345    GCC \
346    GCOV \
347    GDB \
348    GNU \
349    GPIB \
350    GPIO \
351    GROFF \
352    HTML \
353    INET \
354    INET6 \
355    INFO \
356    INSTALLLIB \
357    IPFILTER \
358    IPFW \
359    IPX \
360    JAIL \
361    KDUMP \
362    KERBEROS \
363    KERNEL_SYMBOLS \
364    KVM \
365    LEGACY_CONSOLE \
366    LIB32 \
367    LIBPTHREAD \
368    LIBTHR \
369    LOCALES \
370    LOCATE \
371    LPR \
372    LS_COLORS \
373    MAIL \
374    MAILWRAPPER \
375    MAKE \
376    MAN \
377    NDIS \
378    NETCAT \
379    NETGRAPH \
380    NIS \
381    NLS \
382    NLS_CATALOGS \
383    NS_CACHING \
384    NTP \
385    OPENSSH \
386    OPENSSL \
387    PAM \
388    PF \
389    PKGBOOTSTRAP \
390    PKGTOOLS \
391    PMC \
392    PORTSNAP \
393    PPP \
394    PROFILE \
395    QUOTAS \
396    RCMDS \
397    RCS \
398    RESCUE \
399    ROUTED \
400    SENDMAIL \
401    SETUID_LOGIN \
402    SHAREDOCS \
403    SSP \
404    SYSINSTALL \
405    SYMVER \
406    SYSCONS \
407    TCSH \
408    TELNET \
409    TEXTPROC \
410    TOOLCHAIN \
411    USB \
412    UTMPX \
413    WIRELESS \
414    WPA_SUPPLICANT_EAPOL \
415    ZFS \
416    ZONEINFO
417
418__DEFAULT_NO_OPTIONS = \
419    BMAKE \
420    BSD_GREP \
421    BIND_IDN \
422    BIND_LARGE_FILE \
423    BIND_LIBS \
424    BIND_SIGCHASE \
425    BIND_XML \
426    BSDCONFIG \
427    CLANG_EXTRAS \
428    CLANG_IS_CC \
429    CTF \
430    HESIOD \
431    ICONV \
432    IDEA \
433    INSTALL_AS_USER \
434    NAND \
435    OFED \
436    SHARED_TOOLCHAIN
437
438#
439# Default behaviour of some options depends on the architecture.  Unfortunately
440# this means that we have to test TARGET_ARCH (the buildworld case) as well
441# as MACHINE_ARCH (the non-buildworld case).  Normally TARGET_ARCH is not
442# used at all in bsd.*.mk, but we have to make an exception here if we want
443# to allow defaults for some things like clang and fdt to vary by target
444# architecture.
445#
446.if defined(TARGET_ARCH)
447__T=${TARGET_ARCH}
448.else
449__T=${MACHINE_ARCH}
450.endif
451# Clang is only for x86 and powerpc right now, by default.
452.if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*}
453__DEFAULT_YES_OPTIONS+=CLANG
454.else
455__DEFAULT_NO_OPTIONS+=CLANG
456.endif
457# FDT is needed only for arm, mips and powerpc
458.if ${__T:Marm*} || ${__T:Mpowerpc*} || ${__T:Mmips*}
459__DEFAULT_YES_OPTIONS+=FDT
460.else
461__DEFAULT_NO_OPTIONS+=FDT
462.endif
463.undef __T
464
465#
466# MK_* options which default to "yes".
467#
468.for var in ${__DEFAULT_YES_OPTIONS}
469.if defined(WITH_${var}) && defined(WITHOUT_${var})
470.error WITH_${var} and WITHOUT_${var} can't both be set.
471.endif
472.if defined(MK_${var})
473.error MK_${var} can't be set by a user.
474.endif
475.if defined(WITHOUT_${var})
476MK_${var}:=	no
477.else
478MK_${var}:=	yes
479.endif
480.endfor
481.undef __DEFAULT_YES_OPTIONS
482
483#
484# MK_* options which default to "no".
485#
486.for var in ${__DEFAULT_NO_OPTIONS}
487.if defined(WITH_${var}) && defined(WITHOUT_${var})
488.error WITH_${var} and WITHOUT_${var} can't both be set.
489.endif
490.if defined(MK_${var})
491.error MK_${var} can't be set by a user.
492.endif
493.if defined(WITH_${var})
494MK_${var}:=	yes
495.else
496MK_${var}:=	no
497.endif
498.endfor
499.undef __DEFAULT_NO_OPTIONS
500
501#
502# Force some options off if their dependencies are off.
503# Order is somewhat important.
504#
505.if ${MK_LIBPTHREAD} == "no"
506MK_LIBTHR:=	no
507.endif
508
509.if ${MK_LIBTHR} == "no"
510MK_BIND:=	no
511.endif
512
513.if ${MK_BIND} == "no"
514MK_BIND_DNSSEC:= no
515MK_BIND_ETC:=	no
516MK_BIND_LIBS:=	no
517MK_BIND_LIBS_LWRES:= no
518MK_BIND_MTREE:=	no
519MK_BIND_NAMED:=	no
520MK_BIND_UTILS:=	no
521.endif
522
523.if ${MK_BIND_MTREE} == "no"
524MK_BIND_ETC:=	no
525.endif
526
527.if ${MK_SOURCELESS} == "no"
528MK_SOURCELESS_HOST:=	no
529MK_SOURCELESS_UCODE:= no
530.endif
531
532.if ${MK_CDDL} == "no"
533MK_ZFS:=	no
534MK_CTF:=	no
535.endif
536
537.if ${MK_CLANG} == "no"
538MK_CLANG_EXTRAS:= no
539.endif
540
541.if ${MK_CRYPT} == "no"
542MK_OPENSSL:=	no
543MK_OPENSSH:=	no
544MK_KERBEROS:=	no
545.endif
546
547.if ${MK_CXX} == "no"
548MK_CLANG:=	no
549MK_GROFF:=	no
550.endif
551
552.if ${MK_MAIL} == "no"
553MK_MAILWRAPPER:= no
554MK_SENDMAIL:=	no
555.endif
556
557.if ${MK_NETGRAPH} == "no"
558MK_ATM:=	no
559MK_BLUETOOTH:=	no
560.endif
561
562.if ${MK_OPENSSL} == "no"
563MK_OPENSSH:=	no
564MK_KERBEROS:=	no
565.endif
566
567.if ${MK_PF} == "no"
568MK_AUTHPF:=	no
569.endif
570
571.if ${MK_TEXTPROC} == "no"
572MK_GROFF:=	no
573.endif
574
575.if ${MK_TOOLCHAIN} == "no"
576MK_BINUTILS:=	no
577MK_CLANG:=	no
578MK_GCC:=	no
579MK_GDB:=	no
580.endif
581
582.if ${MK_CLANG} == "no"
583MK_CLANG_IS_CC:= no
584.endif
585
586#
587# Set defaults for the MK_*_SUPPORT variables.
588#
589
590#
591# MK_*_SUPPORT options which default to "yes" unless their corresponding
592# MK_* variable is set to "no".
593#
594.for var in \
595    BZIP2 \
596    GNU \
597    INET \
598    INET6 \
599    IPX \
600    KERBEROS \
601    KVM \
602    NETGRAPH \
603    PAM \
604    WIRELESS
605.if defined(WITH_${var}_SUPPORT) && defined(WITHOUT_${var}_SUPPORT)
606.error WITH_${var}_SUPPORT and WITHOUT_${var}_SUPPORT can't both be set.
607.endif
608.if defined(MK_${var}_SUPPORT)
609.error MK_${var}_SUPPORT can't be set by a user.
610.endif
611.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
612MK_${var}_SUPPORT:= no
613.else
614MK_${var}_SUPPORT:= yes
615.endif
616.endfor
617
618#
619# MK_* options whose default value depends on another option.
620#
621.for vv in \
622    GSSAPI/KERBEROS \
623    MAN_UTILS/MAN
624.if defined(WITH_${vv:H}) && defined(WITHOUT_${vv:H})
625.error WITH_${vv:H} and WITHOUT_${vv:H} can't both be set.
626.endif
627.if defined(MK_${vv:H})
628.error MK_${vv:H} can't be set by a user.
629.endif
630.if defined(WITH_${vv:H})
631MK_${vv:H}:=	yes
632.elif defined(WITHOUT_${vv:H})
633MK_${vv:H}:=	no
634.else
635MK_${vv:H}:=	${MK_${vv:T}}
636.endif
637.endfor
638
639#
640# MK_* options that default to "yes" if the compiler is a C++11 compiler.
641#
642.include <bsd.compiler.mk>
643.for var in \
644    LIBCPLUSPLUS
645.if defined(WITH_${var}) && defined(WITHOUT_${var})
646.error WITH_${var} and WITHOUT_${var} can't both be set.
647.endif
648.if defined(MK_${var})
649.error MK_${var} can't be set by a user.
650.endif
651.if ${COMPILER_FEATURES:Mc++11}
652.if defined(WITHOUT_${var})
653MK_${var}:=	no
654.else
655MK_${var}:=	yes
656.endif
657.else
658.if defined(WITH_${var})
659MK_${var}:=	yes
660.else
661MK_${var}:=	no
662.endif
663.endif
664.endfor
665
666.if ${MK_CTF} != "no"
667CTFCONVERT_CMD=	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
668.elif defined(MAKE_VERSION) && ${MAKE_VERSION} >= 5201111300
669CTFCONVERT_CMD=
670.else
671CTFCONVERT_CMD=	@:
672.endif 
673
674.if ${MK_INSTALL_AS_USER} != "no"
675_uid!=	id -un
676.if ${_uid} != 0
677_gid!=	id -gn
678.for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE
679$xOWN=	${_uid}
680$xGRP=	${_gid}
681.endfor
682.endif
683.endif
684
685.endif # !_WITHOUT_SRCCONF
686
687.endif	# !target(__<bsd.own.mk>__)
688