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