bsd.own.mk revision 245269
1# $FreeBSD: head/share/mk/bsd.own.mk 245269 2013-01-10 22:44:19Z des $
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    SHARED_TOOLCHAIN
364
365#
366# Default behaviour of some options depends on the architecture.  Unfortunately
367# this means that we have to test TARGET_ARCH (the buildworld case) as well
368# as MACHINE_ARCH (the non-buildworld case).  Normally TARGET_ARCH is not
369# used at all in bsd.*.mk, but we have to make an exception here if we want
370# to allow defaults for some things like clang and fdt to vary by target
371# architecture.
372#
373.if defined(TARGET_ARCH)
374__T=${TARGET_ARCH}
375.else
376__T=${MACHINE_ARCH}
377.endif
378# Clang is only for x86 and powerpc right now, by default.
379.if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*}
380__DEFAULT_YES_OPTIONS+=CLANG
381.else
382__DEFAULT_NO_OPTIONS+=CLANG
383.endif
384# Clang the default system compiler only on x86.
385.if ${__T} == "amd64" || ${__T} == "i386"
386__DEFAULT_YES_OPTIONS+=CLANG_IS_CC
387.else
388__DEFAULT_NO_OPTIONS+=CLANG_IS_CC
389.endif
390# FDT is needed only for arm, mips and powerpc
391.if ${__T:Marm*} || ${__T:Mpowerpc*} || ${__T:Mmips*}
392__DEFAULT_YES_OPTIONS+=FDT
393.else
394__DEFAULT_NO_OPTIONS+=FDT
395.endif
396.undef __T
397
398#
399# MK_* options which default to "yes".
400#
401.for var in ${__DEFAULT_YES_OPTIONS}
402.if defined(WITH_${var}) && defined(WITHOUT_${var})
403.error WITH_${var} and WITHOUT_${var} can't both be set.
404.endif
405.if defined(MK_${var})
406.error MK_${var} can't be set by a user.
407.endif
408.if defined(WITHOUT_${var})
409MK_${var}:=	no
410.else
411MK_${var}:=	yes
412.endif
413.endfor
414.undef __DEFAULT_YES_OPTIONS
415
416#
417# MK_* options which default to "no".
418#
419.for var in ${__DEFAULT_NO_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(WITH_${var})
427MK_${var}:=	yes
428.else
429MK_${var}:=	no
430.endif
431.endfor
432.undef __DEFAULT_NO_OPTIONS
433
434#
435# Force some options off if their dependencies are off.
436# Order is somewhat important.
437#
438.if ${MK_LIBPTHREAD} == "no"
439MK_LIBTHR:=	no
440.endif
441
442.if ${MK_LIBTHR} == "no"
443MK_BIND:=	no
444.endif
445
446.if ${MK_BIND} == "no"
447MK_BIND_DNSSEC:= no
448MK_BIND_ETC:=	no
449MK_BIND_LIBS:=	no
450MK_BIND_LIBS_LWRES:= no
451MK_BIND_MTREE:=	no
452MK_BIND_NAMED:=	no
453MK_BIND_UTILS:=	no
454.endif
455
456.if ${MK_BIND_MTREE} == "no"
457MK_BIND_ETC:=	no
458.endif
459
460.if ${MK_SOURCELESS} == "no"
461MK_SOURCELESS_HOST:=	no
462MK_SOURCELESS_UCODE:= no
463.endif
464
465.if ${MK_CDDL} == "no"
466MK_ZFS:=	no
467MK_CTF:=	no
468.endif
469
470.if ${MK_CLANG} == "no"
471MK_CLANG_EXTRAS:= no
472.endif
473
474.if ${MK_CRYPT} == "no"
475MK_OPENSSL:=	no
476MK_OPENSSH:=	no
477MK_KERBEROS:=	no
478.endif
479
480.if ${MK_CXX} == "no"
481MK_CLANG:=	no
482MK_GROFF:=	no
483.endif
484
485.if ${MK_MAIL} == "no"
486MK_MAILWRAPPER:= no
487MK_SENDMAIL:=	no
488.endif
489
490.if ${MK_NETGRAPH} == "no"
491MK_ATM:=	no
492MK_BLUETOOTH:=	no
493.endif
494
495.if ${MK_OPENSSL} == "no"
496MK_OPENSSH:=	no
497MK_KERBEROS:=	no
498.endif
499
500.if ${MK_PF} == "no"
501MK_AUTHPF:=	no
502.endif
503
504.if ${MK_TEXTPROC} == "no"
505MK_GROFF:=	no
506.endif
507
508.if ${MK_TOOLCHAIN} == "no"
509MK_BINUTILS:=	no
510MK_CLANG:=	no
511MK_GCC:=	no
512MK_GDB:=	no
513.endif
514
515.if ${MK_CLANG} == "no"
516MK_CLANG_IS_CC:= no
517.endif
518
519#
520# Set defaults for the MK_*_SUPPORT variables.
521#
522
523#
524# MK_*_SUPPORT options which default to "yes" unless their corresponding
525# MK_* variable is set to "no".
526#
527.for var in \
528    BZIP2 \
529    GNU \
530    INET \
531    INET6 \
532    IPX \
533    KERBEROS \
534    KVM \
535    NETGRAPH \
536    PAM \
537    WIRELESS
538.if defined(WITH_${var}_SUPPORT) && defined(WITHOUT_${var}_SUPPORT)
539.error WITH_${var}_SUPPORT and WITHOUT_${var}_SUPPORT can't both be set.
540.endif
541.if defined(MK_${var}_SUPPORT)
542.error MK_${var}_SUPPORT can't be set by a user.
543.endif
544.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
545MK_${var}_SUPPORT:= no
546.else
547MK_${var}_SUPPORT:= yes
548.endif
549.endfor
550
551#
552# MK_* options whose default value depends on another option.
553#
554.for vv in \
555    GSSAPI/KERBEROS \
556    MAN_UTILS/MAN
557.if defined(WITH_${vv:H}) && defined(WITHOUT_${vv:H})
558.error WITH_${vv:H} and WITHOUT_${vv:H} can't both be set.
559.endif
560.if defined(MK_${vv:H})
561.error MK_${vv:H} can't be set by a user.
562.endif
563.if defined(WITH_${vv:H})
564MK_${vv:H}:=	yes
565.elif defined(WITHOUT_${vv:H})
566MK_${vv:H}:=	no
567.else
568MK_${vv:H}:=	${MK_${vv:T}}
569.endif
570.endfor
571
572#
573# MK_* options that default to "yes" if the compiler is a C++11 compiler.
574#
575.include <bsd.compiler.mk>
576.for var in \
577    LIBCPLUSPLUS
578.if defined(WITH_${var}) && defined(WITHOUT_${var})
579.error WITH_${var} and WITHOUT_${var} can't both be set.
580.endif
581.if defined(MK_${var})
582.error MK_${var} can't be set by a user.
583.endif
584.if ${COMPILER_FEATURES:Mc++11}
585.if defined(WITHOUT_${var})
586MK_${var}:=	no
587.else
588MK_${var}:=	yes
589.endif
590.else
591.if defined(WITH_${var})
592MK_${var}:=	yes
593.else
594MK_${var}:=	no
595.endif
596.endif
597.endfor
598
599.if ${MK_CTF} != "no"
600CTFCONVERT_CMD=	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
601.elif defined(.PARSEDIR) || (defined(MAKE_VERSION) && ${MAKE_VERSION} >= 5201111300)
602CTFCONVERT_CMD=
603.else
604CTFCONVERT_CMD=	@:
605.endif 
606
607.if ${MK_INSTALL_AS_USER} != "no"
608_uid!=	id -u
609.if ${_uid} != 0
610.if !defined(USER)
611USER!=	id -un
612.endif
613_gid!=	id -gn
614.for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE
615$xOWN=	${USER}
616$xGRP=	${_gid}
617.endfor
618.endif
619.endif
620
621.endif # !_WITHOUT_SRCCONF
622
623.endif	# !target(__<bsd.own.mk>__)
624