2 # Options set in the build system which affect the building of kernel
3 # modules. These select which parts to compile in or out (eg INET) or which
4 # parts to omit (eg CDDL or SOURCELESS_HOST). Some of these will cause
5 # config.mk to define symbols in various opt_*.h files.
8 # Define MK_* variables (which are either "yes" or "no") for users
9 # to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the
10 # make(1) environment.
11 # These should be tested with `== "no"' or `!= "no"' in makefiles.
12 # The NO_* variables should only be set by makefiles for variables
13 # that haven't been converted over.
16 # Note: bsd.own.mk must be included before the rest of kern.opts.mk to make
17 # building on 10.x and earlier work. This should be removed when that's no
18 # longer supported since it confounds the defaults (since it uses the host's
19 # notion of defaults rather than what's default in current when building
20 # within sys/modules).
23 # These options are used by the kernel build process (kern.mk and kmod.mk)
24 # They have to be listed here so we can build modules outside of the
29 __DEFAULT_YES_OPTIONS = \
57 __DEFAULT_NO_OPTIONS = \
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.
73 # Broken on 32-bit arm, kernel module compile errors
74 .if ${MACHINE_CPUARCH} == "arm"
78 # Things that don't work based on toolchain support.
79 .if ${MACHINE} != "i386" && ${MACHINE} != "amd64"
80 BROKEN_OPTIONS+= KERNEL_RETPOLINE
83 # EFI doesn't exist on powerpc or riscv and is broken on i386
84 .if ${MACHINE:Mpowerpc} || ${MACHINE:Mriscv} || ${MACHINE} == "i386"
88 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
89 __DEFAULT_NO_OPTIONS += FDT
91 __DEFAULT_YES_OPTIONS += FDT
97 __INIT_ALL_OPTIONS= none pattern zero
98 __INIT_ALL_DEFAULT= none
99 .if ${MACHINE} == "amd64"
100 # PR251083 conflict between INIT_ALL_ZERO and ifunc memset
101 BROKEN_SINGLE_OPTIONS+= INIT_ALL zero none
104 # expanded inline from bsd.mkopt.mk to avoid share/mk dependency
106 # Those that default to yes
107 .for var in ${__DEFAULT_YES_OPTIONS}
108 .if !defined(MK_${var})
109 .if defined(WITHOUT_${var}) # WITHOUT always wins
115 .if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
116 .error "Illegal value for MK_${var}: ${MK_${var}}"
118 .endif # !defined(MK_${var})
120 .undef __DEFAULT_YES_OPTIONS
122 # Those that default to no
123 .for var in ${__DEFAULT_NO_OPTIONS}
124 .if !defined(MK_${var})
125 .if defined(WITH_${var}) && !defined(WITHOUT_${var}) # WITHOUT always wins
131 .if ${MK_${var}} != "yes" && ${MK_${var}} != "no"
132 .error "Illegal value for MK_${var}: ${MK_${var}}"
134 .endif # !defined(MK_${var})
136 .undef __DEFAULT_NO_OPTIONS
139 # MK_* options which are always no, usually because they are
140 # unsupported/badly broken on this architecture.
142 .for var in ${BROKEN_OPTIONS}
145 .undef BROKEN_OPTIONS
148 # Group options set an OPT_FOO variable for each option.
150 .for opt in ${__SINGLE_OPTIONS}
151 .if !defined(__${opt}_OPTIONS) || empty(__${opt}_OPTIONS)
152 .error __${opt}_OPTIONS not defined or empty
154 .if !defined(__${opt}_DEFAULT) || empty(__${opt}_DEFAULT)
155 .error __${opt}_DEFAULT undefined or empty
158 OPT_${opt}:= ${${opt}}
160 OPT_${opt}:= ${__${opt}_DEFAULT}
162 .if empty(OPT_${opt}) || ${__${opt}_OPTIONS:M${OPT_${opt}}} != ${OPT_${opt}}
163 .error Invalid option OPT_${opt} (${OPT_${opt}}), must be one of: ${__${opt}_OPTIONS}
166 .undef __SINGLE_OPTIONS
168 .for opt val rep in ${BROKEN_SINGLE_OPTIONS}
169 .if ${OPT_${opt}} == ${val}
173 #end of bsd.mkopt.mk expanded inline.
176 # MK_*_SUPPORT options which default to "yes" unless their corresponding
177 # MK_* variable is set to "no".
182 .if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
183 MK_${var}_SUPPORT:= no
185 .if defined(KERNBUILDDIR) # See if there's an opt_foo.h
186 .if !defined(OPT_${var})
187 OPT_${var}!= cat ${KERNBUILDDIR}/opt_${var:tl}.h; echo
190 .if ${OPT_${var}} == "" # nothing -> no
191 MK_${var}_SUPPORT:= no
193 MK_${var}_SUPPORT:= yes
195 .else # otherwise, yes
196 MK_${var}_SUPPORT:= yes
201 .if ${MK_SPLIT_KERNEL_DEBUG} == "no"
202 MK_KERNEL_SYMBOLS:= no
205 .if ${MK_CDDL} == "no"
209 # Some modules only compile successfully if option FDT is set, due to #ifdef FDT
210 # wrapped around declarations. Module makefiles can optionally compile such
211 # things using .if !empty(OPT_FDT)
212 .if !defined(OPT_FDT) && defined(KERNBUILDDIR)
213 OPT_FDT!= sed -n '/FDT/p' ${KERNBUILDDIR}/opt_platform.h