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