bsd.own.mk revision 245527
1# $FreeBSD: head/share/mk/bsd.own.mk 245527 2013-01-17 01:51:04Z bz $
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})
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# Common variables
185.if !defined(DEBUG_FLAGS)
186STRIP?=		-s
187.endif
188
189COMPRESS_CMD?=	gzip -cn
190COMPRESS_EXT?=	.gz
191
192.if !defined(_WITHOUT_SRCCONF)
193#
194# Define MK_* variables (which are either "yes" or "no") for users
195# to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the
196# make(1) environment.
197# These should be tested with `== "no"' or `!= "no"' in makefiles.
198# The NO_* variables should only be set by makefiles.
199#
200
201#
202# Supported NO_* options (if defined, MK_* will be forced to "no",
203# regardless of user's setting).
204#
205.for var in \
206    CTF \
207    INSTALLLIB \
208    MAN \
209    PROFILE
210.if defined(NO_${var})
211.if defined(WITH_${var})
212.undef WITH_${var}
213.endif
214WITHOUT_${var}=
215.endif
216.endfor
217
218#
219# Older-style variables that enabled behaviour when set.
220#
221.if defined(YES_HESIOD)
222WITH_HESIOD=
223.endif
224.if defined(MAKE_IDEA)
225WITH_IDEA=
226.endif
227
228__DEFAULT_YES_OPTIONS = \
229    ACCT \
230    ACPI \
231    AMD \
232    APM \
233    ASSERT_DEBUG \
234    AT \
235    ATF \
236    ATM \
237    AUDIT \
238    AUTHPF \
239    BIND \
240    BIND_DNSSEC \
241    BIND_ETC \
242    BIND_LIBS_LWRES \
243    BIND_MTREE \
244    BIND_NAMED \
245    BIND_UTILS \
246    BINUTILS \
247    BLUETOOTH \
248    BOOT \
249    BSD_CPIO \
250    BSNMP \
251    BZIP2 \
252    CALENDAR \
253    CAPSICUM \
254    CDDL \
255    CPP \
256    CRYPT \
257    CTM \
258    CVS \
259    CXX \
260    DICT \
261    DYNAMICROOT \
262    ED_CRYPTO \
263    EXAMPLES \
264    FLOPPY \
265    FORTH \
266    FP_LIBC \
267    FREEBSD_UPDATE \
268    GAMES \
269    GCC \
270    GCOV \
271    GDB \
272    GNU \
273    GPIB \
274    GPIO \
275    GROFF \
276    HTML \
277    INET \
278    INET6 \
279    INFO \
280    INSTALLLIB \
281    IPFILTER \
282    IPFW \
283    IPX \
284    JAIL \
285    KDUMP \
286    KERBEROS \
287    KERNEL_SYMBOLS \
288    KVM \
289    LEGACY_CONSOLE \
290    LIB32 \
291    LIBPTHREAD \
292    LIBTHR \
293    LOCALES \
294    LOCATE \
295    LPR \
296    LS_COLORS \
297    MAIL \
298    MAILWRAPPER \
299    MAKE \
300    MAN \
301    NDIS \
302    NETCAT \
303    NETGRAPH \
304    NIS \
305    NLS \
306    NLS_CATALOGS \
307    NS_CACHING \
308    NTP \
309    OPENSSH \
310    OPENSSL \
311    PAM \
312    PF \
313    PKGBOOTSTRAP \
314    PKGTOOLS \
315    PMC \
316    PORTSNAP \
317    PPP \
318    PROFILE \
319    QUOTAS \
320    RCMDS \
321    RCS \
322    RESCUE \
323    ROUTED \
324    SENDMAIL \
325    SETUID_LOGIN \
326    SHAREDOCS \
327    SOURCELESS \
328    SOURCELESS_HOST \
329    SOURCELESS_UCODE \
330    SSP \
331    SYMVER \
332    SYSCONS \
333    SYSINSTALL \
334    TCSH \
335    TELNET \
336    TEXTPROC \
337    TOOLCHAIN \
338    USB \
339    UTMPX \
340    WIRELESS \
341    WPA_SUPPLICANT_EAPOL \
342    ZFS \
343    ZONEINFO
344
345__DEFAULT_NO_OPTIONS = \
346    BIND_IDN \
347    BIND_LARGE_FILE \
348    BIND_LIBS \
349    BIND_SIGCHASE \
350    BIND_XML \
351    BMAKE \
352    BSDCONFIG \
353    BSD_GREP \
354    CLANG_EXTRAS \
355    CTF \
356    HESIOD \
357    ICONV \
358    IDEA \
359    INSTALL_AS_USER \
360    NMTREE \
361    NAND \
362    OFED \
363    OPENSSH_NONE_CIPHER \
364    SHARED_TOOLCHAIN
365
366#
367# Default behaviour of some options depends on the architecture.  Unfortunately
368# this means that we have to test TARGET_ARCH (the buildworld case) as well
369# as MACHINE_ARCH (the non-buildworld case).  Normally TARGET_ARCH is not
370# used at all in bsd.*.mk, but we have to make an exception here if we want
371# to allow defaults for some things like clang and fdt to vary by target
372# architecture.
373#
374.if defined(TARGET_ARCH)
375__T=${TARGET_ARCH}
376.else
377__T=${MACHINE_ARCH}
378.endif
379# Clang is only for x86 and powerpc right now, by default.
380.if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*}
381__DEFAULT_YES_OPTIONS+=CLANG
382.else
383__DEFAULT_NO_OPTIONS+=CLANG
384.endif
385# Clang the default system compiler only on x86.
386.if ${__T} == "amd64" || ${__T} == "i386"
387__DEFAULT_YES_OPTIONS+=CLANG_IS_CC
388.else
389__DEFAULT_NO_OPTIONS+=CLANG_IS_CC
390.endif
391# FDT is needed only for arm, mips and powerpc
392.if ${__T:Marm*} || ${__T:Mpowerpc*} || ${__T:Mmips*}
393__DEFAULT_YES_OPTIONS+=FDT
394.else
395__DEFAULT_NO_OPTIONS+=FDT
396.endif
397.undef __T
398
399#
400# MK_* options which default to "yes".
401#
402.for var in ${__DEFAULT_YES_OPTIONS}
403.if defined(WITH_${var}) && defined(WITHOUT_${var})
404.error WITH_${var} and WITHOUT_${var} can't both be set.
405.endif
406.if defined(MK_${var})
407.error MK_${var} can't be set by a user.
408.endif
409.if defined(WITHOUT_${var})
410MK_${var}:=	no
411.else
412MK_${var}:=	yes
413.endif
414.endfor
415.undef __DEFAULT_YES_OPTIONS
416
417#
418# MK_* options which default to "no".
419#
420.for var in ${__DEFAULT_NO_OPTIONS}
421.if defined(WITH_${var}) && defined(WITHOUT_${var})
422.error WITH_${var} and WITHOUT_${var} can't both be set.
423.endif
424.if defined(MK_${var})
425.error MK_${var} can't be set by a user.
426.endif
427.if defined(WITH_${var})
428MK_${var}:=	yes
429.else
430MK_${var}:=	no
431.endif
432.endfor
433.undef __DEFAULT_NO_OPTIONS
434
435#
436# Force some options off if their dependencies are off.
437# Order is somewhat important.
438#
439.if ${MK_LIBPTHREAD} == "no"
440MK_LIBTHR:=	no
441.endif
442
443.if ${MK_LIBTHR} == "no"
444MK_BIND:=	no
445.endif
446
447.if ${MK_BIND} == "no"
448MK_BIND_DNSSEC:= no
449MK_BIND_ETC:=	no
450MK_BIND_LIBS:=	no
451MK_BIND_LIBS_LWRES:= no
452MK_BIND_MTREE:=	no
453MK_BIND_NAMED:=	no
454MK_BIND_UTILS:=	no
455.endif
456
457.if ${MK_BIND_MTREE} == "no"
458MK_BIND_ETC:=	no
459.endif
460
461.if ${MK_SOURCELESS} == "no"
462MK_SOURCELESS_HOST:=	no
463MK_SOURCELESS_UCODE:= no
464.endif
465
466.if ${MK_CDDL} == "no"
467MK_ZFS:=	no
468MK_CTF:=	no
469.endif
470
471.if ${MK_CLANG} == "no"
472MK_CLANG_EXTRAS:= no
473.endif
474
475.if ${MK_CRYPT} == "no"
476MK_OPENSSL:=	no
477MK_OPENSSH:=	no
478MK_KERBEROS:=	no
479.endif
480
481.if ${MK_CXX} == "no"
482MK_CLANG:=	no
483MK_GROFF:=	no
484.endif
485
486.if ${MK_MAIL} == "no"
487MK_MAILWRAPPER:= no
488MK_SENDMAIL:=	no
489.endif
490
491.if ${MK_NETGRAPH} == "no"
492MK_ATM:=	no
493MK_BLUETOOTH:=	no
494.endif
495
496.if ${MK_OPENSSL} == "no"
497MK_OPENSSH:=	no
498MK_KERBEROS:=	no
499.endif
500
501.if ${MK_PF} == "no"
502MK_AUTHPF:=	no
503.endif
504
505.if ${MK_TEXTPROC} == "no"
506MK_GROFF:=	no
507.endif
508
509.if ${MK_TOOLCHAIN} == "no"
510MK_BINUTILS:=	no
511MK_CLANG:=	no
512MK_GCC:=	no
513MK_GDB:=	no
514.endif
515
516.if ${MK_CLANG} == "no"
517MK_CLANG_IS_CC:= no
518.endif
519
520#
521# Set defaults for the MK_*_SUPPORT variables.
522#
523
524#
525# MK_*_SUPPORT options which default to "yes" unless their corresponding
526# MK_* variable is set to "no".
527#
528.for var in \
529    BZIP2 \
530    GNU \
531    INET \
532    INET6 \
533    IPX \
534    KERBEROS \
535    KVM \
536    NETGRAPH \
537    PAM \
538    WIRELESS
539.if defined(WITH_${var}_SUPPORT) && defined(WITHOUT_${var}_SUPPORT)
540.error WITH_${var}_SUPPORT and WITHOUT_${var}_SUPPORT can't both be set.
541.endif
542.if defined(MK_${var}_SUPPORT)
543.error MK_${var}_SUPPORT can't be set by a user.
544.endif
545.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
546MK_${var}_SUPPORT:= no
547.else
548MK_${var}_SUPPORT:= yes
549.endif
550.endfor
551
552#
553# MK_* options whose default value depends on another option.
554#
555.for vv in \
556    GSSAPI/KERBEROS \
557    MAN_UTILS/MAN
558.if defined(WITH_${vv:H}) && defined(WITHOUT_${vv:H})
559.error WITH_${vv:H} and WITHOUT_${vv:H} can't both be set.
560.endif
561.if defined(MK_${vv:H})
562.error MK_${vv:H} can't be set by a user.
563.endif
564.if defined(WITH_${vv:H})
565MK_${vv:H}:=	yes
566.elif defined(WITHOUT_${vv:H})
567MK_${vv:H}:=	no
568.else
569MK_${vv:H}:=	${MK_${vv:T}}
570.endif
571.endfor
572
573#
574# MK_* options that default to "yes" if the compiler is a C++11 compiler.
575#
576.include <bsd.compiler.mk>
577.for var in \
578    LIBCPLUSPLUS
579.if defined(WITH_${var}) && defined(WITHOUT_${var})
580.error WITH_${var} and WITHOUT_${var} can't both be set.
581.endif
582.if defined(MK_${var})
583.error MK_${var} can't be set by a user.
584.endif
585.if ${COMPILER_FEATURES:Mc++11}
586.if defined(WITHOUT_${var})
587MK_${var}:=	no
588.else
589MK_${var}:=	yes
590.endif
591.else
592.if defined(WITH_${var})
593MK_${var}:=	yes
594.else
595MK_${var}:=	no
596.endif
597.endif
598.endfor
599
600.if ${MK_CTF} != "no"
601CTFCONVERT_CMD=	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
602.elif defined(.PARSEDIR) || (defined(MAKE_VERSION) && ${MAKE_VERSION} >= 5201111300)
603CTFCONVERT_CMD=
604.else
605CTFCONVERT_CMD=	@:
606.endif 
607
608.if ${MK_INSTALL_AS_USER} != "no"
609_uid!=	id -u
610.if ${_uid} != 0
611.if !defined(USER)
612USER!=	id -un
613.endif
614_gid!=	id -gn
615.for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE
616$xOWN=	${USER}
617$xGRP=	${_gid}
618.endfor
619.endif
620.endif
621
622.endif # !_WITHOUT_SRCCONF
623
624.endif	# !target(__<bsd.own.mk>__)
625