1 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. 6 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# These options are used by the kernel build process (kern.mk and kmod.mk) 18# They have to be listed here so we can build modules outside of the 19# src tree. 20 21.include <bsd.init.mk> 22 23KLDXREF_CMD?= kldxref 24 25__DEFAULT_YES_OPTIONS = \ 26 AUTOFS \ 27 BHYVE \ 28 BLUETOOTH \ 29 CCD \ 30 CDDL \ 31 CRYPT \ 32 CUSE \ 33 DTRACE \ 34 EFI \ 35 FORMAT_EXTENSIONS \ 36 INET \ 37 INET6 \ 38 IPFILTER \ 39 IPSEC_SUPPORT \ 40 ISCSI \ 41 KERNEL_SYMBOLS \ 42 NETGRAPH \ 43 OFED \ 44 PF \ 45 SCTP_SUPPORT \ 46 SOURCELESS_HOST \ 47 SOURCELESS_UCODE \ 48 SPLIT_KERNEL_DEBUG \ 49 TESTS \ 50 USB \ 51 USB_GADGET_EXAMPLES \ 52 ZFS 53 54__DEFAULT_NO_OPTIONS = \ 55 BHYVE_SNAPSHOT \ 56 KERNEL_BIN \ 57 KERNEL_RETPOLINE \ 58 RATELIMIT \ 59 REPRODUCIBLE_BUILD \ 60 REPRODUCIBLE_PATHS \ 61 VERIEXEC 62 63# Some options are totally broken on some architectures. We disable them. If you 64# need to enable them on an experimental basis, you must change this code. 65# Note: These only apply to the list of modules we build by default and 66# sometimes what is in the opt_*.h files by default. Kernel config files are 67# unaffected, though some targets can be affected by KERNEL_BIN, KERNEL_SYMBOLS, 68# FORMAT_EXTENSIONS, CTF and SSP. 69 70# Broken on 32-bit arm, kernel module compile errors 71.if ${MACHINE_CPUARCH} == "arm" 72BROKEN_OPTIONS+= OFED 73.endif 74 75# Things that don't work based on toolchain support. 76.if ${MACHINE} != "i386" && ${MACHINE} != "amd64" 77BROKEN_OPTIONS+= KERNEL_RETPOLINE 78.endif 79 80# EFI doesn't exist on powerpc and is broken on i386 81.if ${MACHINE:Mpowerpc} || ${MACHINE} == "i386" 82BROKEN_OPTIONS+=EFI 83.endif 84 85# We only generate kernel.bin on arm and arm64, otherwise they break the build. 86.if ${MACHINE} != "arm" && ${MACHINE} != "arm64" 87BROKEN_OPTIONS+=KERNEL_BIN 88.endif 89 90.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 91__DEFAULT_NO_OPTIONS += FDT 92.else 93__DEFAULT_YES_OPTIONS += FDT 94.endif 95 96__SINGLE_OPTIONS = \ 97 INIT_ALL 98 99__INIT_ALL_OPTIONS= none pattern zero 100__INIT_ALL_DEFAULT= none 101.if ${MACHINE} == "amd64" 102# PR251083 conflict between INIT_ALL_ZERO and ifunc memset 103BROKEN_SINGLE_OPTIONS+= INIT_ALL zero none 104.endif 105 106# expanded inline from bsd.mkopt.mk to avoid share/mk dependency 107 108# Those that default to yes 109.for var in ${__DEFAULT_YES_OPTIONS} 110.if !defined(MK_${var}) 111.if defined(WITHOUT_${var}) # WITHOUT always wins 112MK_${var}:= no 113.else 114MK_${var}:= yes 115.endif 116.else 117.if ${MK_${var}} != "yes" && ${MK_${var}} != "no" 118.error "Illegal value for MK_${var}: ${MK_${var}}" 119.endif 120.endif # !defined(MK_${var}) 121.endfor 122.undef __DEFAULT_YES_OPTIONS 123 124# Those that default to no 125.for var in ${__DEFAULT_NO_OPTIONS} 126.if !defined(MK_${var}) 127.if defined(WITH_${var}) && !defined(WITHOUT_${var}) # WITHOUT always wins 128MK_${var}:= yes 129.else 130MK_${var}:= no 131.endif 132.else 133.if ${MK_${var}} != "yes" && ${MK_${var}} != "no" 134.error "Illegal value for MK_${var}: ${MK_${var}}" 135.endif 136.endif # !defined(MK_${var}) 137.endfor 138.undef __DEFAULT_NO_OPTIONS 139 140# 141# MK_* options which are always no, usually because they are 142# unsupported/badly broken on this architecture. 143# 144.for var in ${BROKEN_OPTIONS} 145MK_${var}:= no 146.endfor 147.undef BROKEN_OPTIONS 148 149# 150# Group options set an OPT_FOO variable for each option. 151# 152.for opt in ${__SINGLE_OPTIONS} 153.if !defined(__${opt}_OPTIONS) || empty(__${opt}_OPTIONS) 154.error __${opt}_OPTIONS not defined or empty 155.endif 156.if !defined(__${opt}_DEFAULT) || empty(__${opt}_DEFAULT) 157.error __${opt}_DEFAULT undefined or empty 158.endif 159.if defined(${opt}) 160OPT_${opt}:= ${${opt}} 161.else 162OPT_${opt}:= ${__${opt}_DEFAULT} 163.endif 164.if empty(OPT_${opt}) || ${__${opt}_OPTIONS:M${OPT_${opt}}} != ${OPT_${opt}} 165.error Invalid option OPT_${opt} (${OPT_${opt}}), must be one of: ${__${opt}_OPTIONS} 166.endif 167.endfor 168.undef __SINGLE_OPTIONS 169 170.for opt val rep in ${BROKEN_SINGLE_OPTIONS} 171.if ${OPT_${opt}} == ${val} 172OPT_${opt}:= ${rep} 173.endif 174.endfor 175#end of bsd.mkopt.mk expanded inline. 176 177# 178# MK_*_SUPPORT options which default to "yes" unless their corresponding 179# MK_* variable is set to "no". 180# 181.for var in \ 182 INET \ 183 INET6 184.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no" 185MK_${var}_SUPPORT:= no 186.else 187.if defined(KERNBUILDDIR) # See if there's an opt_foo.h 188.if !defined(OPT_${var}) 189OPT_${var}!= cat ${KERNBUILDDIR}/opt_${var:tl}.h; echo 190.export OPT_${var} 191.endif 192.if ${OPT_${var}} == "" # nothing -> no 193MK_${var}_SUPPORT:= no 194.else 195MK_${var}_SUPPORT:= yes 196.endif 197.else # otherwise, yes 198MK_${var}_SUPPORT:= yes 199.endif 200.endif 201.endfor 202 203.if ${MK_SPLIT_KERNEL_DEBUG} == "no" 204MK_KERNEL_SYMBOLS:= no 205.endif 206 207.if ${MK_CDDL} == "no" 208MK_DTRACE:= no 209.endif 210 211.if ${MK_USB} == "no" 212MK_USB_GADGET_EXAMPLES:= no 213.endif 214 215# Some modules only compile successfully if option FDT is set, due to #ifdef FDT 216# wrapped around declarations. Module makefiles can optionally compile such 217# things using .if !empty(OPT_FDT) 218.if !defined(OPT_FDT) && defined(KERNBUILDDIR) 219OPT_FDT!= sed -n '/FDT/p' ${KERNBUILDDIR}/opt_platform.h 220.export OPT_FDT 221.if empty(OPT_FDT) 222MK_FDT:=no 223.else 224MK_FDT:=yes 225.endif 226.endif 227