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 them. If you
66 # need to enable them on an experimental basis, you must change this code.
67 # Note: These only apply to the list of modules we build by default and
68 # sometimes what is in the opt_*.h files by default. Kernel config files are
69 # unaffected, though some targets can be affected by KERNEL_BIN, KERNEL_SYMBOLS,
70 # FORMAT_EXTENSIONS, CTF and SSP.
72 # Broken on 32-bit arm, kernel module compile errors
73 .if
${MACHINE_CPUARCH} == "arm"
77 # Things that don't work based on toolchain support.
78 .if
${MACHINE} != "i386" && ${MACHINE} != "amd64"
79 BROKEN_OPTIONS
+= KERNEL_RETPOLINE
82 # EFI doesn't exist on powerpc or riscv and is broken on i386
83 .if
${MACHINE
:Mpowerpc
} ||
${MACHINE
:Mriscv
} ||
${MACHINE} == "i386"
87 # We only generate kernel.bin on arm and arm64, otherwise they break the build.
88 .if
${MACHINE} != "arm" && ${MACHINE} != "arm64"
89 BROKEN_OPTIONS
+=KERNEL_BIN
92 .if
${MACHINE_CPUARCH} == "i386" ||
${MACHINE_CPUARCH} == "amd64"
93 __DEFAULT_NO_OPTIONS
+= FDT
95 __DEFAULT_YES_OPTIONS
+= FDT
101 __INIT_ALL_OPTIONS
= none pattern zero
102 __INIT_ALL_DEFAULT
= none
103 .if
${MACHINE} == "amd64"
104 # PR251083 conflict between INIT_ALL_ZERO and ifunc memset
105 BROKEN_SINGLE_OPTIONS
+= INIT_ALL zero none
108 # expanded inline from bsd.mkopt.mk to avoid share/mk dependency
110 # Those that default to yes
111 .for var in
${__DEFAULT_YES_OPTIONS}
112 .if
!defined
(MK_
${var})
113 .if defined
(WITHOUT_
${var}) # WITHOUT always wins
119 .if
${MK_
${var}} != "yes" && ${MK_
${var}} != "no"
120 .error
"Illegal value for MK_${var}: ${MK_${var}}"
122 .
endif # !defined(MK_${var})
124 .undef __DEFAULT_YES_OPTIONS
126 # Those that default to no
127 .for var in
${__DEFAULT_NO_OPTIONS}
128 .if
!defined
(MK_
${var})
129 .if defined
(WITH_
${var}) && !defined
(WITHOUT_
${var}) # WITHOUT always wins
135 .if
${MK_
${var}} != "yes" && ${MK_
${var}} != "no"
136 .error
"Illegal value for MK_${var}: ${MK_${var}}"
138 .
endif # !defined(MK_${var})
140 .undef __DEFAULT_NO_OPTIONS
143 # MK_* options which are always no, usually because they are
144 # unsupported/badly broken on this architecture.
146 .for var in
${BROKEN_OPTIONS}
149 .undef BROKEN_OPTIONS
152 # Group options set an OPT_FOO variable for each option.
154 .for opt in
${__SINGLE_OPTIONS}
155 .if
!defined
(__
${opt}_OPTIONS
) || empty
(__
${opt}_OPTIONS
)
156 .error __
${opt}_OPTIONS not defined or empty
158 .if
!defined
(__
${opt}_DEFAULT
) || empty
(__
${opt}_DEFAULT
)
159 .error __
${opt}_DEFAULT undefined or empty
162 OPT_
${opt}:= ${${opt}}
164 OPT_
${opt}:= ${__
${opt}_DEFAULT
}
166 .if empty
(OPT_
${opt}) ||
${__
${opt}_OPTIONS
:M
${OPT_
${opt}}} != ${OPT_
${opt}}
167 .error Invalid option OPT_
${opt} (${OPT_
${opt}}), must be one of
: ${__
${opt}_OPTIONS
}
170 .undef __SINGLE_OPTIONS
172 .for opt val rep in
${BROKEN_SINGLE_OPTIONS}
173 .if
${OPT_
${opt}} == ${val}
177 #end of bsd.mkopt.mk expanded inline.
180 # MK_*_SUPPORT options which default to "yes" unless their corresponding
181 # MK_* variable is set to "no".
186 .if defined
(WITHOUT_
${var}_SUPPORT
) ||
${MK_
${var}} == "no"
187 MK_
${var}_SUPPORT
:= no
189 .if defined
(KERNBUILDDIR
) # See if there's an opt_foo.h
190 .if
!defined
(OPT_
${var})
191 OPT_
${var}!= cat
${KERNBUILDDIR}/opt_
${var
:tl
}.h
; echo
194 .if
${OPT_
${var}} == "" # nothing -> no
195 MK_
${var}_SUPPORT
:= no
197 MK_
${var}_SUPPORT
:= yes
199 .
else # otherwise, yes
200 MK_
${var}_SUPPORT
:= yes
205 .if
${MK_SPLIT_KERNEL_DEBUG} == "no"
206 MK_KERNEL_SYMBOLS
:= no
209 .if
${MK_CDDL} == "no"
213 # Some modules only compile successfully if option FDT is set, due to #ifdef FDT
214 # wrapped around declarations. Module makefiles can optionally compile such
215 # things using .if !empty(OPT_FDT)
216 .if
!defined
(OPT_FDT
) && defined
(KERNBUILDDIR
)
217 OPT_FDT
!= sed
-n
'/FDT/p' ${KERNBUILDDIR}/opt_platform.h