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