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