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