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