xref: /freebsd/share/mk/src.opts.mk (revision a8197ad3aa952a03fc2aeebc2eafe9bb9de54550)
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    GDB \
106    GDB_LIBEXEC \
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    GCOV \
205    GNUCXX \
206    GNU_GREP_COMPAT \
207    GPL_DTC \
208    HESIOD \
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		x86
276__LLVM_TARGET_FILT=	C/(amd64|i386)/x86/:S/arm64/aarch64/:S/powerpc64/powerpc/
277.for __llt in ${__LLVM_TARGETS}
278# Default enable the given TARGET's LLVM_TARGET support
279.if ${__TT:${__LLVM_TARGET_FILT}} == ${__llt}
280__DEFAULT_YES_OPTIONS+=	LLVM_TARGET_${__llt:${__LLVM_TARGET_FILT}:tu}
281# aarch64 needs arm for -m32 support.
282.elif ${__TT} == "arm64" && ${__llt} == "arm"
283__DEFAULT_DEPENDENT_OPTIONS+=	LLVM_TARGET_ARM/LLVM_TARGET_AARCH64
284# Default the rest of the LLVM_TARGETs to the value of MK_LLVM_TARGET_ALL.
285.else
286__DEFAULT_DEPENDENT_OPTIONS+=	LLVM_TARGET_${__llt:${__LLVM_TARGET_FILT}:tu}/LLVM_TARGET_ALL
287.endif
288.endfor
289# until we can unwind clang + sparc
290MK_LLVM_TARGET_SPARC:=no
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")
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}
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__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# LIB32 is supported on amd64, mips64, and powerpc64
335.if (${__T} == "amd64" || ${__T:Mmips64*} || ${__T} == "powerpc64")
336__DEFAULT_YES_OPTIONS+=LIB32
337.else
338BROKEN_OPTIONS+=LIB32
339.endif
340# Only doing soft float API stuff on armv6 and armv7
341.if ${__T} != "armv6" && ${__T} != "armv7"
342BROKEN_OPTIONS+=LIBSOFT
343.endif
344.if ${__T:Mmips*}
345# GOOGLETEST cannot currently be compiled on mips due to external circumstances.
346# Notably, the freebsd-gcc port isn't linking in libgcc so we end up trying ot
347# link to a hidden symbol. LLVM would successfully link this in, but some of
348# the mips variants are broken under LLVM until LLVM 10. GOOGLETEST should be
349# marked no longer broken with the switch to LLVM.
350BROKEN_OPTIONS+=GOOGLETEST SSP
351.endif
352# EFI doesn't exist on mips, powerpc, or riscv.
353.if ${__T:Mmips*} || ${__T:Mpowerpc*} || ${__T:Mriscv*}
354BROKEN_OPTIONS+=EFI
355.endif
356# OFW is only for powerpc, exclude others
357.if ${__T:Mpowerpc*} == ""
358BROKEN_OPTIONS+=LOADER_OFW
359.endif
360# UBOOT is only for arm, mips and powerpc, exclude others
361.if ${__T:Marm*} == "" && ${__T:Mmips*} == "" && ${__T:Mpowerpc*} == ""
362BROKEN_OPTIONS+=LOADER_UBOOT
363.endif
364# GELI and Lua in loader currently cause boot failures on powerpc.
365# Further debugging is required -- probably they are just broken on big
366# endian systems generically (they jump to null pointers or try to read
367# crazy high addresses, which is typical of endianness problems).
368.if ${__T:Mpowerpc*}
369BROKEN_OPTIONS+=LOADER_GELI LOADER_LUA
370.endif
371
372.if ${__T:Mmips64*}
373# profiling won't work on MIPS64 because there is only assembly for o32
374BROKEN_OPTIONS+=PROFILE
375.endif
376.if ${__T} != "aarch64" && ${__T} != "amd64" && ${__T} != "i386" && \
377    ${__T} != "powerpc64"
378BROKEN_OPTIONS+=CXGBETOOL
379BROKEN_OPTIONS+=MLX5TOOL
380.endif
381
382# HyperV is currently x86-only
383.if ${__T} != "amd64" && ${__T} != "i386"
384BROKEN_OPTIONS+=HYPERV
385.endif
386
387# NVME is only aarch64, x86 and powerpc64
388.if ${__T} != "aarch64" && ${__T} != "amd64" && ${__T} != "i386" && \
389    ${__T} != "powerpc64"
390BROKEN_OPTIONS+=NVME
391.endif
392
393.if ${COMPILER_FEATURES:Mc++11} && \
394    (${__T} == "amd64" || ${__T} == "i386" || ${__T} == "powerpc64")
395__DEFAULT_YES_OPTIONS+=OPENMP
396.else
397__DEFAULT_NO_OPTIONS+=OPENMP
398.endif
399
400.include <bsd.mkopt.mk>
401
402#
403# MK_* options that default to "yes" if the compiler is a C++11 compiler.
404#
405.for var in \
406    LIBCPLUSPLUS
407.if !defined(MK_${var})
408.if ${COMPILER_FEATURES:Mc++11}
409.if defined(WITHOUT_${var})
410MK_${var}:=	no
411.else
412MK_${var}:=	yes
413.endif
414.else
415.if defined(WITH_${var})
416MK_${var}:=	yes
417.else
418MK_${var}:=	no
419.endif
420.endif
421.endif
422.endfor
423
424#
425# Force some options off if their dependencies are off.
426# Order is somewhat important.
427#
428.if !${COMPILER_FEATURES:Mc++11}
429MK_GOOGLETEST:=	no
430MK_LLVM_LIBUNWIND:=	no
431.endif
432
433.if ${MK_CAPSICUM} == "no"
434MK_CASPER:=	no
435.endif
436
437.if ${MK_LIBPTHREAD} == "no"
438MK_LIBTHR:=	no
439.endif
440
441.if ${MK_SOURCELESS} == "no"
442MK_SOURCELESS_HOST:=	no
443MK_SOURCELESS_UCODE:= no
444.endif
445
446.if ${MK_CDDL} == "no"
447MK_ZFS:=	no
448MK_LOADER_ZFS:=	no
449MK_CTF:=	no
450.endif
451
452.if ${MK_CRYPT} == "no"
453MK_OPENSSL:=	no
454MK_OPENSSH:=	no
455MK_KERBEROS:=	no
456MK_KERBEROS_SUPPORT:=	no
457.endif
458
459.if ${MK_CXX} == "no"
460MK_CLANG:=	no
461MK_GNUCXX:=	no
462MK_GOOGLETEST:=	no
463MK_TESTS:=	no
464.endif
465
466.if ${MK_DIALOG} == "no"
467MK_BSDINSTALL:=	no
468.endif
469
470.if ${MK_FILE} == "no"
471MK_SVNLITE:=	no
472.endif
473
474.if ${__TT} == "mips" && ${MK_GCC} == "no"
475MK_BINUTILS_BOOTSTRAP:=	no
476.endif
477
478.if ${MK_MAIL} == "no"
479MK_MAILWRAPPER:= no
480MK_SENDMAIL:=	no
481MK_DMAGENT:=	no
482.endif
483
484.if ${MK_NETGRAPH} == "no"
485MK_ATM:=	no
486MK_BLUETOOTH:=	no
487.endif
488
489.if ${MK_NLS} == "no"
490MK_NLS_CATALOGS:= no
491.endif
492
493.if ${MK_OPENSSL} == "no"
494MK_DMAGENT:=	no
495MK_OPENSSH:=	no
496MK_KERBEROS:=	no
497MK_KERBEROS_SUPPORT:=	no
498MK_LDNS:=	no
499.endif
500
501.if ${MK_LDNS} == "no"
502MK_LDNS_UTILS:=	no
503MK_UNBOUND:= no
504.endif
505
506.if ${MK_PF} == "no"
507MK_AUTHPF:=	no
508.endif
509
510.if ${MK_OFED} == "no"
511MK_OFED_EXTRA:=	no
512.endif
513
514.if ${MK_PORTSNAP} == "no"
515# freebsd-update depends on phttpget from portsnap
516MK_FREEBSD_UPDATE:=	no
517.endif
518
519.if ${MK_TESTS} == "no"
520MK_DTRACE_TESTS:= no
521.endif
522
523.if ${MK_TESTS_SUPPORT} == "no"
524MK_GOOGLETEST:=	no
525.endif
526
527.if ${MK_ZONEINFO} == "no"
528MK_ZONEINFO_LEAPSECONDS_SUPPORT:= no
529MK_ZONEINFO_OLD_TIMEZONES_SUPPORT:= no
530.endif
531
532.if ${MK_CROSS_COMPILER} == "no"
533MK_BINUTILS_BOOTSTRAP:= no
534MK_CLANG_BOOTSTRAP:= no
535MK_ELFTOOLCHAIN_BOOTSTRAP:= no
536MK_GCC_BOOTSTRAP:= no
537MK_LLD_BOOTSTRAP:= no
538.endif
539
540.if ${MK_TOOLCHAIN} == "no"
541MK_BINUTILS:=	no
542MK_CLANG:=	no
543MK_GCC:=	no
544MK_GDB:=	no
545MK_INCLUDES:=	no
546MK_LLD:=	no
547MK_LLDB:=	no
548.endif
549
550.if ${MK_CLANG} == "no"
551MK_CLANG_EXTRAS:= no
552MK_CLANG_FULL:= no
553MK_LLVM_COV:= no
554.endif
555
556.if ${MK_LOADER_VERIEXEC} == "no"
557MK_LOADER_VERIEXEC_PASS_MANIFEST := no
558.endif
559
560#
561# MK_* options whose default value depends on another option.
562#
563.for vv in \
564    GSSAPI/KERBEROS \
565    MAN_UTILS/MAN
566.if defined(WITH_${vv:H})
567MK_${vv:H}:=	yes
568.elif defined(WITHOUT_${vv:H})
569MK_${vv:H}:=	no
570.else
571MK_${vv:H}:=	${MK_${vv:T}}
572.endif
573.endfor
574
575#
576# Set defaults for the MK_*_SUPPORT variables.
577#
578
579.if !${COMPILER_FEATURES:Mc++11}
580MK_LLDB:=	no
581.endif
582
583# gcc 4.8 and newer supports libc++, so suppress gnuc++ in that case.
584# while in theory we could build it with that, we don't want to do
585# that since it creates too much confusion for too little gain.
586# XXX: This is incomplete and needs X_COMPILER_TYPE/VERSION checks too
587#      to prevent Makefile.inc1 from bootstrapping unneeded dependencies
588#      and to support 'make delete-old' when supplying an external toolchain.
589.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800
590MK_GNUCXX:=no
591MK_GCC:=no
592.endif
593
594.endif #  !target(__<src.opts.mk>__)
595