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