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