xref: /freebsd/sys/conf/kern.opts.mk (revision 9f44a47fd07924afc035991af15d84e6585dea4f)
1# $FreeBSD$
2
3# Options set in the build system which affect the building of kernel
4# modules. These select which parts to compile in or out (eg INET) or which
5# parts to omit (eg CDDL or SOURCELESS_HOST). Some of these will cause
6# config.mk to define symbols in various opt_*.h files.
7
8#
9# Define MK_* variables (which are either "yes" or "no") for users
10# to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the
11# make(1) environment.
12# These should be tested with `== "no"' or `!= "no"' in makefiles.
13# The NO_* variables should only be set by makefiles for variables
14# that haven't been converted over.
15#
16
17# Note: bsd.own.mk must be included before the rest of kern.opts.mk to make
18# building on 10.x and earlier work. This should be removed when that's no
19# longer supported since it confounds the defaults (since it uses the host's
20# notion of defaults rather than what's default in current when building
21# within sys/modules).
22.include <bsd.own.mk>
23
24# These options are used by the kernel build process (kern.mk and kmod.mk)
25# They have to be listed here so we can build modules outside of the
26# src tree.
27
28KLDXREF_CMD?=	kldxref
29
30__DEFAULT_YES_OPTIONS = \
31    AUTOFS \
32    BHYVE \
33    BLUETOOTH \
34    CCD \
35    CDDL \
36    CRYPT \
37    CUSE \
38    DTRACE \
39    EFI \
40    FORMAT_EXTENSIONS \
41    INET \
42    INET6 \
43    IPFILTER \
44    IPSEC_SUPPORT \
45    ISCSI \
46    KERNEL_SYMBOLS \
47    NETGRAPH \
48    OFED \
49    PF \
50    SCTP_SUPPORT \
51    SOURCELESS_HOST \
52    SOURCELESS_UCODE \
53    SPLIT_KERNEL_DEBUG \
54    TESTS \
55    USB_GADGET_EXAMPLES \
56    ZFS
57
58__DEFAULT_NO_OPTIONS = \
59    BHYVE_SNAPSHOT \
60    EXTRA_TCP_STACKS \
61    INIT_ALL_PATTERN \
62    INIT_ALL_ZERO \
63    KERNEL_RETPOLINE \
64    RATELIMIT \
65    REPRODUCIBLE_BUILD \
66    VERIEXEC
67
68# Some options are totally broken on some architectures. We disable
69# them. If you need to enable them on an experimental basis, you
70# must change this code.
71# Note: These only apply to the list of modules we build by default
72# and sometimes what is in the opt_*.h files by default.
73# Kernel config files are unaffected, though some targets can be
74# affected by KERNEL_SYMBOLS, FORMAT_EXTENSIONS, CTF and SSP.
75
76# Things that don't work based on the CPU
77.if ${MACHINE} == "amd64"
78# PR251083 conflict between INIT_ALL_ZERO and ifunc memset
79BROKEN_OPTIONS+= INIT_ALL_ZERO
80.endif
81
82# Broken on 32-bit arm, kernel module compile errors
83.if ${MACHINE_CPUARCH} == "arm"
84BROKEN_OPTIONS+= OFED
85.endif
86
87# Things that don't work based on toolchain support.
88.if ${MACHINE} != "i386" && ${MACHINE} != "amd64"
89BROKEN_OPTIONS+= KERNEL_RETPOLINE
90.endif
91
92# EFI doesn't exist on powerpc or riscv and is broken on i386
93.if ${MACHINE:Mpowerpc} || ${MACHINE:Mriscv} || ${MACHINE} == "i386"
94BROKEN_OPTIONS+=EFI
95.endif
96
97.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
98__DEFAULT_NO_OPTIONS += FDT
99.else
100__DEFAULT_YES_OPTIONS += FDT
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#end of bsd.mkopt.mk expanded inline.
146
147#
148# MK_*_SUPPORT options which default to "yes" unless their corresponding
149# MK_* variable is set to "no".
150#
151.for var in \
152    INET \
153    INET6
154.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
155MK_${var}_SUPPORT:= no
156.else
157.if defined(KERNBUILDDIR)	# See if there's an opt_foo.h
158.if !defined(OPT_${var})
159OPT_${var}!= cat ${KERNBUILDDIR}/opt_${var:tl}.h; echo
160.export OPT_${var}
161.endif
162.if ${OPT_${var}} == ""		# nothing -> no
163MK_${var}_SUPPORT:= no
164.else
165MK_${var}_SUPPORT:= yes
166.endif
167.else				# otherwise, yes
168MK_${var}_SUPPORT:= yes
169.endif
170.endif
171.endfor
172
173.if ${MK_SPLIT_KERNEL_DEBUG} == "no"
174MK_KERNEL_SYMBOLS:=	no
175.endif
176
177.if ${MK_CDDL} == "no"
178MK_DTRACE:=	no
179.endif
180
181# Some modules only compile successfully if option FDT is set, due to #ifdef FDT
182# wrapped around declarations.  Module makefiles can optionally compile such
183# things using .if !empty(OPT_FDT)
184.if !defined(OPT_FDT) && defined(KERNBUILDDIR)
185OPT_FDT!= sed -n '/FDT/p' ${KERNBUILDDIR}/opt_platform.h
186.export OPT_FDT
187.if empty(OPT_FDT)
188MK_FDT:=no
189.else
190MK_FDT:=yes
191.endif
192.endif
193