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