xref: /freebsd/sys/conf/kern.opts.mk (revision fe815331bb40604ba31312acf7e4619674631777)
1# $FreeBSD$
2
3# Options set in the build system that affect the kernel somehow.
4
5#
6# Define MK_* variables (which are either "yes" or "no") for users
7# to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the
8# make(1) environment.
9# These should be tested with `== "no"' or `!= "no"' in makefiles.
10# The NO_* variables should only be set by makefiles for variables
11# that haven't been converted over.
12#
13
14# Note: bsd.own.mk must be included before the rest of kern.opts.mk to make
15# building on 10.x and earlier work. This should be removed when that's no
16# longer supported since it confounds the defaults (since it uses the host's
17# notion of defaults rather than what's default in current when building
18# within sys/modules).
19.include <bsd.own.mk>
20
21# These options are used by the kernel build process (kern.mk and kmod.mk)
22# They have to be listed here so we can build modules outside of the
23# src tree.
24
25KLDXREF_CMD?=	kldxref
26
27__DEFAULT_YES_OPTIONS = \
28    AUTOFS \
29    BHYVE \
30    BLUETOOTH \
31    CCD \
32    CDDL \
33    CRYPT \
34    CUSE \
35    EFI \
36    FORMAT_EXTENSIONS \
37    INET \
38    INET6 \
39    IPFILTER \
40    IPSEC_SUPPORT \
41    ISCSI \
42    KERNEL_SYMBOLS \
43    NETGRAPH \
44    PF \
45    SCTP_SUPPORT \
46    SOURCELESS_HOST \
47    SOURCELESS_UCODE \
48    TESTS \
49    USB_GADGET_EXAMPLES \
50    ZFS
51
52__DEFAULT_NO_OPTIONS = \
53    BHYVE_SNAPSHOT \
54    EXTRA_TCP_STACKS \
55    KERNEL_RETPOLINE \
56    OFED \
57    RATELIMIT \
58    REPRODUCIBLE_BUILD
59
60# Some options are totally broken on some architectures. We disable
61# them. If you need to enable them on an experimental basis, you
62# must change this code.
63# Note: These only apply to the list of modules we build by default
64# and sometimes what is in the opt_*.h files by default.
65# Kernel config files are unaffected, though some targets can be
66# affected by KERNEL_SYMBOLS, FORMAT_EXTENSIONS, CTF and SSP.
67
68# Things that don't work based on the CPU
69.if ${MACHINE_CPUARCH} == "arm"
70. if ${MACHINE_ARCH:Marmv[67]*} == ""
71BROKEN_OPTIONS+= CDDL ZFS
72. endif
73.endif
74
75.if ${MACHINE_CPUARCH} == "mips"
76BROKEN_OPTIONS+= CDDL ZFS SSP
77.endif
78
79.if ${MACHINE_CPUARCH} == "powerpc" && ${MACHINE_ARCH} == "powerpc"
80BROKEN_OPTIONS+= ZFS
81.endif
82
83# Things that don't work because the kernel doesn't have the support
84# for them.
85.if ${MACHINE} != "i386" && ${MACHINE} != "amd64"
86BROKEN_OPTIONS+= OFED
87.endif
88
89# Things that don't work based on toolchain support.
90.if ${MACHINE} != "i386" && ${MACHINE} != "amd64"
91BROKEN_OPTIONS+= KERNEL_RETPOLINE
92.endif
93
94# EFI doesn't exist on mips, powerpc, or riscv.
95.if ${MACHINE:Mmips} || ${MACHINE:Mpowerpc} || ${MACHINE:Mriscv}
96BROKEN_OPTIONS+=EFI
97.endif
98
99# expanded inline from bsd.mkopt.mk to avoid share/mk dependency
100
101# Those that default to yes
102.for var in ${__DEFAULT_YES_OPTIONS}
103.if !defined(MK_${var})
104.if defined(WITHOUT_${var})			# WITHOUT always wins
105MK_${var}:=	no
106.else
107MK_${var}:=	yes
108.endif
109.else
110.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
111.error "Illegal value for MK_${var}: ${MK_${var}}"
112.endif
113.endif # !defined(MK_${var})
114.endfor
115.undef __DEFAULT_YES_OPTIONS
116
117# Those that default to no
118.for var in ${__DEFAULT_NO_OPTIONS}
119.if !defined(MK_${var})
120.if defined(WITH_${var}) && !defined(WITHOUT_${var}) # WITHOUT always wins
121MK_${var}:=	yes
122.else
123MK_${var}:=	no
124.endif
125.else
126.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
127.error "Illegal value for MK_${var}: ${MK_${var}}"
128.endif
129.endif # !defined(MK_${var})
130.endfor
131.undef __DEFAULT_NO_OPTIONS
132
133#
134# MK_* options which are always no, usually because they are
135# unsupported/badly broken on this architecture.
136#
137.for var in ${BROKEN_OPTIONS}
138MK_${var}:=	no
139.endfor
140.undef BROKEN_OPTIONS
141#end of bsd.mkopt.mk expanded inline.
142
143#
144# MK_*_SUPPORT options which default to "yes" unless their corresponding
145# MK_* variable is set to "no".
146#
147.for var in \
148    INET \
149    INET6
150.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
151MK_${var}_SUPPORT:= no
152.else
153.if defined(KERNBUILDDIR)	# See if there's an opt_foo.h
154.if !defined(OPT_${var})
155OPT_${var}!= cat ${KERNBUILDDIR}/opt_${var:tl}.h; echo
156.export OPT_${var}
157.endif
158.if ${OPT_${var}} == ""		# nothing -> no
159MK_${var}_SUPPORT:= no
160.else
161MK_${var}_SUPPORT:= yes
162.endif
163.else				# otherwise, yes
164MK_${var}_SUPPORT:= yes
165.endif
166.endif
167.endfor
168
169# Some modules only compile successfully if option FDT is set, due to #ifdef FDT
170# wrapped around declarations.  Module makefiles can optionally compile such
171# things using .if !empty(OPT_FDT)
172.if !defined(OPT_FDT) && defined(KERNBUILDDIR)
173OPT_FDT!= sed -n '/FDT/p' ${KERNBUILDDIR}/opt_platform.h
174.export OPT_FDT
175.endif
176