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