xref: /freebsd/share/mk/src.opts.mk (revision eb24e1491f9900e922c78e53af588f22a3e9535f)
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 the src builds. Those listed in
45# __DEFAULT_YES_OPTIONS default to 'yes' and will build unless turned
46# off.  __DEFAULT_NO_OPTIONS will default to 'no' and won't build
47# unless turned on. Any options listed in 'BROKEN_OPTIONS' will be
48# hard-wired to 'no'.  "Broken" here means not working or
49# not-appropriate and/or not supported. It doesn't imply something is
50# wrong with the code. There's not a single good word for this, so
51# BROKEN was selected as the least imperfect one considered at the
52# time. Options are added to BROKEN_OPTIONS list on a per-arch basis.
53# At this time, there's no provision for mutually incompatible options.
54
55__DEFAULT_YES_OPTIONS = \
56    ACCT \
57    ACPI \
58    APM \
59    AT \
60    ATM \
61    AUDIT \
62    AUTHPF \
63    AUTOFS \
64    BHYVE \
65    BINUTILS \
66    BLACKLIST \
67    BLUETOOTH \
68    BOOT \
69    BOOTPARAMD \
70    BOOTPD \
71    BSD_CPIO \
72    BSDINSTALL \
73    BSNMP \
74    BZIP2 \
75    CALENDAR \
76    CAPSICUM \
77    CAROOT \
78    CASPER \
79    CCD \
80    CDDL \
81    CPP \
82    CROSS_COMPILER \
83    CRYPT \
84    CUSE \
85    CXX \
86    CXGBETOOL \
87    DIALOG \
88    DICT \
89    DMAGENT \
90    DYNAMICROOT \
91    EE \
92    EFI \
93    ELFTOOLCHAIN_BOOTSTRAP \
94    EXAMPLES \
95    FDT \
96    FILE \
97    FINGER \
98    FLOPPY \
99    FMTREE \
100    FORTH \
101    FP_LIBC \
102    FREEBSD_UPDATE \
103    FTP \
104    GAMES \
105    GCOV \
106    GDB \
107    GNU_DIFF \
108    GNU_GREP \
109    GOOGLETEST \
110    GPIO \
111    HAST \
112    HTML \
113    HYPERV \
114    ICONV \
115    INET \
116    INET6 \
117    INETD \
118    IPFILTER \
119    IPFW \
120    ISCSI \
121    JAIL \
122    KDUMP \
123    KVM \
124    LDNS \
125    LDNS_UTILS \
126    LEGACY_CONSOLE \
127    LIBPTHREAD \
128    LIBTHR \
129    LLVM_COV \
130    LLVM_LIBUNWIND \
131    LLVM_TARGET_ALL \
132    LOADER_GELI \
133    LOADER_LUA \
134    LOADER_OFW \
135    LOADER_UBOOT \
136    LOCALES \
137    LOCATE \
138    LPR \
139    LS_COLORS \
140    LZMA_SUPPORT \
141    MAIL \
142    MAILWRAPPER \
143    MAKE \
144    MLX5TOOL \
145    NDIS \
146    NETCAT \
147    NETGRAPH \
148    NLS_CATALOGS \
149    NS_CACHING \
150    NTP \
151    NVME \
152    OFED \
153    OPENSSL \
154    PAM \
155    PF \
156    PKGBOOTSTRAP \
157    PMC \
158    PORTSNAP \
159    PPP \
160    QUOTAS \
161    RADIUS_SUPPORT \
162    RBOOTD \
163    RESCUE \
164    ROUTED \
165    SENDMAIL \
166    SERVICESDB \
167    SETUID_LOGIN \
168    SHARED_TOOLCHAIN \
169    SHAREDOCS \
170    SOURCELESS \
171    SOURCELESS_HOST \
172    SOURCELESS_UCODE \
173    STATS \
174    SVNLITE \
175    SYSCONS \
176    SYSTEM_COMPILER \
177    SYSTEM_LINKER \
178    TALK \
179    TCP_WRAPPERS \
180    TCSH \
181    TELNET \
182    TEXTPROC \
183    TFTP \
184    UNBOUND \
185    USB \
186    UTMPX \
187    VI \
188    VT \
189    WIRELESS \
190    WPA_SUPPLICANT_EAPOL \
191    ZFS \
192    LOADER_ZFS \
193    ZONEINFO
194
195__DEFAULT_NO_OPTIONS = \
196    AMD \
197    BEARSSL \
198    BSD_GREP \
199    CLANG_EXTRAS \
200    DTRACE_TESTS \
201    EXPERIMENTAL \
202    GCC \
203    GCC_BOOTSTRAP \
204    GNUCXX \
205    GNU_GREP_COMPAT \
206    GPL_DTC \
207    HESIOD \
208    HTTPD \
209    LIBSOFT \
210    LOADER_FIREWIRE \
211    LOADER_FORCE_LE \
212    LOADER_VERBOSE \
213    LOADER_VERIEXEC_PASS_MANIFEST \
214    OFED_EXTRA \
215    OPENLDAP \
216    REPRODUCIBLE_BUILD \
217    RPCBIND_WARMSTART_SUPPORT \
218    SORT_THREADS \
219    SVN \
220    ZONEINFO_LEAPSECONDS_SUPPORT \
221    ZONEINFO_OLD_TIMEZONES_SUPPORT \
222
223# LEFT/RIGHT. Left options which default to "yes" unless their corresponding
224# RIGHT option is disabled.
225__DEFAULT_DEPENDENT_OPTIONS= \
226	CLANG_FULL/CLANG \
227	LOADER_VERIEXEC/BEARSSL \
228	LOADER_EFI_SECUREBOOT/LOADER_VERIEXEC \
229	VERIEXEC/BEARSSL \
230
231# MK_*_SUPPORT options which default to "yes" unless their corresponding
232# MK_* variable is set to "no".
233#
234.for var in \
235    BLACKLIST \
236    BZIP2 \
237    INET \
238    INET6 \
239    KERBEROS \
240    KVM \
241    NETGRAPH \
242    PAM \
243    TESTS \
244    WIRELESS
245__DEFAULT_DEPENDENT_OPTIONS+= ${var}_SUPPORT/${var}
246.endfor
247
248#
249# Default behaviour of some options depends on the architecture.  Unfortunately
250# this means that we have to test TARGET_ARCH (the buildworld case) as well
251# as MACHINE_ARCH (the non-buildworld case).  Normally TARGET_ARCH is not
252# used at all in bsd.*.mk, but we have to make an exception here if we want
253# to allow defaults for some things like clang to vary by target architecture.
254# Additional, per-target behavior should be rarely added only after much
255# gnashing of teeth and grinding of gears.
256#
257.if defined(TARGET_ARCH)
258__T=${TARGET_ARCH}
259.else
260__T=${MACHINE_ARCH}
261.endif
262.if defined(TARGET)
263__TT=${TARGET}
264.else
265__TT=${MACHINE}
266.endif
267
268# All supported backends for LLVM_TARGET_XXX
269__LLVM_TARGETS= \
270		aarch64 \
271		arm \
272		mips \
273		powerpc \
274		riscv \
275		sparc \
276		x86
277__LLVM_TARGET_FILT=	C/(amd64|i386)/x86/:S/sparc64/sparc/:S/arm64/aarch64/:S/powerpc64/powerpc/
278.for __llt in ${__LLVM_TARGETS}
279# Default enable the given TARGET's LLVM_TARGET support
280.if ${__TT:${__LLVM_TARGET_FILT}} == ${__llt}
281__DEFAULT_YES_OPTIONS+=	LLVM_TARGET_${__llt:${__LLVM_TARGET_FILT}:tu}
282# aarch64 needs arm for -m32 support.
283.elif ${__TT} == "arm64" && ${__llt} == "arm"
284__DEFAULT_DEPENDENT_OPTIONS+=	LLVM_TARGET_ARM/LLVM_TARGET_AARCH64
285# Default the rest of the LLVM_TARGETs to the value of MK_LLVM_TARGET_ALL.
286.else
287__DEFAULT_DEPENDENT_OPTIONS+=	LLVM_TARGET_${__llt:${__LLVM_TARGET_FILT}:tu}/LLVM_TARGET_ALL
288.endif
289.endfor
290
291__DEFAULT_NO_OPTIONS+=LLVM_TARGET_BPF
292
293.include <bsd.compiler.mk>
294# If the compiler is not C++11 capable, disable Clang.  External toolchain will
295# be required.
296
297.if ${COMPILER_FEATURES:Mc++11} && (${__TT} != "mips" && ${__TT} != "sparc64")
298# Clang is enabled, and will be installed as the default /usr/bin/cc.
299__DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_IS_CC LLD
300.elif ${COMPILER_FEATURES:Mc++11} && ${__T} != "sparc64"
301# If an external compiler that supports C++11 is used as ${CC} and Clang
302# supports the target, then Clang is enabled but we still require an external
303# toolchain.
304# default /usr/bin/cc.
305__DEFAULT_YES_OPTIONS+=CLANG LLD
306__DEFAULT_NO_OPTIONS+=CLANG_BOOTSTRAP CLANG_IS_CC
307.else
308# Everything else disables Clang, and uses GCC instead.
309__DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_IS_CC LLD
310.endif
311# In-tree binutils/gcc are older versions without modern architecture support.
312.if ${__T} == "aarch64" || ${__T:Mriscv*} != ""
313BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB
314.endif
315.if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*}
316__DEFAULT_YES_OPTIONS+=BINUTILS_BOOTSTRAP
317.else
318__DEFAULT_NO_OPTIONS+=BINUTILS_BOOTSTRAP
319.endif
320.if ${__T:Mriscv*} != ""
321BROKEN_OPTIONS+=OFED
322.endif
323.if ${__TT} != "mips" && ${__T} != "powerpc" && ${__T} != "powerpcspe" && \
324    ${__T} != "sparc64"
325__DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
326.else
327__DEFAULT_NO_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
328.endif
329.if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386"
330__DEFAULT_YES_OPTIONS+=LLDB
331.else
332__DEFAULT_NO_OPTIONS+=LLDB
333.endif
334# GDB in base is generally less functional than GDB in ports.  Ports GDB
335# sparc64 kernel support has not been tested.
336.if ${__T} == "sparc64"
337__DEFAULT_NO_OPTIONS+=GDB_LIBEXEC
338.else
339__DEFAULT_YES_OPTIONS+=GDB_LIBEXEC
340.endif
341# LIB32 is supported on amd64, mips64, and powerpc64
342.if (${__T} == "amd64" || ${__T:Mmips64*} || ${__T} == "powerpc64")
343__DEFAULT_YES_OPTIONS+=LIB32
344.else
345BROKEN_OPTIONS+=LIB32
346.endif
347# Only doing soft float API stuff on armv6 and armv7
348.if ${__T} != "armv6" && ${__T} != "armv7"
349BROKEN_OPTIONS+=LIBSOFT
350.endif
351.if ${__T:Mmips*}
352BROKEN_OPTIONS+=SSP
353.endif
354# EFI doesn't exist on mips, powerpc, sparc or riscv.
355.if ${__T:Mmips*} || ${__T:Mpowerpc*} || ${__T:Msparc64} || ${__T:Mriscv*}
356BROKEN_OPTIONS+=EFI
357.endif
358# OFW is only for powerpc and sparc64, exclude others
359.if ${__T:Mpowerpc*} == "" && ${__T:Msparc64} == ""
360BROKEN_OPTIONS+=LOADER_OFW
361.endif
362# UBOOT is only for arm, mips and powerpc, exclude others
363.if ${__T:Marm*} == "" && ${__T:Mmips*} == "" && ${__T:Mpowerpc*} == ""
364BROKEN_OPTIONS+=LOADER_UBOOT
365.endif
366# GELI and Lua in loader currently cause boot failures on sparc64 and powerpc.
367# Further debugging is required -- probably they are just broken on big
368# endian systems generically (they jump to null pointers or try to read
369# crazy high addresses, which is typical of endianness problems).
370.if ${__T} == "sparc64" || ${__T:Mpowerpc*}
371BROKEN_OPTIONS+=LOADER_GELI LOADER_LUA
372.endif
373
374.if ${__T:Mmips64*}
375# profiling won't work on MIPS64 because there is only assembly for o32
376BROKEN_OPTIONS+=PROFILE
377.endif
378.if ${__T} != "aarch64" && ${__T} != "amd64" && ${__T} != "i386" && \
379    ${__T} != "powerpc64" && ${__T} != "sparc64"
380BROKEN_OPTIONS+=CXGBETOOL
381BROKEN_OPTIONS+=MLX5TOOL
382.endif
383
384# HyperV is currently x86-only
385.if ${__T} != "amd64" && ${__T} != "i386"
386BROKEN_OPTIONS+=HYPERV
387.endif
388
389# NVME is only aarch64, x86 and powerpc64
390.if ${__T} != "aarch64" && ${__T} != "amd64" && ${__T} != "i386" && \
391    ${__T} != "powerpc64"
392BROKEN_OPTIONS+=NVME
393.endif
394
395.if ${__T:Msparc64}
396# PR 233405
397BROKEN_OPTIONS+=LLVM_LIBUNWIND
398.endif
399
400.if ${COMPILER_FEATURES:Mc++11} && \
401    (${__T} == "amd64" || ${__T} == "i386" || ${__T} == "powerpc64")
402__DEFAULT_YES_OPTIONS+=OPENMP
403.else
404__DEFAULT_NO_OPTIONS+=OPENMP
405.endif
406
407.include <bsd.mkopt.mk>
408
409#
410# MK_* options that default to "yes" if the compiler is a C++11 compiler.
411#
412.for var in \
413    LIBCPLUSPLUS
414.if !defined(MK_${var})
415.if ${COMPILER_FEATURES:Mc++11}
416.if defined(WITHOUT_${var})
417MK_${var}:=	no
418.else
419MK_${var}:=	yes
420.endif
421.else
422.if defined(WITH_${var})
423MK_${var}:=	yes
424.else
425MK_${var}:=	no
426.endif
427.endif
428.endif
429.endfor
430
431#
432# Force some options off if their dependencies are off.
433# Order is somewhat important.
434#
435.if !${COMPILER_FEATURES:Mc++11}
436MK_GOOGLETEST:=	no
437MK_LLVM_LIBUNWIND:=	no
438.endif
439
440.if ${MK_CAPSICUM} == "no"
441MK_CASPER:=	no
442.endif
443
444.if ${MK_LIBPTHREAD} == "no"
445MK_LIBTHR:=	no
446.endif
447
448.if ${MK_SOURCELESS} == "no"
449MK_SOURCELESS_HOST:=	no
450MK_SOURCELESS_UCODE:= no
451.endif
452
453.if ${MK_CDDL} == "no"
454MK_ZFS:=	no
455MK_LOADER_ZFS:=	no
456MK_CTF:=	no
457.endif
458
459.if ${MK_CRYPT} == "no"
460MK_OPENSSL:=	no
461MK_OPENSSH:=	no
462MK_KERBEROS:=	no
463MK_KERBEROS_SUPPORT:=	no
464.endif
465
466.if ${MK_CXX} == "no"
467MK_CLANG:=	no
468MK_GNUCXX:=	no
469MK_GOOGLETEST:=	no
470MK_TESTS:=	no
471.endif
472
473.if ${MK_DIALOG} == "no"
474MK_BSDINSTALL:=	no
475.endif
476
477.if ${MK_FILE} == "no"
478MK_SVNLITE:=	no
479.endif
480
481.if (${__TT} == "mips" || ${__TT} == "sparc64") && ${MK_GCC} == "no"
482MK_BINUTILS_BOOTSTRAP:=	no
483.endif
484
485.if ${MK_MAIL} == "no"
486MK_MAILWRAPPER:= no
487MK_SENDMAIL:=	no
488MK_DMAGENT:=	no
489.endif
490
491.if ${MK_NETGRAPH} == "no"
492MK_ATM:=	no
493MK_BLUETOOTH:=	no
494.endif
495
496.if ${MK_NLS} == "no"
497MK_NLS_CATALOGS:= no
498.endif
499
500.if ${MK_OPENSSL} == "no"
501MK_DMAGENT:=	no
502MK_OPENSSH:=	no
503MK_KERBEROS:=	no
504MK_KERBEROS_SUPPORT:=	no
505MK_LDNS:=	no
506.endif
507
508.if ${MK_LDNS} == "no"
509MK_LDNS_UTILS:=	no
510MK_UNBOUND:= no
511.endif
512
513.if ${MK_PF} == "no"
514MK_AUTHPF:=	no
515.endif
516
517.if ${MK_OFED} == "no"
518MK_OFED_EXTRA:=	no
519.endif
520
521.if ${MK_PORTSNAP} == "no"
522# freebsd-update depends on phttpget from portsnap
523MK_FREEBSD_UPDATE:=	no
524.endif
525
526.if ${MK_TESTS} == "no"
527MK_DTRACE_TESTS:= no
528.endif
529
530.if ${MK_TESTS_SUPPORT} == "no"
531MK_GOOGLETEST:=	no
532.endif
533
534.if ${MK_ZONEINFO} == "no"
535MK_ZONEINFO_LEAPSECONDS_SUPPORT:= no
536MK_ZONEINFO_OLD_TIMEZONES_SUPPORT:= no
537.endif
538
539.if ${MK_CROSS_COMPILER} == "no"
540MK_BINUTILS_BOOTSTRAP:= no
541MK_CLANG_BOOTSTRAP:= no
542MK_ELFTOOLCHAIN_BOOTSTRAP:= no
543MK_GCC_BOOTSTRAP:= no
544MK_LLD_BOOTSTRAP:= no
545.endif
546
547.if ${MK_TOOLCHAIN} == "no"
548MK_BINUTILS:=	no
549MK_CLANG:=	no
550MK_GCC:=	no
551MK_GDB:=	no
552MK_INCLUDES:=	no
553MK_LLD:=	no
554MK_LLDB:=	no
555.endif
556
557.if ${MK_CLANG} == "no"
558MK_CLANG_EXTRAS:= no
559MK_CLANG_FULL:= no
560MK_LLVM_COV:= no
561.endif
562
563.if ${MK_LOADER_VERIEXEC} == "no"
564MK_LOADER_VERIEXEC_PASS_MANIFEST := no
565.endif
566
567#
568# MK_* options whose default value depends on another option.
569#
570.for vv in \
571    GSSAPI/KERBEROS \
572    MAN_UTILS/MAN
573.if defined(WITH_${vv:H})
574MK_${vv:H}:=	yes
575.elif defined(WITHOUT_${vv:H})
576MK_${vv:H}:=	no
577.else
578MK_${vv:H}:=	${MK_${vv:T}}
579.endif
580.endfor
581
582#
583# Set defaults for the MK_*_SUPPORT variables.
584#
585
586.if !${COMPILER_FEATURES:Mc++11}
587MK_LLDB:=	no
588.endif
589
590# gcc 4.8 and newer supports libc++, so suppress gnuc++ in that case.
591# while in theory we could build it with that, we don't want to do
592# that since it creates too much confusion for too little gain.
593# XXX: This is incomplete and needs X_COMPILER_TYPE/VERSION checks too
594#      to prevent Makefile.inc1 from bootstrapping unneeded dependencies
595#      and to support 'make delete-old' when supplying an external toolchain.
596.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800
597MK_GNUCXX:=no
598MK_GCC:=no
599.endif
600
601.endif #  !target(__<src.opts.mk>__)
602