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