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