xref: /freebsd/share/mk/src.opts.mk (revision 52f72944b8f5abb2386eae924357dee8aea17d5b)
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*} != "" || ${__TT} == "mips"
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__DEFAULT_YES_OPTIONS+=MLX5TOOL
324.else
325__DEFAULT_NO_OPTIONS+=CXGBETOOL
326__DEFAULT_NO_OPTIONS+=MLX5TOOL
327.endif
328
329.include <bsd.mkopt.mk>
330
331#
332# MK_* options that default to "yes" if the compiler is a C++11 compiler.
333#
334.for var in \
335    LIBCPLUSPLUS
336.if !defined(MK_${var})
337.if ${COMPILER_FEATURES:Mc++11}
338.if defined(WITHOUT_${var})
339MK_${var}:=	no
340.else
341MK_${var}:=	yes
342.endif
343.else
344.if defined(WITH_${var})
345MK_${var}:=	yes
346.else
347MK_${var}:=	no
348.endif
349.endif
350.endif
351.endfor
352
353#
354# Force some options off if their dependencies are off.
355# Order is somewhat important.
356#
357.if !${COMPILER_FEATURES:Mc++11}
358MK_LLVM_LIBUNWIND:=	no
359.endif
360
361.if ${MK_BINUTILS} == "no"
362MK_GDB:=	no
363.endif
364
365.if ${MK_CAPSICUM} == "no"
366MK_CASPER:=	no
367.endif
368
369.if ${MK_LIBPTHREAD} == "no"
370MK_LIBTHR:=	no
371.endif
372
373.if ${MK_LDNS} == "no"
374MK_LDNS_UTILS:=	no
375MK_UNBOUND:= no
376.endif
377
378.if ${MK_SOURCELESS} == "no"
379MK_SOURCELESS_HOST:=	no
380MK_SOURCELESS_UCODE:= no
381.endif
382
383.if ${MK_CDDL} == "no"
384MK_ZFS:=	no
385MK_CTF:=	no
386.endif
387
388.if ${MK_CRYPT} == "no"
389MK_OPENSSL:=	no
390MK_OPENSSH:=	no
391MK_KERBEROS:=	no
392.endif
393
394.if ${MK_CXX} == "no"
395MK_CLANG:=	no
396MK_GNUCXX:=	no
397MK_TESTS:=	no
398.endif
399
400.if ${MK_DIALOG} == "no"
401MK_BSDINSTALL:=	no
402.endif
403
404.if ${MK_MAIL} == "no"
405MK_MAILWRAPPER:= no
406MK_SENDMAIL:=	no
407MK_DMAGENT:=	no
408.endif
409
410.if ${MK_NETGRAPH} == "no"
411MK_ATM:=	no
412MK_BLUETOOTH:=	no
413.endif
414
415.if ${MK_NLS} == "no"
416MK_NLS_CATALOGS:= no
417.endif
418
419.if ${MK_OPENSSL} == "no"
420MK_OPENSSH:=	no
421MK_KERBEROS:=	no
422.endif
423
424.if ${MK_PF} == "no"
425MK_AUTHPF:=	no
426.endif
427
428.if ${MK_TESTS} == "no"
429MK_DTRACE_TESTS:= no
430.endif
431
432.if ${MK_ZONEINFO} == "no"
433MK_ZONEINFO_LEAPSECONDS_SUPPORT:= no
434MK_ZONEINFO_OLD_TIMEZONES_SUPPORT:= no
435.endif
436
437.if ${MK_CROSS_COMPILER} == "no"
438MK_BINUTILS_BOOTSTRAP:= no
439MK_CLANG_BOOTSTRAP:= no
440MK_ELFTOOLCHAIN_BOOTSTRAP:= no
441MK_GCC_BOOTSTRAP:= no
442MK_LLD_BOOTSTRAP:= no
443.endif
444
445.if ${MK_TOOLCHAIN} == "no"
446MK_BINUTILS:=	no
447MK_CLANG:=	no
448MK_GCC:=	no
449MK_GDB:=	no
450MK_INCLUDES:=	no
451MK_LLD:=	no
452MK_LLDB:=	no
453.endif
454
455.if ${MK_CLANG} == "no"
456MK_CLANG_EXTRAS:= no
457MK_CLANG_FULL:= no
458MK_LLVM_COV:= no
459.endif
460
461#
462# MK_* options whose default value depends on another option.
463#
464.for vv in \
465    GSSAPI/KERBEROS \
466    MAN_UTILS/MAN
467.if defined(WITH_${vv:H})
468MK_${vv:H}:=	yes
469.elif defined(WITHOUT_${vv:H})
470MK_${vv:H}:=	no
471.else
472MK_${vv:H}:=	${MK_${vv:T}}
473.endif
474.endfor
475
476#
477# Set defaults for the MK_*_SUPPORT variables.
478#
479
480#
481# MK_*_SUPPORT options which default to "yes" unless their corresponding
482# MK_* variable is set to "no".
483#
484.for var in \
485    BLACKLIST \
486    BZIP2 \
487    INET \
488    INET6 \
489    KERBEROS \
490    KVM \
491    NETGRAPH \
492    PAM \
493    TESTS \
494    WIRELESS
495.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
496MK_${var}_SUPPORT:= no
497.else
498MK_${var}_SUPPORT:= yes
499.endif
500.endfor
501
502.if !${COMPILER_FEATURES:Mc++11}
503MK_LLDB:=	no
504.endif
505
506# gcc 4.8 and newer supports libc++, so suppress gnuc++ in that case.
507# while in theory we could build it with that, we don't want to do
508# that since it creates too much confusion for too little gain.
509# XXX: This is incomplete and needs X_COMPILER_TYPE/VERSION checks too
510#      to prevent Makefile.inc1 from bootstrapping unneeded dependencies
511#      and to support 'make delete-old' when supplying an external toolchain.
512.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800
513MK_GNUCXX:=no
514MK_GCC:=no
515.endif
516
517.endif #  !target(__<src.opts.mk>__)
518