xref: /freebsd/sys/conf/kern.opts.mk (revision cab6a39d7b343596a5823e65c0f7b426551ec22d)
1# $FreeBSD$
2
3# Options set in the build system that affect the kernel somehow.
4
5#
6# Define MK_* variables (which are either "yes" or "no") for users
7# to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the
8# make(1) environment.
9# These should be tested with `== "no"' or `!= "no"' in makefiles.
10# The NO_* variables should only be set by makefiles for variables
11# that haven't been converted over.
12#
13
14# Note: bsd.own.mk must be included before the rest of kern.opts.mk to make
15# building on 10.x and earlier work. This should be removed when that's no
16# longer supported since it confounds the defaults (since it uses the host's
17# notion of defaults rather than what's default in current when building
18# within sys/modules).
19.include <bsd.own.mk>
20
21# These options are used by the kernel build process (kern.mk and kmod.mk)
22# They have to be listed here so we can build modules outside of the
23# src tree.
24
25KLDXREF_CMD?=	kldxref
26
27__DEFAULT_YES_OPTIONS = \
28    AUTOFS \
29    BHYVE \
30    BLUETOOTH \
31    CCD \
32    CDDL \
33    CRYPT \
34    CUSE \
35    EFI \
36    FORMAT_EXTENSIONS \
37    INET \
38    INET6 \
39    IPFILTER \
40    IPSEC_SUPPORT \
41    ISCSI \
42    KERNEL_SYMBOLS \
43    NETGRAPH \
44    OFED \
45    PF \
46    SCTP_SUPPORT \
47    SOURCELESS_HOST \
48    SOURCELESS_UCODE \
49    TESTS \
50    USB_GADGET_EXAMPLES \
51    ZFS
52
53__DEFAULT_NO_OPTIONS = \
54    BHYVE_SNAPSHOT \
55    EXTRA_TCP_STACKS \
56    INIT_ALL_PATTERN \
57    INIT_ALL_ZERO \
58    KERNEL_RETPOLINE \
59    RATELIMIT \
60    REPRODUCIBLE_BUILD
61
62# Some options are totally broken on some architectures. We disable
63# them. If you need to enable them on an experimental basis, you
64# must change this code.
65# Note: These only apply to the list of modules we build by default
66# and sometimes what is in the opt_*.h files by default.
67# Kernel config files are unaffected, though some targets can be
68# affected by KERNEL_SYMBOLS, FORMAT_EXTENSIONS, CTF and SSP.
69
70# Things that don't work based on the CPU
71.if ${MACHINE} == "amd64"
72# PR251083 conflict between INIT_ALL_ZERO and ifunc memset
73BROKEN_OPTIONS+= INIT_ALL_ZERO
74.endif
75
76.if ${MACHINE_CPUARCH} == "arm"
77. if ${MACHINE_ARCH:Marmv[67]*} == ""
78BROKEN_OPTIONS+= CDDL ZFS
79. endif
80.endif
81
82.if ${MACHINE_CPUARCH} == "mips"
83BROKEN_OPTIONS+= CDDL ZFS SSP
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 mips, powerpc, or riscv.
102.if ${MACHINE:Mmips} || ${MACHINE:Mpowerpc} || ${MACHINE:Mriscv}
103BROKEN_OPTIONS+=EFI
104.endif
105
106# expanded inline from bsd.mkopt.mk to avoid share/mk dependency
107
108# Those that default to yes
109.for var in ${__DEFAULT_YES_OPTIONS}
110.if !defined(MK_${var})
111.if defined(WITHOUT_${var})			# WITHOUT always wins
112MK_${var}:=	no
113.else
114MK_${var}:=	yes
115.endif
116.else
117.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
118.error "Illegal value for MK_${var}: ${MK_${var}}"
119.endif
120.endif # !defined(MK_${var})
121.endfor
122.undef __DEFAULT_YES_OPTIONS
123
124# Those that default to no
125.for var in ${__DEFAULT_NO_OPTIONS}
126.if !defined(MK_${var})
127.if defined(WITH_${var}) && !defined(WITHOUT_${var}) # WITHOUT always wins
128MK_${var}:=	yes
129.else
130MK_${var}:=	no
131.endif
132.else
133.if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
134.error "Illegal value for MK_${var}: ${MK_${var}}"
135.endif
136.endif # !defined(MK_${var})
137.endfor
138.undef __DEFAULT_NO_OPTIONS
139
140#
141# MK_* options which are always no, usually because they are
142# unsupported/badly broken on this architecture.
143#
144.for var in ${BROKEN_OPTIONS}
145MK_${var}:=	no
146.endfor
147.undef BROKEN_OPTIONS
148#end of bsd.mkopt.mk expanded inline.
149
150#
151# MK_*_SUPPORT options which default to "yes" unless their corresponding
152# MK_* variable is set to "no".
153#
154.for var in \
155    INET \
156    INET6
157.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
158MK_${var}_SUPPORT:= no
159.else
160.if defined(KERNBUILDDIR)	# See if there's an opt_foo.h
161.if !defined(OPT_${var})
162OPT_${var}!= cat ${KERNBUILDDIR}/opt_${var:tl}.h; echo
163.export OPT_${var}
164.endif
165.if ${OPT_${var}} == ""		# nothing -> no
166MK_${var}_SUPPORT:= no
167.else
168MK_${var}_SUPPORT:= yes
169.endif
170.else				# otherwise, yes
171MK_${var}_SUPPORT:= yes
172.endif
173.endif
174.endfor
175
176# Some modules only compile successfully if option FDT is set, due to #ifdef FDT
177# wrapped around declarations.  Module makefiles can optionally compile such
178# things using .if !empty(OPT_FDT)
179.if !defined(OPT_FDT) && defined(KERNBUILDDIR)
180OPT_FDT!= sed -n '/FDT/p' ${KERNBUILDDIR}/opt_platform.h
181.export OPT_FDT
182.endif
183