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