xref: /freebsd/sys/conf/kern.opts.mk (revision 1719886f)
1
2# Options set in the build system which affect the building of kernel
3# modules. These select which parts to compile in or out (eg INET) or which
4# parts to omit (eg CDDL or SOURCELESS_HOST). Some of these will cause
5# config.mk to define symbols in various opt_*.h files.
6
7#
8# Define MK_* variables (which are either "yes" or "no") for users
9# to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the
10# make(1) environment.
11# These should be tested with `== "no"' or `!= "no"' in makefiles.
12# The NO_* variables should only be set by makefiles for variables
13# that haven't been converted over.
14#
15
16# Note: bsd.own.mk must be included before the rest of kern.opts.mk to make
17# building on 10.x and earlier work. This should be removed when that's no
18# longer supported since it confounds the defaults (since it uses the host's
19# notion of defaults rather than what's default in current when building
20# within sys/modules).
21.include <bsd.own.mk>
22
23# These options are used by the kernel build process (kern.mk and kmod.mk)
24# They have to be listed here so we can build modules outside of the
25# src tree.
26
27KLDXREF_CMD?=	kldxref
28
29__DEFAULT_YES_OPTIONS = \
30    AUTOFS \
31    BHYVE \
32    BLUETOOTH \
33    CCD \
34    CDDL \
35    CRYPT \
36    CUSE \
37    DTRACE \
38    EFI \
39    FORMAT_EXTENSIONS \
40    INET \
41    INET6 \
42    IPFILTER \
43    IPSEC_SUPPORT \
44    ISCSI \
45    KERNEL_SYMBOLS \
46    NETGRAPH \
47    OFED \
48    PF \
49    SCTP_SUPPORT \
50    SOURCELESS_HOST \
51    SOURCELESS_UCODE \
52    SPLIT_KERNEL_DEBUG \
53    TESTS \
54    USB_GADGET_EXAMPLES \
55    VIMAGE \
56    ZFS
57
58__DEFAULT_NO_OPTIONS = \
59    BHYVE_SNAPSHOT \
60    KERNEL_BIN \
61    KERNEL_RETPOLINE \
62    RATELIMIT \
63    REPRODUCIBLE_BUILD \
64    VERIEXEC
65
66# Some options are totally broken on some architectures. We disable them. If you
67# need to enable them on an experimental basis, you must change this code.
68# Note: These only apply to the list of modules we build by default and
69# sometimes what is in the opt_*.h files by default.  Kernel config files are
70# unaffected, though some targets can be affected by KERNEL_BIN, KERNEL_SYMBOLS,
71# FORMAT_EXTENSIONS, CTF and SSP.
72
73# Broken on 32-bit arm, kernel module compile errors
74.if ${MACHINE_CPUARCH} == "arm"
75BROKEN_OPTIONS+= OFED
76.endif
77
78# Things that don't work based on toolchain support.
79.if ${MACHINE} != "i386" && ${MACHINE} != "amd64"
80BROKEN_OPTIONS+= KERNEL_RETPOLINE
81.endif
82
83# EFI doesn't exist on powerpc or riscv and is broken on i386
84.if ${MACHINE:Mpowerpc} || ${MACHINE:Mriscv} || ${MACHINE} == "i386"
85BROKEN_OPTIONS+=EFI
86.endif
87
88# We only generate kernel.bin on arm and arm64, otherwise they break the build.
89.if ${MACHINE} != "arm" && ${MACHINE} != "arm64"
90BROKEN_OPTIONS+=KERNEL_BIN
91.endif
92
93.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
94__DEFAULT_NO_OPTIONS += FDT
95.else
96__DEFAULT_YES_OPTIONS += FDT
97.endif
98
99__SINGLE_OPTIONS = \
100	INIT_ALL
101
102__INIT_ALL_OPTIONS=	none pattern zero
103__INIT_ALL_DEFAULT=	none
104.if ${MACHINE} == "amd64"
105# PR251083 conflict between INIT_ALL_ZERO and ifunc memset
106BROKEN_SINGLE_OPTIONS+=	INIT_ALL zero none
107.endif
108
109# expanded inline from bsd.mkopt.mk to avoid share/mk dependency
110
111# Those that default to yes
112.for var in ${__DEFAULT_YES_OPTIONS}
113.if !defined(MK_${var})
114.if defined(WITHOUT_${var})			# WITHOUT always wins
115MK_${var}:=	no
116.else
117MK_${var}:=	yes
118.endif
119.else
120.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
121.error "Illegal value for MK_${var}: ${MK_${var}}"
122.endif
123.endif # !defined(MK_${var})
124.endfor
125.undef __DEFAULT_YES_OPTIONS
126
127# Those that default to no
128.for var in ${__DEFAULT_NO_OPTIONS}
129.if !defined(MK_${var})
130.if defined(WITH_${var}) && !defined(WITHOUT_${var}) # WITHOUT always wins
131MK_${var}:=	yes
132.else
133MK_${var}:=	no
134.endif
135.else
136.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
137.error "Illegal value for MK_${var}: ${MK_${var}}"
138.endif
139.endif # !defined(MK_${var})
140.endfor
141.undef __DEFAULT_NO_OPTIONS
142
143#
144# MK_* options which are always no, usually because they are
145# unsupported/badly broken on this architecture.
146#
147.for var in ${BROKEN_OPTIONS}
148MK_${var}:=	no
149.endfor
150.undef BROKEN_OPTIONS
151
152#
153# Group options set an OPT_FOO variable for each option.
154#
155.for opt in ${__SINGLE_OPTIONS}
156.if !defined(__${opt}_OPTIONS) || empty(__${opt}_OPTIONS)
157.error __${opt}_OPTIONS not defined or empty
158.endif
159.if !defined(__${opt}_DEFAULT) || empty(__${opt}_DEFAULT)
160.error __${opt}_DEFAULT undefined or empty
161.endif
162.if defined(${opt})
163OPT_${opt}:=	${${opt}}
164.else
165OPT_${opt}:=	${__${opt}_DEFAULT}
166.endif
167.if empty(OPT_${opt}) || ${__${opt}_OPTIONS:M${OPT_${opt}}} != ${OPT_${opt}}
168.error Invalid option OPT_${opt} (${OPT_${opt}}), must be one of: ${__${opt}_OPTIONS}
169.endif
170.endfor
171.undef __SINGLE_OPTIONS
172
173.for opt val rep in ${BROKEN_SINGLE_OPTIONS}
174.if ${OPT_${opt}} == ${val}
175OPT_${opt}:=	${rep}
176.endif
177.endfor
178#end of bsd.mkopt.mk expanded inline.
179
180#
181# MK_*_SUPPORT options which default to "yes" unless their corresponding
182# MK_* variable is set to "no".
183#
184.for var in \
185    INET \
186    INET6 \
187    VIMAGE
188.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
189MK_${var}_SUPPORT:= no
190.else
191.if defined(KERNBUILDDIR)	# See if there's an opt_foo.h
192.if !defined(OPT_${var})
193OPT_${var}!= cat ${KERNBUILDDIR}/opt_${var:tl}.h; echo
194.export OPT_${var}
195.endif
196.if ${OPT_${var}} == ""		# nothing -> no
197MK_${var}_SUPPORT:= no
198.else
199MK_${var}_SUPPORT:= yes
200.endif
201.else				# otherwise, yes
202MK_${var}_SUPPORT:= yes
203.endif
204.endif
205.endfor
206
207.if ${MK_SPLIT_KERNEL_DEBUG} == "no"
208MK_KERNEL_SYMBOLS:=	no
209.endif
210
211.if ${MK_CDDL} == "no"
212MK_DTRACE:=	no
213.endif
214
215# Some modules only compile successfully if option FDT is set, due to #ifdef FDT
216# wrapped around declarations.  Module makefiles can optionally compile such
217# things using .if !empty(OPT_FDT)
218.if !defined(OPT_FDT) && defined(KERNBUILDDIR)
219OPT_FDT!= sed -n '/FDT/p' ${KERNBUILDDIR}/opt_platform.h
220.export OPT_FDT
221.if empty(OPT_FDT)
222MK_FDT:=no
223.else
224MK_FDT:=yes
225.endif
226.endif
227