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