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