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