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})
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.warning unsetting WITH_${var}
234.undef WITH_${var}
235.if defined(WITH_${var})
236.error wtf
237.endif
238.endif
239WITHOUT_${var}=
240.endif
241.endfor
242
243#
244# Compat NO_* options (same as above, except their use is deprecated).
245#
246.if !defined(BURN_BRIDGES)
247.for var in \
248    ACPI \
249    ATM \
250    AUDIT \
251    AUTHPF \
252    BIND \
253    BIND_DNSSEC \
254    BIND_ETC \
255    BIND_LIBS_LWRES \
256    BIND_MTREE \
257    BIND_NAMED \
258    BIND_UTILS \
259    BLUETOOTH \
260    BOOT \
261    CALENDAR \
262    CPP \
263    CRYPT \
264    CVS \
265    CXX \
266    DICT \
267    DYNAMICROOT \
268    EXAMPLES \
269    FORTH \
270    FP_LIBC \
271    GAMES \
272    GCOV \
273    GDB \
274    GNU \
275    GPIB \
276    GROFF \
277    HTML \
278    INET6 \
279    INFO \
280    IPFILTER \
281    IPX \
282    KERBEROS \
283    LIB32 \
284    LIBPTHREAD \
285    LIBTHR \
286    LOCALES \
287    LPR \
288    MAILWRAPPER \
289    NETCAT \
290    NIS \
291    NLS \
292    NLS_CATALOGS \
293    NS_CACHING \
294    OPENSSH \
295    OPENSSL \
296    PAM \
297    PF \
298    RCMDS \
299    RCS \
300    RESCUE \
301    SENDMAIL \
302    SETUID_LOGIN \
303    SHAREDOCS \
304    SYSCONS \
305    TCSH \
306    TOOLCHAIN \
307    USB \
308    WPA_SUPPLICANT_EAPOL
309.if defined(NO_${var})
310#.warning NO_${var} is deprecated in favour of WITHOUT_${var}=
311WITHOUT_${var}=
312.endif
313.endfor
314.endif # !defined(BURN_BRIDGES)
315
316#
317# Older-style variables that enabled behaviour when set.
318#
319.if defined(YES_HESIOD)
320WITH_HESIOD=
321.endif
322.if defined(MAKE_IDEA)
323WITH_IDEA=
324.endif
325
326__DEFAULT_YES_OPTIONS = \
327    ACCT \
328    ACPI \
329    AMD \
330    APM \
331    ASSERT_DEBUG \
332    AT \
333    ATM \
334    AUDIT \
335    AUTHPF \
336    BIND \
337    BIND_DNSSEC \
338    BIND_ETC \
339    BIND_LIBS_LWRES \
340    BIND_MTREE \
341    BIND_NAMED \
342    BIND_UTILS \
343    BINUTILS \
344    BLUETOOTH \
345    BOOT \
346    BSD_CPIO \
347    BSNMP \
348    SOURCELESS \
349    SOURCELESS_HOST \
350    SOURCELESS_UCODE \
351    BZIP2 \
352    CALENDAR \
353    CDDL \
354    CPP \
355    CRYPT \
356    CTM \
357    CVS \
358    CXX \
359    DICT \
360    DYNAMICROOT \
361    EXAMPLES \
362    FLOPPY \
363    FORTH \
364    FP_LIBC \
365    FREEBSD_UPDATE \
366    GAMES \
367    GCC \
368    GCOV \
369    GDB \
370    GNU \
371    GPIB \
372    GPIO \
373    GROFF \
374    HTML \
375    INET \
376    INET6 \
377    INFO \
378    INSTALLLIB \
379    IPFILTER \
380    IPFW \
381    IPX \
382    JAIL \
383    KERBEROS \
384    KERNEL_SYMBOLS \
385    KVM \
386    LEGACY_CONSOLE \
387    LIB32 \
388    LIBPTHREAD \
389    LIBTHR \
390    LOCALES \
391    LOCATE \
392    LPR \
393    MAIL \
394    MAILWRAPPER \
395    MAKE \
396    MAN \
397    NCP \
398    NDIS \
399    NETCAT \
400    NETGRAPH \
401    NIS \
402    NLS \
403    NLS_CATALOGS \
404    NS_CACHING \
405    NTP \
406    OPENSSH \
407    OPENSSL \
408    PAM \
409    PC_SYSINSTALL \
410    PF \
411    PKGBOOTSTRAP \
412    PKGTOOLS \
413    PMC \
414    PORTSNAP \
415    PPP \
416    PROFILE \
417    QUOTAS \
418    RCMDS \
419    RCS \
420    RESCUE \
421    ROUTED \
422    SENDMAIL \
423    SETUID_LOGIN \
424    SHAREDOCS \
425    SSP \
426    SYSINSTALL \
427    SYMVER \
428    SYSCONS \
429    TCSH \
430    TELNET \
431    TEXTPROC \
432    TOOLCHAIN \
433    USB \
434    UTMPX \
435    WIRELESS \
436    WPA_SUPPLICANT_EAPOL \
437    ZFS \
438    ZONEINFO
439
440__DEFAULT_NO_OPTIONS = \
441    BSD_GREP \
442    BIND_IDN \
443    BIND_LARGE_FILE \
444    BIND_LIBS \
445    BIND_SIGCHASE \
446    BIND_XML \
447    CLANG_EXTRAS \
448    CLANG_IS_CC \
449    CTF \
450    DEBUG_FILES \
451    HESIOD \
452    ICONV \
453    IDEA \
454    NMTREE \
455    OFED \
456    OPENSSH_NONE_CIPHER \
457    SHARED_TOOLCHAIN
458
459#
460# Default behaviour of some options depends on the architecture.  Unfortunately
461# this means that we have to test TARGET_ARCH (the buildworld case) as well
462# as MACHINE_ARCH (the non-buildworld case).  Normally TARGET_ARCH is not
463# used at all in bsd.*.mk, but we have to make an exception here if we want
464# to allow defaults for some things like clang and fdt to vary by target
465# architecture.
466#
467.if defined(TARGET_ARCH)
468__T=${TARGET_ARCH}
469.else
470__T=${MACHINE_ARCH}
471.endif
472# Clang is only for x86 and powerpc right now, by default.
473.if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*}
474__DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL
475.else
476__DEFAULT_NO_OPTIONS+=CLANG CLANG_FULL
477.endif
478# FDT is needed only for arm and powerpc
479.if ${__T:Marm*} || ${__T:Mpowerpc*}
480__DEFAULT_YES_OPTIONS+=FDT
481.else
482__DEFAULT_NO_OPTIONS+=FDT
483.endif
484.undef __T
485
486#
487# MK_* options which default to "yes".
488#
489.for var in ${__DEFAULT_YES_OPTIONS}
490.if defined(WITH_${var}) && defined(WITHOUT_${var})
491.error WITH_${var} and WITHOUT_${var} can't both be set.
492.endif
493.if defined(MK_${var})
494.error MK_${var} can't be set by a user.
495.endif
496.if defined(WITHOUT_${var})
497MK_${var}:=	no
498.else
499MK_${var}:=	yes
500.endif
501.endfor
502.undef __DEFAULT_YES_OPTIONS
503
504#
505# MK_* options which default to "no".
506#
507.for var in ${__DEFAULT_NO_OPTIONS}
508.if defined(WITH_${var}) && defined(WITHOUT_${var})
509.error WITH_${var} and WITHOUT_${var} can't both be set.
510.endif
511.if defined(MK_${var})
512.error MK_${var} can't be set by a user.
513.endif
514.if defined(WITH_${var})
515MK_${var}:=	yes
516.else
517MK_${var}:=	no
518.endif
519.endfor
520.undef __DEFAULT_NO_OPTIONS
521
522#
523# Force some options off if their dependencies are off.
524# Order is somewhat important.
525#
526.if ${MK_LIBPTHREAD} == "no"
527MK_LIBTHR:=	no
528.endif
529
530.if ${MK_LIBTHR} == "no"
531MK_BIND:=	no
532.endif
533
534.if ${MK_BIND} == "no"
535MK_BIND_DNSSEC:= no
536MK_BIND_ETC:=	no
537MK_BIND_LIBS:=	no
538MK_BIND_LIBS_LWRES:= no
539MK_BIND_MTREE:=	no
540MK_BIND_NAMED:=	no
541MK_BIND_UTILS:=	no
542.endif
543
544.if ${MK_BIND_MTREE} == "no"
545MK_BIND_ETC:=	no
546.endif
547
548.if ${MK_SOURCELESS} == "no"
549MK_SOURCELESS_HOST:=	no
550MK_SOURCELESS_UCODE:= no
551.endif
552
553.if ${MK_CDDL} == "no"
554MK_ZFS:=	no
555MK_CTF:=	no
556.endif
557
558.if ${MK_CRYPT} == "no"
559MK_OPENSSL:=	no
560MK_OPENSSH:=	no
561MK_KERBEROS:=	no
562.endif
563
564.if ${MK_CXX} == "no"
565MK_CLANG:=	no
566MK_GROFF:=	no
567.endif
568
569.if ${MK_IPX} == "no"
570MK_NCP:=	no
571.endif
572
573.if ${MK_MAIL} == "no"
574MK_MAILWRAPPER:= no
575MK_SENDMAIL:=	no
576.endif
577
578.if ${MK_NETGRAPH} == "no"
579MK_ATM:=	no
580MK_BLUETOOTH:=	no
581.endif
582
583.if ${MK_OPENSSL} == "no"
584MK_OPENSSH:=	no
585MK_KERBEROS:=	no
586.endif
587
588.if ${MK_PF} == "no"
589MK_AUTHPF:=	no
590.endif
591
592.if ${MK_TEXTPROC} == "no"
593MK_GROFF:=	no
594.endif
595
596.if ${MK_TOOLCHAIN} == "no"
597MK_BINUTILS:=	no
598MK_CLANG:=	no
599MK_GCC:=	no
600MK_GDB:=	no
601.endif
602
603.if ${MK_CLANG} == "no"
604MK_CLANG_EXTRAS:= no
605MK_CLANG_FULL:= no
606MK_CLANG_IS_CC:= no
607.endif
608
609#
610# Set defaults for the MK_*_SUPPORT variables.
611#
612
613#
614# MK_*_SUPPORT options which default to "yes" unless their corresponding
615# MK_* variable is set to "no".
616#
617.for var in \
618    BZIP2 \
619    GNU \
620    INET \
621    INET6 \
622    IPX \
623    KERBEROS \
624    KVM \
625    NETGRAPH \
626    PAM \
627    WIRELESS
628.if defined(WITH_${var}_SUPPORT) && defined(WITHOUT_${var}_SUPPORT)
629.error WITH_${var}_SUPPORT and WITHOUT_${var}_SUPPORT can't both be set.
630.endif
631.if defined(MK_${var}_SUPPORT)
632.error MK_${var}_SUPPORT can't be set by a user.
633.endif
634.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
635MK_${var}_SUPPORT:= no
636.else
637MK_${var}_SUPPORT:= yes
638.endif
639.endfor
640
641#
642# MK_* options whose default value depends on another option.
643#
644.for vv in \
645    GSSAPI/KERBEROS \
646    MAN_UTILS/MAN
647.if defined(WITH_${vv:H}) && defined(WITHOUT_${vv:H})
648.error WITH_${vv:H} and WITHOUT_${vv:H} can't both be set.
649.endif
650.if defined(MK_${vv:H})
651.error MK_${vv:H} can't be set by a user.
652.endif
653.if defined(WITH_${vv:H})
654MK_${vv:H}:=	yes
655.elif defined(WITHOUT_${vv:H})
656MK_${vv:H}:=	no
657.else
658MK_${vv:H}:=	${MK_${vv:T}}
659.endif
660.endfor
661
662#
663# MK_* options that default to "yes" if the compiler is a C++11 compiler.
664#
665.include <bsd.compiler.mk>
666.for var in \
667    LIBCPLUSPLUS
668.if defined(WITH_${var}) && defined(WITHOUT_${var})
669.error WITH_${var} and WITHOUT_${var} can't both be set.
670.endif
671.if defined(MK_${var})
672.error MK_${var} can't be set by a user.
673.endif
674.if ${COMPILER_FEATURES:Mc++11}
675.if defined(WITHOUT_${var})
676MK_${var}:=	no
677.else
678MK_${var}:=	yes
679.endif
680.else
681.if defined(WITH_${var})
682MK_${var}:=	yes
683.else
684MK_${var}:=	no
685.endif
686.endif
687.endfor
688
689.if ${MK_CTF} != "no"
690CTFCONVERT_CMD=	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
691.elif defined(.PARSEDIR) || ${MAKE_VERSION} >= 9201210220
692CTFCONVERT_CMD=
693.else
694CTFCONVERT_CMD=	@:
695.endif 
696
697.endif # !_WITHOUT_SRCCONF
698
699.endif	# !target(__<bsd.own.mk>__)
700