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