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