src.opts.mk revision 363496
1# $FreeBSD: stable/11/share/mk/src.opts.mk 363496 2020-07-24 20:54:07Z dim $
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    BSD_GREP_FASTMATCH \
66    BSDINSTALL \
67    BSNMP \
68    BZIP2 \
69    CALENDAR \
70    CAPSICUM \
71    CAROOT \
72    CASPER \
73    CCD \
74    CDDL \
75    CPP \
76    CROSS_COMPILER \
77    CRYPT \
78    CTM \
79    CUSE \
80    CXX \
81    DIALOG \
82    DICT \
83    DMAGENT \
84    DYNAMICROOT \
85    ED_CRYPTO \
86    EE \
87    ELFCOPY_AS_OBJCOPY \
88    EFI \
89    ELFTOOLCHAIN_BOOTSTRAP \
90    EXAMPLES \
91    FDT \
92    FILE \
93    FINGER \
94    FLOPPY \
95    FMTREE \
96    FORTH \
97    FP_LIBC \
98    FREEBSD_UPDATE \
99    FTP \
100    GAMES \
101    GCOV \
102    GDB \
103    GNU \
104    GNU_DIFF \
105    GNU_GREP \
106    GNU_GREP_COMPAT \
107    GPIO \
108    GPL_DTC \
109    GROFF \
110    HAST \
111    HTML \
112    HYPERV \
113    ICONV \
114    INET \
115    INET6 \
116    INETD \
117    IPFILTER \
118    IPFW \
119    ISCSI \
120    JAIL \
121    KDUMP \
122    KVM \
123    LDNS \
124    LDNS_UTILS \
125    LEGACY_CONSOLE \
126    LIB32 \
127    LIBPTHREAD \
128    LIBTHR \
129    LLVM_COV \
130    LOADER_GELI \
131    LOADER_LUA \
132    LOADER_OFW \
133    LOADER_UBOOT \
134    LOCALES \
135    LOCATE \
136    LPR \
137    LS_COLORS \
138    LZMA_SUPPORT \
139    MAIL \
140    MAILWRAPPER \
141    MAKE \
142    MANDOCDB \
143    NDIS \
144    NETCAT \
145    NETGRAPH \
146    NLS_CATALOGS \
147    NS_CACHING \
148    NTP \
149    OPENSSL \
150    PAM \
151    PC_SYSINSTALL \
152    PF \
153    PKGBOOTSTRAP \
154    PMC \
155    PORTSNAP \
156    PPP \
157    QUOTAS \
158    RADIUS_SUPPORT \
159    RCMDS \
160    RBOOTD \
161    RCS \
162    RESCUE \
163    ROUTED \
164    SENDMAIL \
165    SETUID_LOGIN \
166    SHAREDOCS \
167    SOURCELESS \
168    SOURCELESS_HOST \
169    SOURCELESS_UCODE \
170    SVNLITE \
171    SYSCONS \
172    SYSTEM_COMPILER \
173    TALK \
174    TCP_WRAPPERS \
175    TCSH \
176    TELNET \
177    TESTS \
178    TEXTPROC \
179    TFTP \
180    TIMED \
181    UNBOUND \
182    USB \
183    UTMPX \
184    VI \
185    VT \
186    WIRELESS \
187    WPA_SUPPLICANT_EAPOL \
188    ZFS \
189    LOADER_ZFS \
190    ZONEINFO
191
192__DEFAULT_NO_OPTIONS = \
193    BSD_GREP \
194    CLANG_EXTRAS \
195    CLANG_FORMAT \
196    DTRACE_TESTS \
197    EISA \
198    HESIOD \
199    LIBSOFT \
200    LINT \
201    LLVM_ASSERTIONS \
202    LOADER_FIREWIRE \
203    LOADER_FORCE_LE \
204    LOADER_VERBOSE \
205    NAND \
206    OFED_EXTRA \
207    OPENLDAP \
208    REPRODUCIBLE_BUILD \
209    RPCBIND_WARMSTART_SUPPORT \
210    SHARED_TOOLCHAIN \
211    SORT_THREADS \
212    SVN \
213    ZONEINFO_LEAPSECONDS_SUPPORT \
214
215
216#
217# Default behaviour of some options depends on the architecture.  Unfortunately
218# this means that we have to test TARGET_ARCH (the buildworld case) as well
219# as MACHINE_ARCH (the non-buildworld case).  Normally TARGET_ARCH is not
220# used at all in bsd.*.mk, but we have to make an exception here if we want
221# to allow defaults for some things like clang to vary by target architecture.
222# Additional, per-target behavior should be rarely added only after much
223# gnashing of teeth and grinding of gears.
224#
225.if defined(TARGET_ARCH)
226__T=${TARGET_ARCH}
227.else
228__T=${MACHINE_ARCH}
229.endif
230.if defined(TARGET)
231__TT=${TARGET}
232.else
233__TT=${MACHINE}
234.endif
235
236__DEFAULT_NO_OPTIONS+=LLVM_TARGET_BPF
237__DEFAULT_NO_OPTIONS+=LLVM_TARGET_RISCV
238
239.include <bsd.compiler.mk>
240# If the compiler is not C++11 capable, disable Clang and use GCC instead.
241# This means that architectures that have GCC 4.2 as default can not
242# build Clang without using an external compiler.
243
244.if ${COMPILER_FEATURES:Mc++11} && (${__T} == "aarch64" || \
245    ${__T} == "amd64" || ${__TT} == "arm" || ${__T} == "i386")
246# Clang is enabled, and will be installed as the default /usr/bin/cc.
247__DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC LLD
248__DEFAULT_YES_OPTIONS+=LLVM_TARGET_AARCH64 LLVM_TARGET_ARM LLVM_TARGET_MIPS
249__DEFAULT_YES_OPTIONS+=LLVM_TARGET_POWERPC LLVM_TARGET_SPARC LLVM_TARGET_X86
250__DEFAULT_NO_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
251.elif ${COMPILER_FEATURES:Mc++11} && ${__T} != "riscv64" && ${__T} != "sparc64"
252# If an external compiler that supports C++11 is used as ${CC} and Clang
253# supports the target, then Clang is enabled but GCC is installed as the
254# default /usr/bin/cc.
255__DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL GCC GCC_BOOTSTRAP GNUCXX
256__DEFAULT_YES_OPTIONS+=LLVM_TARGET_AARCH64 LLVM_TARGET_ARM LLVM_TARGET_MIPS
257__DEFAULT_YES_OPTIONS+=LLVM_TARGET_POWERPC LLVM_TARGET_SPARC LLVM_TARGET_X86
258__DEFAULT_NO_OPTIONS+=CLANG_BOOTSTRAP CLANG_IS_CC LLD
259.else
260# Everything else disables Clang, and uses GCC instead.
261__DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
262__DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC LLD
263__DEFAULT_NO_OPTIONS+=LLVM_TARGET_AARCH64 LLVM_TARGET_ARM LLVM_TARGET_MIPS
264__DEFAULT_NO_OPTIONS+=LLVM_TARGET_POWERPC LLVM_TARGET_SPARC LLVM_TARGET_X86
265.endif
266__DEFAULT_NO_OPTIONS+=LLVM_TARGET_BPF
267# In-tree binutils/gcc are older versions without modern architecture support.
268.if ${__T} == "aarch64" || ${__T} == "riscv64"
269BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB
270.endif
271.if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386" || \
272    ${__T:Mriscv*} != "" || ${__TT} == "mips"
273__DEFAULT_YES_OPTIONS+=LLVM_LIBUNWIND
274.else
275__DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND
276.endif
277.if ${__T} == "riscv64"
278BROKEN_OPTIONS+=PROFILE # "sorry, unimplemented: profiler support for RISC-V"
279BROKEN_OPTIONS+=TESTS   # "undefined reference to `_Unwind_Resume'"
280BROKEN_OPTIONS+=CXX     # "libcxxrt.so: undefined reference to `_Unwind_Resume_or_Rethrow'"
281.endif
282.if ${__T} == "aarch64"
283__DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
284.else
285__DEFAULT_NO_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
286.endif
287.if ${__T} == "aarch64" || ${__T} == "amd64"
288__DEFAULT_YES_OPTIONS+=LLDB
289.else
290__DEFAULT_NO_OPTIONS+=LLDB
291.endif
292# LLVM lacks support for FreeBSD 64-bit atomic operations for ARMv4/ARMv5
293.if ${__T} == "arm" || ${__T} == "armeb"
294BROKEN_OPTIONS+=LLDB
295.endif
296# Only doing soft float API stuff on armv6
297.if ${__T} != "armv6"
298BROKEN_OPTIONS+=LIBSOFT
299.endif
300# EFI doesn't exist on mips, pc98, powerpc, sparc or riscv.
301.if ${__T:Mmips*} || ${__TT:Mpc98*} || ${__T:Mpowerpc*} || ${__T:Msparc64} || \
302    ${__T:Mriscv*}
303BROKEN_OPTIONS+=EFI
304.endif
305# OFW is only for powerpc and sparc64, exclude others
306.if ${__T:Mpowerpc*} == "" && ${__T:Msparc64} == ""
307BROKEN_OPTIONS+=LOADER_OFW
308.endif
309# UBOOT is only for arm, mips and powerpc, exclude others
310.if ${__T:Marm*} == "" && ${__T:Mmips*} == "" && ${__T:Mpowerpc*} == ""
311BROKEN_OPTIONS+=LOADER_UBOOT
312.endif
313# GELI and Lua in loader currently cause boot failures on sparc64 and powerpc.
314# Further debugging is required -- probably they are just broken on big
315# endian systems generically (they jump to null pointers or try to read
316# crazy high addresses, which is typical of endianness problems).
317.if ${__T} == "sparc64" || ${__T:Mpowerpc*}
318BROKEN_OPTIONS+=LOADER_GELI LOADER_LUA
319.endif
320# Both features are untested on pc98, so we'll mark them as disabled just to
321# be safe and make sure we keep pc98 stable.
322.if ${__TT:Mpc98*}
323BROKEN_OPTIONS+=LOADER_GELI LOADER_LUA
324.endif
325.if ${__T:Mmips64*}
326# profiling won't work on MIPS64 because there is only assembly for o32
327BROKEN_OPTIONS+=PROFILE
328.endif
329.if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386" || \
330    ${__T} == "powerpc64" || ${__T} == "sparc64"
331__DEFAULT_YES_OPTIONS+=CXGBETOOL
332__DEFAULT_YES_OPTIONS+=MLX5TOOL
333.else
334__DEFAULT_NO_OPTIONS+=CXGBETOOL
335__DEFAULT_NO_OPTIONS+=MLX5TOOL
336.endif
337
338.if ${__T} == "amd64"
339__DEFAULT_YES_OPTIONS+=OFED
340.else
341__DEFAULT_NO_OPTIONS+=OFED
342.endif
343
344.if ${COMPILER_FEATURES:Mc++11} && \
345    (${__T} == "amd64" || ${__T} == "i386" || ${__T} == "powerpc64")
346__DEFAULT_YES_OPTIONS+=OPENMP
347.else
348__DEFAULT_NO_OPTIONS+=OPENMP
349.endif
350
351.include <bsd.mkopt.mk>
352
353#
354# MK_* options that default to "yes" if the compiler is a C++11 compiler.
355#
356.for var in \
357    LIBCPLUSPLUS
358.if !defined(MK_${var})
359.if ${COMPILER_FEATURES:Mc++11}
360.if defined(WITHOUT_${var})
361MK_${var}:=	no
362.else
363MK_${var}:=	yes
364.endif
365.else
366.if defined(WITH_${var})
367MK_${var}:=	yes
368.else
369MK_${var}:=	no
370.endif
371.endif
372.endif
373.endfor
374
375#
376# Force some options off if their dependencies are off.
377# Order is somewhat important.
378#
379.if !${COMPILER_FEATURES:Mc++11}
380MK_LLVM_LIBUNWIND:=	no
381.endif
382
383.if ${MK_CAPSICUM} == "no"
384MK_CASPER:=	no
385.endif
386
387.if ${MK_LIBPTHREAD} == "no"
388MK_LIBTHR:=	no
389.endif
390
391.if ${MK_LDNS} == "no"
392MK_LDNS_UTILS:=	no
393MK_UNBOUND:= no
394.endif
395
396.if ${MK_SOURCELESS} == "no"
397MK_SOURCELESS_HOST:=	no
398MK_SOURCELESS_UCODE:= no
399.endif
400
401.if ${MK_CDDL} == "no"
402MK_ZFS:=	no
403MK_LOADER_ZFS:=	no
404MK_CTF:=	no
405.endif
406
407.if ${MK_CRYPT} == "no"
408MK_OPENSSL:=	no
409MK_OPENSSH:=	no
410MK_KERBEROS:=	no
411.endif
412
413.if ${MK_CXX} == "no"
414MK_CLANG:=	no
415MK_GROFF:=	no
416MK_GNUCXX:=	no
417.endif
418
419.if ${MK_DIALOG} == "no"
420MK_BSDINSTALL:=	no
421.endif
422
423.if ${MK_MAIL} == "no"
424MK_MAILWRAPPER:= no
425MK_SENDMAIL:=	no
426MK_DMAGENT:=	no
427.endif
428
429.if ${MK_NETGRAPH} == "no"
430MK_ATM:=	no
431MK_BLUETOOTH:=	no
432.endif
433
434.if ${MK_NLS} == "no"
435MK_NLS_CATALOGS:= no
436.endif
437
438.if ${MK_OPENSSL} == "no"
439MK_OPENSSH:=	no
440MK_KERBEROS:=	no
441.endif
442
443.if ${MK_OFED} == "no"
444MK_OFED_EXTRA:=	no
445.endif
446
447.if ${MK_PF} == "no"
448MK_AUTHPF:=	no
449.endif
450
451.if ${MK_TESTS} == "no"
452MK_DTRACE_TESTS:= no
453.endif
454
455.if ${MK_TEXTPROC} == "no"
456MK_GROFF:=	no
457.endif
458
459.if ${MK_ZONEINFO} == "no"
460MK_ZONEINFO_LEAPSECONDS_SUPPORT:= no
461.endif
462
463.if ${MK_CROSS_COMPILER} == "no"
464MK_BINUTILS_BOOTSTRAP:= no
465MK_CLANG_BOOTSTRAP:= no
466MK_ELFTOOLCHAIN_BOOTSTRAP:= no
467MK_GCC_BOOTSTRAP:= no
468MK_LLD_BOOTSTRAP:= no
469.endif
470
471.if ${MK_META_MODE} == "yes"
472MK_SYSTEM_COMPILER:= no
473.endif
474
475.if ${MK_TOOLCHAIN} == "no"
476MK_BINUTILS:=	no
477MK_CLANG:=	no
478MK_GCC:=	no
479MK_GDB:=	no
480MK_INCLUDES:=	no
481MK_LLD:=	no
482MK_LLDB:=	no
483.endif
484
485.if ${MK_CLANG} == "no"
486MK_CLANG_EXTRAS:= no
487MK_CLANG_FORMAT:= no
488MK_CLANG_FULL:= no
489MK_LLVM_COV:= no
490.endif
491
492#
493# MK_* options whose default value depends on another option.
494#
495.for vv in \
496    GSSAPI/KERBEROS \
497    MAN_UTILS/MAN
498.if defined(WITH_${vv:H})
499MK_${vv:H}:=	yes
500.elif defined(WITHOUT_${vv:H})
501MK_${vv:H}:=	no
502.else
503MK_${vv:H}:=	${MK_${vv:T}}
504.endif
505.endfor
506
507#
508# Set defaults for the MK_*_SUPPORT variables.
509#
510
511#
512# MK_*_SUPPORT options which default to "yes" unless their corresponding
513# MK_* variable is set to "no".
514#
515.for var in \
516    BLACKLIST \
517    BZIP2 \
518    GNU \
519    INET \
520    INET6 \
521    KERBEROS \
522    KVM \
523    NETGRAPH \
524    PAM \
525    TESTS \
526    WIRELESS
527.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
528MK_${var}_SUPPORT:= no
529.else
530MK_${var}_SUPPORT:= yes
531.endif
532.endfor
533
534.if !${COMPILER_FEATURES:Mc++11}
535MK_LLDB:=	no
536.endif
537
538# gcc 4.8 and newer supports libc++, so suppress gnuc++ in that case.
539# while in theory we could build it with that, we don't want to do
540# that since it creates too much confusion for too little gain.
541# XXX: This is incomplete and needs X_COMPILER_TYPE/VERSION checks too
542#      to prevent Makefile.inc1 from bootstrapping unneeded dependencies
543#      and to support 'make delete-old' when supplying an external toolchain.
544.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800
545MK_GNUCXX:=no
546MK_GCC:=no
547.endif
548
549.endif #  !target(__<src.opts.mk>__)
550