xref: /freebsd/share/mk/src.opts.mk (revision 5bf5ca772c6de2d53344a78cf461447cc322ccea)
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    AMD \
59    APM \
60    AT \
61    ATM \
62    AUDIT \
63    AUTHPF \
64    AUTOFS \
65    BHYVE \
66    BINUTILS \
67    BINUTILS_BOOTSTRAP \
68    BLACKLIST \
69    BLUETOOTH \
70    BOOT \
71    BOOTPARAMD \
72    BOOTPD \
73    BSD_CPIO \
74    BSDINSTALL \
75    BSNMP \
76    BZIP2 \
77    CALENDAR \
78    CAPSICUM \
79    CASPER \
80    CCD \
81    CDDL \
82    CPP \
83    CROSS_COMPILER \
84    CRYPT \
85    CTM \
86    CUSE \
87    CXX \
88    DIALOG \
89    DICT \
90    DMAGENT \
91    DYNAMICROOT \
92    ED_CRYPTO \
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    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    LIB32 \
129    LIBPTHREAD \
130    LIBTHR \
131    LLVM_COV \
132    LOCALES \
133    LOCATE \
134    LPR \
135    LS_COLORS \
136    LZMA_SUPPORT \
137    LOADER_GELI \
138    LOADER_OFW \
139    LOADER_UBOOT \
140    MAIL \
141    MAILWRAPPER \
142    MAKE \
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    RBOOTD \
160    RESCUE \
161    ROUTED \
162    SENDMAIL \
163    SETUID_LOGIN \
164    SHAREDOCS \
165    SOURCELESS \
166    SOURCELESS_HOST \
167    SOURCELESS_UCODE \
168    SVNLITE \
169    SYSCONS \
170    SYSTEM_COMPILER \
171    TALK \
172    TCP_WRAPPERS \
173    TCSH \
174    TELNET \
175    TEXTPROC \
176    TFTP \
177    TIMED \
178    UNBOUND \
179    USB \
180    UTMPX \
181    VI \
182    VT \
183    WIRELESS \
184    WPA_SUPPLICANT_EAPOL \
185    ZFS \
186    ZONEINFO
187
188__DEFAULT_NO_OPTIONS = \
189    BSD_GREP \
190    BSD_GREP_FASTMATCH \
191    CLANG_EXTRAS \
192    DTRACE_TESTS \
193    GNU_GREP_COMPAT \
194    HESIOD \
195    LIBSOFT \
196    LOADER_FIREWIRE \
197    LOADER_FORCE_LE \
198    LOADER_LUA \
199    NAND \
200    OFED \
201    OPENLDAP \
202    REPRODUCIBLE_BUILD \
203    RPCBIND_WARMSTART_SUPPORT \
204    SHARED_TOOLCHAIN \
205    SORT_THREADS \
206    SVN \
207    ZONEINFO_LEAPSECONDS_SUPPORT \
208    ZONEINFO_OLD_TIMEZONES_SUPPORT \
209
210
211#
212# Default behaviour of some options depends on the architecture.  Unfortunately
213# this means that we have to test TARGET_ARCH (the buildworld case) as well
214# as MACHINE_ARCH (the non-buildworld case).  Normally TARGET_ARCH is not
215# used at all in bsd.*.mk, but we have to make an exception here if we want
216# to allow defaults for some things like clang to vary by target architecture.
217# Additional, per-target behavior should be rarely added only after much
218# gnashing of teeth and grinding of gears.
219#
220.if defined(TARGET_ARCH)
221__T=${TARGET_ARCH}
222.else
223__T=${MACHINE_ARCH}
224.endif
225.if defined(TARGET)
226__TT=${TARGET}
227.else
228__TT=${MACHINE}
229.endif
230
231.include <bsd.compiler.mk>
232# If the compiler is not C++11 capable, disable Clang and use GCC instead.
233# This means that architectures that have GCC 4.2 as default can not
234# build Clang without using an external compiler.
235
236.if ${COMPILER_FEATURES:Mc++11} && (${__T} == "aarch64" || \
237    ${__T} == "amd64" || ${__TT} == "arm" || ${__T} == "i386")
238# Clang is enabled, and will be installed as the default /usr/bin/cc.
239__DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC LLD
240__DEFAULT_NO_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX GPL_DTC
241.elif ${COMPILER_FEATURES:Mc++11} && ${__T:Mriscv*} == "" && ${__T} != "sparc64"
242# If an external compiler that supports C++11 is used as ${CC} and Clang
243# supports the target, then Clang is enabled but GCC is installed as the
244# default /usr/bin/cc.
245__DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL GCC GCC_BOOTSTRAP GNUCXX GPL_DTC
246__DEFAULT_NO_OPTIONS+=CLANG_BOOTSTRAP CLANG_IS_CC LLD
247.else
248# Everything else disables Clang, and uses GCC instead.
249__DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX GPL_DTC
250__DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC LLD
251.endif
252# In-tree binutils/gcc are older versions without modern architecture support.
253.if ${__T} == "aarch64" || ${__T:Mriscv*} != ""
254BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB
255.endif
256.if ${__T:Mriscv*} != ""
257BROKEN_OPTIONS+=PROFILE # "sorry, unimplemented: profiler support for RISC-V"
258BROKEN_OPTIONS+=TESTS   # "undefined reference to `_Unwind_Resume'"
259BROKEN_OPTIONS+=CXX     # "libcxxrt.so: undefined reference to `_Unwind_Resume_or_Rethrow'"
260.endif
261.if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386" || \
262    ${__T:Mriscv*} != ""
263__DEFAULT_YES_OPTIONS+=LLVM_LIBUNWIND
264.else
265__DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND
266.endif
267.if ${__T} == "aarch64"
268__DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
269.elif ${__T} == "amd64"
270__DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP
271__DEFAULT_NO_OPTIONS+=LLD_IS_LD
272.else
273__DEFAULT_NO_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
274.endif
275.if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386"
276__DEFAULT_YES_OPTIONS+=LLDB
277.else
278__DEFAULT_NO_OPTIONS+=LLDB
279.endif
280# LLVM lacks support for FreeBSD 64-bit atomic operations for ARMv4/ARMv5
281.if ${__T} == "arm" || ${__T} == "armeb"
282BROKEN_OPTIONS+=LLDB
283.endif
284# GDB in base is generally less functional than GDB in ports.  Ports GDB
285# does not yet contain kernel support for arm, and sparc64 kernel support
286# has not been tested.
287.if ${__T:Marm*} != "" || ${__T} == "sparc64"
288__DEFAULT_NO_OPTIONS+=GDB_LIBEXEC
289.else
290__DEFAULT_YES_OPTIONS+=GDB_LIBEXEC
291.endif
292# Only doing soft float API stuff on armv6 and armv7
293.if ${__T} != "armv6" && ${__T} != "armv7"
294BROKEN_OPTIONS+=LIBSOFT
295.endif
296.if ${__T:Mmips*}
297BROKEN_OPTIONS+=SSP
298.endif
299# EFI doesn't exist on mips, powerpc, sparc or riscv.
300.if ${__T:Mmips*} || ${__T:Mpowerpc*} || ${__T:Msparc64} || ${__T:Mriscv*}
301BROKEN_OPTIONS+=EFI
302.endif
303# GELI isn't supported on !x86
304.if ${__T} != "i386" && ${__T} != "amd64"
305BROKEN_OPTIONS+=LOADER_GELI
306.endif
307# OFW is only for powerpc and sparc64, exclude others
308.if ${__T:Mpowerpc*} == "" && ${__T:Msparc64} == ""
309BROKEN_OPTIONS+=LOADER_OFW
310.endif
311# UBOOT is only for arm, mips and powerpc, exclude others
312.if ${__T:Marm*} == "" && ${__T:Mmips*} == "" && ${__T:Mpowerpc*} == ""
313BROKEN_OPTIONS+=LOADER_UBOOT
314.endif
315
316.if ${__T:Mmips64*}
317# profiling won't work on MIPS64 because there is only assembly for o32
318BROKEN_OPTIONS+=PROFILE
319.endif
320.if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386" || \
321    ${__T} == "powerpc64" || ${__T} == "sparc64"
322__DEFAULT_YES_OPTIONS+=CXGBETOOL
323.else
324__DEFAULT_NO_OPTIONS+=CXGBETOOL
325.endif
326
327.include <bsd.mkopt.mk>
328
329#
330# MK_* options that default to "yes" if the compiler is a C++11 compiler.
331#
332.for var in \
333    LIBCPLUSPLUS
334.if !defined(MK_${var})
335.if ${COMPILER_FEATURES:Mc++11}
336.if defined(WITHOUT_${var})
337MK_${var}:=	no
338.else
339MK_${var}:=	yes
340.endif
341.else
342.if defined(WITH_${var})
343MK_${var}:=	yes
344.else
345MK_${var}:=	no
346.endif
347.endif
348.endif
349.endfor
350
351#
352# Force some options off if their dependencies are off.
353# Order is somewhat important.
354#
355.if !${COMPILER_FEATURES:Mc++11}
356MK_LLVM_LIBUNWIND:=	no
357.endif
358
359.if ${MK_BINUTILS} == "no"
360MK_GDB:=	no
361.endif
362
363.if ${MK_CAPSICUM} == "no"
364MK_CASPER:=	no
365.endif
366
367.if ${MK_LIBPTHREAD} == "no"
368MK_LIBTHR:=	no
369.endif
370
371.if ${MK_LDNS} == "no"
372MK_LDNS_UTILS:=	no
373MK_UNBOUND:= no
374.endif
375
376.if ${MK_SOURCELESS} == "no"
377MK_SOURCELESS_HOST:=	no
378MK_SOURCELESS_UCODE:= no
379.endif
380
381.if ${MK_CDDL} == "no"
382MK_ZFS:=	no
383MK_CTF:=	no
384.endif
385
386.if ${MK_CRYPT} == "no"
387MK_OPENSSL:=	no
388MK_OPENSSH:=	no
389MK_KERBEROS:=	no
390.endif
391
392.if ${MK_CXX} == "no"
393MK_CLANG:=	no
394MK_GNUCXX:=	no
395MK_TESTS:=	no
396.endif
397
398.if ${MK_DIALOG} == "no"
399MK_BSDINSTALL:=	no
400.endif
401
402.if ${MK_MAIL} == "no"
403MK_MAILWRAPPER:= no
404MK_SENDMAIL:=	no
405MK_DMAGENT:=	no
406.endif
407
408.if ${MK_NETGRAPH} == "no"
409MK_ATM:=	no
410MK_BLUETOOTH:=	no
411.endif
412
413.if ${MK_NLS} == "no"
414MK_NLS_CATALOGS:= no
415.endif
416
417.if ${MK_OPENSSL} == "no"
418MK_OPENSSH:=	no
419MK_KERBEROS:=	no
420.endif
421
422.if ${MK_PF} == "no"
423MK_AUTHPF:=	no
424.endif
425
426.if ${MK_TESTS} == "no"
427MK_DTRACE_TESTS:= no
428.endif
429
430.if ${MK_ZONEINFO} == "no"
431MK_ZONEINFO_LEAPSECONDS_SUPPORT:= no
432MK_ZONEINFO_OLD_TIMEZONES_SUPPORT:= no
433.endif
434
435.if ${MK_CROSS_COMPILER} == "no"
436MK_BINUTILS_BOOTSTRAP:= no
437MK_CLANG_BOOTSTRAP:= no
438MK_ELFTOOLCHAIN_BOOTSTRAP:= no
439MK_GCC_BOOTSTRAP:= no
440.endif
441
442.if ${MK_TOOLCHAIN} == "no"
443MK_BINUTILS:=	no
444MK_CLANG:=	no
445MK_GCC:=	no
446MK_GDB:=	no
447MK_INCLUDES:=	no
448MK_LLD:=	no
449MK_LLDB:=	no
450.endif
451
452.if ${MK_CLANG} == "no"
453MK_CLANG_EXTRAS:= no
454MK_CLANG_FULL:= no
455MK_LLVM_COV:= no
456.endif
457
458#
459# MK_* options whose default value depends on another option.
460#
461.for vv in \
462    GSSAPI/KERBEROS \
463    MAN_UTILS/MAN
464.if defined(WITH_${vv:H})
465MK_${vv:H}:=	yes
466.elif defined(WITHOUT_${vv:H})
467MK_${vv:H}:=	no
468.else
469MK_${vv:H}:=	${MK_${vv:T}}
470.endif
471.endfor
472
473#
474# Set defaults for the MK_*_SUPPORT variables.
475#
476
477#
478# MK_*_SUPPORT options which default to "yes" unless their corresponding
479# MK_* variable is set to "no".
480#
481.for var in \
482    BLACKLIST \
483    BZIP2 \
484    INET \
485    INET6 \
486    KERBEROS \
487    KVM \
488    NETGRAPH \
489    PAM \
490    TESTS \
491    WIRELESS
492.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
493MK_${var}_SUPPORT:= no
494.else
495MK_${var}_SUPPORT:= yes
496.endif
497.endfor
498
499.if !${COMPILER_FEATURES:Mc++11}
500MK_LLDB:=	no
501.endif
502
503# gcc 4.8 and newer supports libc++, so suppress gnuc++ in that case.
504# while in theory we could build it with that, we don't want to do
505# that since it creates too much confusion for too little gain.
506# XXX: This is incomplete and needs X_COMPILER_TYPE/VERSION checks too
507#      to prevent Makefile.inc1 from bootstrapping unneeded dependencies
508#      and to support 'make delete-old' when supplying an external toolchain.
509.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800
510MK_GNUCXX:=no
511MK_GCC:=no
512.endif
513
514.endif #  !target(__<src.opts.mk>__)
515