xref: /freebsd/sys/conf/kern.opts.mk (revision 6fa42b91ca3f481912af98c4d49c44507eb1b8e1)
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    ZFS
56
57__DEFAULT_NO_OPTIONS = \
58    BHYVE_SNAPSHOT \
59    KERNEL_BIN \
60    KERNEL_RETPOLINE \
61    RATELIMIT \
62    REPRODUCIBLE_BUILD \
63    VERIEXEC
64
65# Some options are totally broken on some architectures. We disable them. If you
66# need to enable them on an experimental basis, you must change this code.
67# Note: These only apply to the list of modules we build by default and
68# sometimes what is in the opt_*.h files by default.  Kernel config files are
69# unaffected, though some targets can be affected by KERNEL_BIN, KERNEL_SYMBOLS,
70# FORMAT_EXTENSIONS, CTF and SSP.
71
72# Broken on 32-bit arm, kernel module compile errors
73.if ${MACHINE_CPUARCH} == "arm"
74BROKEN_OPTIONS+= OFED
75.endif
76
77# Things that don't work based on toolchain support.
78.if ${MACHINE} != "i386" && ${MACHINE} != "amd64"
79BROKEN_OPTIONS+= KERNEL_RETPOLINE
80.endif
81
82# EFI doesn't exist on powerpc or riscv and is broken on i386
83.if ${MACHINE:Mpowerpc} || ${MACHINE:Mriscv} || ${MACHINE} == "i386"
84BROKEN_OPTIONS+=EFI
85.endif
86
87# We only generate kernel.bin on arm and arm64, otherwise they break the build.
88.if ${MACHINE} != "arm" && ${MACHINE} != "arm64"
89BROKEN_OPTIONS+=KERNEL_BIN
90.endif
91
92.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
93__DEFAULT_NO_OPTIONS += FDT
94.else
95__DEFAULT_YES_OPTIONS += FDT
96.endif
97
98__SINGLE_OPTIONS = \
99	INIT_ALL
100
101__INIT_ALL_OPTIONS=	none pattern zero
102__INIT_ALL_DEFAULT=	none
103.if ${MACHINE} == "amd64"
104# PR251083 conflict between INIT_ALL_ZERO and ifunc memset
105BROKEN_SINGLE_OPTIONS+=	INIT_ALL zero none
106.endif
107
108# expanded inline from bsd.mkopt.mk to avoid share/mk dependency
109
110# Those that default to yes
111.for var in ${__DEFAULT_YES_OPTIONS}
112.if !defined(MK_${var})
113.if defined(WITHOUT_${var})			# WITHOUT always wins
114MK_${var}:=	no
115.else
116MK_${var}:=	yes
117.endif
118.else
119.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
120.error "Illegal value for MK_${var}: ${MK_${var}}"
121.endif
122.endif # !defined(MK_${var})
123.endfor
124.undef __DEFAULT_YES_OPTIONS
125
126# Those that default to no
127.for var in ${__DEFAULT_NO_OPTIONS}
128.if !defined(MK_${var})
129.if defined(WITH_${var}) && !defined(WITHOUT_${var}) # WITHOUT always wins
130MK_${var}:=	yes
131.else
132MK_${var}:=	no
133.endif
134.else
135.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
136.error "Illegal value for MK_${var}: ${MK_${var}}"
137.endif
138.endif # !defined(MK_${var})
139.endfor
140.undef __DEFAULT_NO_OPTIONS
141
142#
143# MK_* options which are always no, usually because they are
144# unsupported/badly broken on this architecture.
145#
146.for var in ${BROKEN_OPTIONS}
147MK_${var}:=	no
148.endfor
149.undef BROKEN_OPTIONS
150
151#
152# Group options set an OPT_FOO variable for each option.
153#
154.for opt in ${__SINGLE_OPTIONS}
155.if !defined(__${opt}_OPTIONS) || empty(__${opt}_OPTIONS)
156.error __${opt}_OPTIONS not defined or empty
157.endif
158.if !defined(__${opt}_DEFAULT) || empty(__${opt}_DEFAULT)
159.error __${opt}_DEFAULT undefined or empty
160.endif
161.if defined(${opt})
162OPT_${opt}:=	${${opt}}
163.else
164OPT_${opt}:=	${__${opt}_DEFAULT}
165.endif
166.if empty(OPT_${opt}) || ${__${opt}_OPTIONS:M${OPT_${opt}}} != ${OPT_${opt}}
167.error Invalid option OPT_${opt} (${OPT_${opt}}), must be one of: ${__${opt}_OPTIONS}
168.endif
169.endfor
170.undef __SINGLE_OPTIONS
171
172.for opt val rep in ${BROKEN_SINGLE_OPTIONS}
173.if ${OPT_${opt}} == ${val}
174OPT_${opt}:=	${rep}
175.endif
176.endfor
177#end of bsd.mkopt.mk expanded inline.
178
179#
180# MK_*_SUPPORT options which default to "yes" unless their corresponding
181# MK_* variable is set to "no".
182#
183.for var in \
184    INET \
185    INET6
186.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
187MK_${var}_SUPPORT:= no
188.else
189.if defined(KERNBUILDDIR)	# See if there's an opt_foo.h
190.if !defined(OPT_${var})
191OPT_${var}!= cat ${KERNBUILDDIR}/opt_${var:tl}.h; echo
192.export OPT_${var}
193.endif
194.if ${OPT_${var}} == ""		# nothing -> no
195MK_${var}_SUPPORT:= no
196.else
197MK_${var}_SUPPORT:= yes
198.endif
199.else				# otherwise, yes
200MK_${var}_SUPPORT:= yes
201.endif
202.endif
203.endfor
204
205.if ${MK_SPLIT_KERNEL_DEBUG} == "no"
206MK_KERNEL_SYMBOLS:=	no
207.endif
208
209.if ${MK_CDDL} == "no"
210MK_DTRACE:=	no
211.endif
212
213# Some modules only compile successfully if option FDT is set, due to #ifdef FDT
214# wrapped around declarations.  Module makefiles can optionally compile such
215# things using .if !empty(OPT_FDT)
216.if !defined(OPT_FDT) && defined(KERNBUILDDIR)
217OPT_FDT!= sed -n '/FDT/p' ${KERNBUILDDIR}/opt_platform.h
218.export OPT_FDT
219.if empty(OPT_FDT)
220MK_FDT:=no
221.else
222MK_FDT:=yes
223.endif
224.endif
225