xref: /freebsd/sys/conf/kern.opts.mk (revision 716fd348)
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    TESTS \
53    USB_GADGET_EXAMPLES \
54    ZFS
55
56__DEFAULT_NO_OPTIONS = \
57    BHYVE_SNAPSHOT \
58    EXTRA_TCP_STACKS \
59    INIT_ALL_PATTERN \
60    INIT_ALL_ZERO \
61    KERNEL_RETPOLINE \
62    RATELIMIT \
63    REPRODUCIBLE_BUILD
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# Things that don't work based on the CPU
74.if ${MACHINE} == "amd64"
75# PR251083 conflict between INIT_ALL_ZERO and ifunc memset
76BROKEN_OPTIONS+= INIT_ALL_ZERO
77.endif
78
79.if ${MACHINE_CPUARCH} == "arm"
80. if ${MACHINE_ARCH:Marmv[67]*} == ""
81BROKEN_OPTIONS+= CDDL ZFS
82. endif
83.endif
84
85.if ${MACHINE_CPUARCH} == "powerpc" && ${MACHINE_ARCH} == "powerpc"
86BROKEN_OPTIONS+= ZFS
87.endif
88
89# Things that don't work because the kernel doesn't have the support
90# for them.
91.if ${MACHINE} != "i386" && ${MACHINE} != "amd64"
92BROKEN_OPTIONS+= OFED
93.endif
94
95# Things that don't work based on toolchain support.
96.if ${MACHINE} != "i386" && ${MACHINE} != "amd64"
97BROKEN_OPTIONS+= KERNEL_RETPOLINE
98.endif
99
100# EFI doesn't exist on powerpc, or riscv
101.if ${MACHINE:Mpowerpc} || ${MACHINE:Mriscv}
102BROKEN_OPTIONS+=EFI
103.endif
104
105.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
106__DEFAULT_NO_OPTIONS += FDT
107.else
108__DEFAULT_YES_OPTIONS += FDT
109.endif
110
111# expanded inline from bsd.mkopt.mk to avoid share/mk dependency
112
113# Those that default to yes
114.for var in ${__DEFAULT_YES_OPTIONS}
115.if !defined(MK_${var})
116.if defined(WITHOUT_${var})			# WITHOUT always wins
117MK_${var}:=	no
118.else
119MK_${var}:=	yes
120.endif
121.else
122.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
123.error "Illegal value for MK_${var}: ${MK_${var}}"
124.endif
125.endif # !defined(MK_${var})
126.endfor
127.undef __DEFAULT_YES_OPTIONS
128
129# Those that default to no
130.for var in ${__DEFAULT_NO_OPTIONS}
131.if !defined(MK_${var})
132.if defined(WITH_${var}) && !defined(WITHOUT_${var}) # WITHOUT always wins
133MK_${var}:=	yes
134.else
135MK_${var}:=	no
136.endif
137.else
138.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
139.error "Illegal value for MK_${var}: ${MK_${var}}"
140.endif
141.endif # !defined(MK_${var})
142.endfor
143.undef __DEFAULT_NO_OPTIONS
144
145#
146# MK_* options which are always no, usually because they are
147# unsupported/badly broken on this architecture.
148#
149.for var in ${BROKEN_OPTIONS}
150MK_${var}:=	no
151.endfor
152.undef BROKEN_OPTIONS
153#end of bsd.mkopt.mk expanded inline.
154
155#
156# MK_*_SUPPORT options which default to "yes" unless their corresponding
157# MK_* variable is set to "no".
158#
159.for var in \
160    INET \
161    INET6
162.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
163MK_${var}_SUPPORT:= no
164.else
165.if defined(KERNBUILDDIR)	# See if there's an opt_foo.h
166.if !defined(OPT_${var})
167OPT_${var}!= cat ${KERNBUILDDIR}/opt_${var:tl}.h; echo
168.export OPT_${var}
169.endif
170.if ${OPT_${var}} == ""		# nothing -> no
171MK_${var}_SUPPORT:= no
172.else
173MK_${var}_SUPPORT:= yes
174.endif
175.else				# otherwise, yes
176MK_${var}_SUPPORT:= yes
177.endif
178.endif
179.endfor
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