bsd.own.mk revision 250658
1# $FreeBSD: head/share/mk/bsd.own.mk 250658 2013-05-15 13:04:10Z brooks $
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    FORMAT_EXTENSIONS \
272    FORTH \
273    FP_LIBC \
274    FREEBSD_UPDATE \
275    GAMES \
276    GCC \
277    GCOV \
278    GDB \
279    GNU \
280    GPIB \
281    GPIO \
282    GROFF \
283    HTML \
284    INET \
285    INET6 \
286    INFO \
287    INSTALLLIB \
288    IPFILTER \
289    IPFW \
290    IPX \
291    JAIL \
292    KDUMP \
293    KERBEROS \
294    KERNEL_SYMBOLS \
295    KVM \
296    LDNS \
297    LEGACY_CONSOLE \
298    LIB32 \
299    LIBPTHREAD \
300    LIBTHR \
301    LOCALES \
302    LOCATE \
303    LPR \
304    LS_COLORS \
305    MAIL \
306    MAILWRAPPER \
307    MAKE \
308    MAN \
309    NDIS \
310    NETCAT \
311    NETGRAPH \
312    NIS \
313    NLS \
314    NLS_CATALOGS \
315    NS_CACHING \
316    NTP \
317    OPENSSH \
318    OPENSSL \
319    PAM \
320    PC_SYSINSTALL \
321    PF \
322    PKGBOOTSTRAP \
323    PKGTOOLS \
324    PMC \
325    PORTSNAP \
326    PPP \
327    PROFILE \
328    QUOTAS \
329    RCMDS \
330    RCS \
331    RESCUE \
332    ROUTED \
333    SENDMAIL \
334    SETUID_LOGIN \
335    SHAREDOCS \
336    SOURCELESS \
337    SOURCELESS_HOST \
338    SOURCELESS_UCODE \
339    SSP \
340    SYMVER \
341    SYSCONS \
342    SYSINSTALL \
343    TCSH \
344    TELNET \
345    TEXTPROC \
346    TOOLCHAIN \
347    USB \
348    UTMPX \
349    WIRELESS \
350    WPA_SUPPLICANT_EAPOL \
351    ZFS \
352    ZONEINFO
353
354__DEFAULT_NO_OPTIONS = \
355    ARM_EABI \
356    BSD_PATCH \
357    BIND_IDN \
358    BIND_LARGE_FILE \
359    BIND_LIBS \
360    BIND_SIGCHASE \
361    BIND_XML \
362    BMAKE \
363    BSDCONFIG \
364    BSD_GREP \
365    CLANG_EXTRAS \
366    CTF \
367    GPL_DTC \
368    HESIOD \
369    ICONV \
370    INSTALL_AS_USER \
371    LDNS_UTILS \
372    NMTREE \
373    NAND \
374    OFED \
375    OPENSSH_NONE_CIPHER \
376    SHARED_TOOLCHAIN
377
378#
379# Default behaviour of some options depends on the architecture.  Unfortunately
380# this means that we have to test TARGET_ARCH (the buildworld case) as well
381# as MACHINE_ARCH (the non-buildworld case).  Normally TARGET_ARCH is not
382# used at all in bsd.*.mk, but we have to make an exception here if we want
383# to allow defaults for some things like clang and fdt to vary by target
384# architecture.
385#
386.if defined(TARGET_ARCH)
387__T=${TARGET_ARCH}
388.else
389__T=${MACHINE_ARCH}
390.endif
391# Clang is only for x86, powerpc and little-endian arm right now, by default.
392.if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*}
393__DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL
394.elif ${__T} == "arm" || ${__T} == "armv6"
395__DEFAULT_YES_OPTIONS+=CLANG
396# GCC is unable to build the full clang on arm, disable it by default.
397__DEFAULT_NO_OPTIONS+=CLANG_FULL
398.else
399__DEFAULT_NO_OPTIONS+=CLANG CLANG_FULL
400.endif
401# Clang the default system compiler only on little-endian arm and x86.
402.if ${__T} == "amd64" || ${__T} == "arm" || ${__T} == "armv6" || \
403    ${__T} == "i386"
404__DEFAULT_YES_OPTIONS+=CLANG_IS_CC
405.else
406__DEFAULT_NO_OPTIONS+=CLANG_IS_CC
407.endif
408# FDT is needed only for arm, mips and powerpc
409.if ${__T:Marm*} || ${__T:Mpowerpc*} || ${__T:Mmips*}
410__DEFAULT_YES_OPTIONS+=FDT
411.else
412__DEFAULT_NO_OPTIONS+=FDT
413.endif
414.undef __T
415
416#
417# MK_* options which default to "yes".
418#
419.for var in ${__DEFAULT_YES_OPTIONS}
420.if defined(WITH_${var}) && defined(WITHOUT_${var})
421.error WITH_${var} and WITHOUT_${var} can't both be set.
422.endif
423.if defined(MK_${var})
424.error MK_${var} can't be set by a user.
425.endif
426.if defined(WITHOUT_${var})
427MK_${var}:=	no
428.else
429MK_${var}:=	yes
430.endif
431.endfor
432.undef __DEFAULT_YES_OPTIONS
433
434#
435# MK_* options which default to "no".
436#
437.for var in ${__DEFAULT_NO_OPTIONS}
438.if defined(WITH_${var}) && defined(WITHOUT_${var})
439.error WITH_${var} and WITHOUT_${var} can't both be set.
440.endif
441.if defined(MK_${var})
442.error MK_${var} can't be set by a user.
443.endif
444.if defined(WITH_${var})
445MK_${var}:=	yes
446.else
447MK_${var}:=	no
448.endif
449.endfor
450.undef __DEFAULT_NO_OPTIONS
451
452#
453# Force some options off if their dependencies are off.
454# Order is somewhat important.
455#
456.if ${MK_LIBPTHREAD} == "no"
457MK_LIBTHR:=	no
458.endif
459
460.if ${MK_LIBTHR} == "no"
461MK_BIND:=	no
462.endif
463
464.if ${MK_BIND} == "no"
465MK_BIND_DNSSEC:= no
466MK_BIND_ETC:=	no
467MK_BIND_LIBS:=	no
468MK_BIND_LIBS_LWRES:= no
469MK_BIND_MTREE:=	no
470MK_BIND_NAMED:=	no
471MK_BIND_UTILS:=	no
472.endif
473
474.if ${MK_LDNS} == "no"
475MK_LDNS_UTILS:=	no
476.endif
477
478.if ${MK_LDNS_UTILS} != "no"
479MK_BIND_UTILS:=	no
480.endif
481
482.if ${MK_BIND_MTREE} == "no"
483MK_BIND_ETC:=	no
484.endif
485
486.if ${MK_SOURCELESS} == "no"
487MK_SOURCELESS_HOST:=	no
488MK_SOURCELESS_UCODE:= no
489.endif
490
491.if ${MK_CDDL} == "no"
492MK_ZFS:=	no
493MK_CTF:=	no
494.endif
495
496.if ${MK_CRYPT} == "no"
497MK_OPENSSL:=	no
498MK_OPENSSH:=	no
499MK_KERBEROS:=	no
500.endif
501
502.if ${MK_CXX} == "no"
503MK_CLANG:=	no
504MK_GROFF:=	no
505.endif
506
507.if ${MK_MAIL} == "no"
508MK_MAILWRAPPER:= no
509MK_SENDMAIL:=	no
510.endif
511
512.if ${MK_NETGRAPH} == "no"
513MK_ATM:=	no
514MK_BLUETOOTH:=	no
515.endif
516
517.if ${MK_OPENSSL} == "no"
518MK_OPENSSH:=	no
519MK_KERBEROS:=	no
520.endif
521
522.if ${MK_PF} == "no"
523MK_AUTHPF:=	no
524.endif
525
526.if ${MK_TEXTPROC} == "no"
527MK_GROFF:=	no
528.endif
529
530.if ${MK_TOOLCHAIN} == "no"
531MK_BINUTILS:=	no
532MK_CLANG:=	no
533MK_GCC:=	no
534MK_GDB:=	no
535.endif
536
537.if ${MK_CLANG} == "no"
538MK_CLANG_EXTRAS:= no
539MK_CLANG_FULL:= no
540MK_CLANG_IS_CC:= no
541.endif
542
543#
544# Set defaults for the MK_*_SUPPORT variables.
545#
546
547#
548# MK_*_SUPPORT options which default to "yes" unless their corresponding
549# MK_* variable is set to "no".
550#
551.for var in \
552    BZIP2 \
553    GNU \
554    INET \
555    INET6 \
556    IPX \
557    KERBEROS \
558    KVM \
559    NETGRAPH \
560    PAM \
561    WIRELESS
562.if defined(WITH_${var}_SUPPORT) && defined(WITHOUT_${var}_SUPPORT)
563.error WITH_${var}_SUPPORT and WITHOUT_${var}_SUPPORT can't both be set.
564.endif
565.if defined(MK_${var}_SUPPORT)
566.error MK_${var}_SUPPORT can't be set by a user.
567.endif
568.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
569MK_${var}_SUPPORT:= no
570.else
571MK_${var}_SUPPORT:= yes
572.endif
573.endfor
574
575#
576# MK_* options whose default value depends on another option.
577#
578.for vv in \
579    GSSAPI/KERBEROS \
580    MAN_UTILS/MAN
581.if defined(WITH_${vv:H}) && defined(WITHOUT_${vv:H})
582.error WITH_${vv:H} and WITHOUT_${vv:H} can't both be set.
583.endif
584.if defined(MK_${vv:H})
585.error MK_${vv:H} can't be set by a user.
586.endif
587.if defined(WITH_${vv:H})
588MK_${vv:H}:=	yes
589.elif defined(WITHOUT_${vv:H})
590MK_${vv:H}:=	no
591.else
592MK_${vv:H}:=	${MK_${vv:T}}
593.endif
594.endfor
595
596#
597# MK_* options that default to "yes" if the compiler is a C++11 compiler.
598#
599.include <bsd.compiler.mk>
600.for var in \
601    LIBCPLUSPLUS
602.if defined(WITH_${var}) && defined(WITHOUT_${var})
603.error WITH_${var} and WITHOUT_${var} can't both be set.
604.endif
605.if defined(MK_${var})
606.error MK_${var} can't be set by a user.
607.endif
608.if ${COMPILER_FEATURES:Mc++11}
609.if defined(WITHOUT_${var})
610MK_${var}:=	no
611.else
612MK_${var}:=	yes
613.endif
614.else
615.if defined(WITH_${var})
616MK_${var}:=	yes
617.else
618MK_${var}:=	no
619.endif
620.endif
621.endfor
622
623.if ${MK_CTF} != "no"
624CTFCONVERT_CMD=	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
625.elif defined(.PARSEDIR) || (defined(MAKE_VERSION) && ${MAKE_VERSION} >= 5201111300)
626CTFCONVERT_CMD=
627.else
628CTFCONVERT_CMD=	@:
629.endif 
630
631.if ${MK_INSTALL_AS_USER} != "no"
632_uid!=	id -u
633.if ${_uid} != 0
634.if !defined(USER)
635USER!=	id -un
636.endif
637_gid!=	id -gn
638.for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE
639$xOWN=	${USER}
640$xGRP=	${_gid}
641.endfor
642.endif
643.endif
644
645.endif # !_WITHOUT_SRCCONF
646
647.endif	# !target(__<bsd.own.mk>__)
648