xref: /freebsd/share/mk/src.opts.mk (revision ca86bcf2)
1# $FreeBSD$
2#
3# Option file for FreeBSD /usr/src builds.
4#
5# Users define WITH_FOO and WITHOUT_FOO on the command line or in /etc/src.conf
6# and /etc/make.conf files. These translate in the build system to MK_FOO={yes,no}
7# with sensible (usually) defaults.
8#
9# Makefiles must include bsd.opts.mk after defining specific MK_FOO options that
10# are applicable for that Makefile (typically there are none, but sometimes there
11# are exceptions). Recursive makes usually add MK_FOO=no for options that they wish
12# to omit from that make.
13#
14# Makefiles must include bsd.mkopt.mk before they test the value of any MK_FOO
15# variable.
16#
17# Makefiles may also assume that this file is included by src.opts.mk should it
18# need variables defined there prior to the end of the Makefile where
19# bsd.{subdir,lib.bin}.mk is traditionally included.
20#
21# The old-style YES_FOO and NO_FOO are being phased out. No new instances of them
22# should be added. Old instances should be removed since they were just to
23# bridge the gap between FreeBSD 4 and FreeBSD 5.
24#
25# Makefiles should never test WITH_FOO or WITHOUT_FOO directly (although an
26# exception is made for _WITHOUT_SRCONF which turns off this mechanism
27# completely inside bsd.*.mk files).
28#
29
30.if !target(__<src.opts.mk>__)
31__<src.opts.mk>__:
32
33.include <bsd.own.mk>
34
35#
36# Define MK_* variables (which are either "yes" or "no") for users
37# to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the
38# make(1) environment.
39# These should be tested with `== "no"' or `!= "no"' in makefiles.
40# The NO_* variables should only be set by makefiles for variables
41# that haven't been converted over.
42#
43
44# These options are used by src the builds
45
46__DEFAULT_YES_OPTIONS = \
47    ACCT \
48    ACPI \
49    AMD \
50    APM \
51    AT \
52    ATM \
53    AUDIT \
54    AUTHPF \
55    AUTOFS \
56    BHYVE \
57    BINUTILS \
58    BINUTILS_BOOTSTRAP \
59    BLACKLIST \
60    BLUETOOTH \
61    BOOT \
62    BOOTPARAMD \
63    BOOTPD \
64    BSD_CPIO \
65    BSDINSTALL \
66    BSNMP \
67    BZIP2 \
68    CALENDAR \
69    CAPSICUM \
70    CASPER \
71    CCD \
72    CDDL \
73    CPP \
74    CROSS_COMPILER \
75    CRYPT \
76    CTM \
77    CUSE \
78    CXX \
79    DIALOG \
80    DICT \
81    DMAGENT \
82    DYNAMICROOT \
83    ED_CRYPTO \
84    EE \
85    EFI \
86    ELFTOOLCHAIN_BOOTSTRAP \
87    EXAMPLES \
88    FDT \
89    FILE \
90    FINGER \
91    FLOPPY \
92    FMTREE \
93    FORTH \
94    FP_LIBC \
95    FREEBSD_UPDATE \
96    FTP \
97    GAMES \
98    GCOV \
99    GDB \
100    GNU \
101    GNU_DIFF \
102    GNU_GREP \
103    GNU_GREP_COMPAT \
104    GPIO \
105    GPL_DTC \
106    GROFF \
107    HAST \
108    HTML \
109    HYPERV \
110    ICONV \
111    INET \
112    INET6 \
113    INETD \
114    IPFILTER \
115    IPFW \
116    ISCSI \
117    JAIL \
118    KDUMP \
119    KVM \
120    LDNS \
121    LDNS_UTILS \
122    LEGACY_CONSOLE \
123    LIB32 \
124    LIBPTHREAD \
125    LIBTHR \
126    LOCALES \
127    LOCATE \
128    LPR \
129    LS_COLORS \
130    LZMA_SUPPORT \
131    MAIL \
132    MAILWRAPPER \
133    MAKE \
134    MANDOCDB \
135    NDIS \
136    NETCAT \
137    NETGRAPH \
138    NLS_CATALOGS \
139    NS_CACHING \
140    NTP \
141    OPENSSL \
142    PAM \
143    PC_SYSINSTALL \
144    PF \
145    PKGBOOTSTRAP \
146    PMC \
147    PORTSNAP \
148    PPP \
149    QUOTAS \
150    RADIUS_SUPPORT \
151    RCMDS \
152    RBOOTD \
153    RESCUE \
154    ROUTED \
155    SENDMAIL \
156    SETUID_LOGIN \
157    SHAREDOCS \
158    SOURCELESS \
159    SOURCELESS_HOST \
160    SOURCELESS_UCODE \
161    SVNLITE \
162    SYSCONS \
163    SYSTEM_COMPILER \
164    TALK \
165    TCP_WRAPPERS \
166    TCSH \
167    TELNET \
168    TESTS \
169    TEXTPROC \
170    TFTP \
171    TIMED \
172    UNBOUND \
173    USB \
174    UTMPX \
175    VI \
176    VT \
177    WIRELESS \
178    WPA_SUPPLICANT_EAPOL \
179    ZFS \
180    ZONEINFO
181
182__DEFAULT_NO_OPTIONS = \
183    BSD_GREP \
184    CLANG_EXTRAS \
185    DTRACE_TESTS \
186    HESIOD \
187    LIBSOFT \
188    NAND \
189    OFED \
190    OPENLDAP \
191    REPRODUCIBLE_BUILD \
192    SHARED_TOOLCHAIN \
193    SORT_THREADS \
194    SVN \
195
196
197#
198# Default behaviour of some options depends on the architecture.  Unfortunately
199# this means that we have to test TARGET_ARCH (the buildworld case) as well
200# as MACHINE_ARCH (the non-buildworld case).  Normally TARGET_ARCH is not
201# used at all in bsd.*.mk, but we have to make an exception here if we want
202# to allow defaults for some things like clang to vary by target architecture.
203# Additional, per-target behavior should be rarely added only after much
204# gnashing of teeth and grinding of gears.
205#
206.if defined(TARGET_ARCH)
207__T=${TARGET_ARCH}
208.else
209__T=${MACHINE_ARCH}
210.endif
211.if defined(TARGET)
212__TT=${TARGET}
213.else
214__TT=${MACHINE}
215.endif
216
217.include <bsd.compiler.mk>
218# If the compiler is not C++11 capable, disable Clang and use GCC instead.
219# This means that architectures that have GCC 4.2 as default can not
220# build Clang without using an external compiler.
221
222.if ${COMPILER_FEATURES:Mc++11} && (${__T} == "aarch64" || \
223    ${__T} == "amd64" || ${__TT} == "arm" || ${__T} == "i386")
224# Clang is enabled, and will be installed as the default /usr/bin/cc.
225__DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC LLD
226__DEFAULT_NO_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
227.elif ${COMPILER_FEATURES:Mc++11} && ${__T} != "riscv64" && ${__T} != "sparc64"
228# If an external compiler that supports C++11 is used as ${CC} and Clang
229# supports the target, then Clang is enabled but GCC is installed as the
230# default /usr/bin/cc.
231__DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL GCC GCC_BOOTSTRAP GNUCXX
232__DEFAULT_NO_OPTIONS+=CLANG_BOOTSTRAP CLANG_IS_CC LLD
233.else
234# Everything else disables Clang, and uses GCC instead.
235__DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
236__DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC LLD
237.endif
238# In-tree binutils/gcc are older versions without modern architecture support.
239.if ${__T} == "aarch64" || ${__T:Mriscv*} != ""
240BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB
241.endif
242.if ${__T:Mriscv*} != ""
243BROKEN_OPTIONS+=PROFILE # "sorry, unimplemented: profiler support for RISC-V"
244BROKEN_OPTIONS+=TESTS   # "undefined reference to `_Unwind_Resume'"
245BROKEN_OPTIONS+=CXX     # "libcxxrt.so: undefined reference to `_Unwind_Resume_or_Rethrow'"
246.endif
247.if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386" || \
248    ${__T:Mriscv*} != ""
249__DEFAULT_YES_OPTIONS+=LLVM_LIBUNWIND
250.else
251__DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND
252.endif
253.if ${__T} == "aarch64"
254__DEFAULT_YES_OPTIONS+=LLD_IS_LD
255.else
256__DEFAULT_NO_OPTIONS+=LLD_IS_LD
257.endif
258.if ${__T} == "aarch64" || ${__T} == "amd64"
259__DEFAULT_YES_OPTIONS+=LLDB
260.else
261__DEFAULT_NO_OPTIONS+=LLDB
262.endif
263# LLVM lacks support for FreeBSD 64-bit atomic operations for ARMv4/ARMv5
264.if ${__T} == "arm" || ${__T} == "armeb"
265BROKEN_OPTIONS+=LLDB
266.endif
267# Only doing soft float API stuff on armv6
268.if ${__T} != "armv6"
269BROKEN_OPTIONS+=LIBSOFT
270.endif
271.if ${__T:Mmips*}
272BROKEN_OPTIONS+=SSP
273.endif
274.if ${__T:Mmips*} || ${__T:Mpowerpc*} || ${__T:Msparc64} || ${__T:Mriscv*}
275BROKEN_OPTIONS+=EFI
276.endif
277
278.if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386" || \
279    ${__T} == "powerpc64" || ${__T} == "sparc64"
280__DEFAULT_YES_OPTIONS+=CXGBETOOL
281.else
282__DEFAULT_NO_OPTIONS+=CXGBETOOL
283.endif
284
285.include <bsd.mkopt.mk>
286
287#
288# MK_* options that default to "yes" if the compiler is a C++11 compiler.
289#
290.for var in \
291    LIBCPLUSPLUS
292.if !defined(MK_${var})
293.if ${COMPILER_FEATURES:Mc++11}
294.if defined(WITHOUT_${var})
295MK_${var}:=	no
296.else
297MK_${var}:=	yes
298.endif
299.else
300.if defined(WITH_${var})
301MK_${var}:=	yes
302.else
303MK_${var}:=	no
304.endif
305.endif
306.endif
307.endfor
308
309#
310# Force some options off if their dependencies are off.
311# Order is somewhat important.
312#
313.if !${COMPILER_FEATURES:Mc++11}
314MK_LLVM_LIBUNWIND:=	no
315.endif
316
317.if ${MK_BINUTILS} == "no"
318MK_GDB:=	no
319.endif
320
321.if ${MK_CAPSICUM} == "no"
322MK_CASPER:=	no
323.endif
324
325.if ${MK_LIBPTHREAD} == "no"
326MK_LIBTHR:=	no
327.endif
328
329.if ${MK_LDNS} == "no"
330MK_LDNS_UTILS:=	no
331MK_UNBOUND:= no
332.endif
333
334.if ${MK_LLD} == "no"
335MK_LLD_IS_LD:=	no
336.endif
337
338# LLD requires LLVM libraries, and we do not yet compare in-tree and host LLD
339# versions to avoid building it if they are identical.
340.if ${MK_LLD_IS_LD} != "no"
341MK_SYSTEM_COMPILER:=	no
342.endif
343
344.if ${MK_SOURCELESS} == "no"
345MK_SOURCELESS_HOST:=	no
346MK_SOURCELESS_UCODE:= no
347.endif
348
349.if ${MK_CDDL} == "no"
350MK_ZFS:=	no
351MK_CTF:=	no
352.endif
353
354.if ${MK_CRYPT} == "no"
355MK_OPENSSL:=	no
356MK_OPENSSH:=	no
357MK_KERBEROS:=	no
358.endif
359
360.if ${MK_CXX} == "no"
361MK_CLANG:=	no
362MK_GROFF:=	no
363MK_GNUCXX:=	no
364MK_TESTS:=	no
365.endif
366
367.if ${MK_DIALOG} == "no"
368MK_BSDINSTALL:=	no
369.endif
370
371.if ${MK_MAIL} == "no"
372MK_MAILWRAPPER:= no
373MK_SENDMAIL:=	no
374MK_DMAGENT:=	no
375.endif
376
377.if ${MK_NETGRAPH} == "no"
378MK_ATM:=	no
379MK_BLUETOOTH:=	no
380.endif
381
382.if ${MK_OPENSSL} == "no"
383MK_OPENSSH:=	no
384MK_KERBEROS:=	no
385.endif
386
387.if ${MK_PF} == "no"
388MK_AUTHPF:=	no
389.endif
390
391.if ${MK_TESTS} == "no"
392MK_DTRACE_TESTS:= no
393.endif
394
395.if ${MK_TEXTPROC} == "no"
396MK_GROFF:=	no
397.endif
398
399.if ${MK_CROSS_COMPILER} == "no"
400MK_BINUTILS_BOOTSTRAP:= no
401MK_CLANG_BOOTSTRAP:= no
402MK_ELFTOOLCHAIN_BOOTSTRAP:= no
403MK_GCC_BOOTSTRAP:= no
404.endif
405
406.if ${MK_TOOLCHAIN} == "no"
407MK_BINUTILS:=	no
408MK_CLANG:=	no
409MK_GCC:=	no
410MK_GDB:=	no
411MK_INCLUDES:=	no
412MK_LLDB:=	no
413.endif
414
415.if ${MK_CLANG} == "no"
416MK_CLANG_EXTRAS:= no
417MK_CLANG_FULL:= no
418.endif
419
420#
421# MK_* options whose default value depends on another option.
422#
423.for vv in \
424    GSSAPI/KERBEROS \
425    MAN_UTILS/MAN
426.if defined(WITH_${vv:H})
427MK_${vv:H}:=	yes
428.elif defined(WITHOUT_${vv:H})
429MK_${vv:H}:=	no
430.else
431MK_${vv:H}:=	${MK_${vv:T}}
432.endif
433.endfor
434
435#
436# Set defaults for the MK_*_SUPPORT variables.
437#
438
439#
440# MK_*_SUPPORT options which default to "yes" unless their corresponding
441# MK_* variable is set to "no".
442#
443.for var in \
444    BLACKLIST \
445    BZIP2 \
446    GNU \
447    INET \
448    INET6 \
449    KERBEROS \
450    KVM \
451    NETGRAPH \
452    PAM \
453    TESTS \
454    WIRELESS
455.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
456MK_${var}_SUPPORT:= no
457.else
458MK_${var}_SUPPORT:= yes
459.endif
460.endfor
461
462.if !${COMPILER_FEATURES:Mc++11}
463MK_LLDB:=	no
464.endif
465
466# gcc 4.8 and newer supports libc++, so suppress gnuc++ in that case.
467# while in theory we could build it with that, we don't want to do
468# that since it creates too much confusion for too little gain.
469# XXX: This is incomplete and needs X_COMPILER_TYPE/VERSION checks too
470#      to prevent Makefile.inc1 from bootstrapping unneeded dependencies
471#      and to support 'make delete-old' when supplying an external toolchain.
472.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800
473MK_GNUCXX:=no
474MK_GCC:=no
475.endif
476
477.endif #  !target(__<src.opts.mk>__)
478