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