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_GADGET_EXAMPLES \ 51 ZFS 52 53__DEFAULT_NO_OPTIONS = \ 54 BHYVE_SNAPSHOT \ 55 KERNEL_BIN \ 56 KERNEL_RETPOLINE \ 57 RATELIMIT \ 58 REPRODUCIBLE_BUILD \ 59 VERIEXEC 60 61# Some options are totally broken on some architectures. We disable them. If you 62# need to enable them on an experimental basis, you must change this code. 63# Note: These only apply to the list of modules we build by default and 64# sometimes what is in the opt_*.h files by default. Kernel config files are 65# unaffected, though some targets can be affected by KERNEL_BIN, KERNEL_SYMBOLS, 66# FORMAT_EXTENSIONS, CTF and SSP. 67 68# Broken on 32-bit arm, kernel module compile errors 69.if ${MACHINE_CPUARCH} == "arm" 70BROKEN_OPTIONS+= OFED 71.endif 72 73# Things that don't work based on toolchain support. 74.if ${MACHINE} != "i386" && ${MACHINE} != "amd64" 75BROKEN_OPTIONS+= KERNEL_RETPOLINE 76.endif 77 78# EFI doesn't exist on powerpc and is broken on i386 79.if ${MACHINE:Mpowerpc} || ${MACHINE} == "i386" 80BROKEN_OPTIONS+=EFI 81.endif 82 83# We only generate kernel.bin on arm and arm64, otherwise they break the build. 84.if ${MACHINE} != "arm" && ${MACHINE} != "arm64" 85BROKEN_OPTIONS+=KERNEL_BIN 86.endif 87 88.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 89__DEFAULT_NO_OPTIONS += FDT 90.else 91__DEFAULT_YES_OPTIONS += FDT 92.endif 93 94__SINGLE_OPTIONS = \ 95 INIT_ALL 96 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 101BROKEN_SINGLE_OPTIONS+= INIT_ALL zero none 102.endif 103 104# expanded inline from bsd.mkopt.mk to avoid share/mk dependency 105 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 110MK_${var}:= no 111.else 112MK_${var}:= yes 113.endif 114.else 115.if ${MK_${var}} != "yes" && ${MK_${var}} != "no" 116.error "Illegal value for MK_${var}: ${MK_${var}}" 117.endif 118.endif # !defined(MK_${var}) 119.endfor 120.undef __DEFAULT_YES_OPTIONS 121 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 126MK_${var}:= yes 127.else 128MK_${var}:= no 129.endif 130.else 131.if ${MK_${var}} != "yes" && ${MK_${var}} != "no" 132.error "Illegal value for MK_${var}: ${MK_${var}}" 133.endif 134.endif # !defined(MK_${var}) 135.endfor 136.undef __DEFAULT_NO_OPTIONS 137 138# 139# MK_* options which are always no, usually because they are 140# unsupported/badly broken on this architecture. 141# 142.for var in ${BROKEN_OPTIONS} 143MK_${var}:= no 144.endfor 145.undef BROKEN_OPTIONS 146 147# 148# Group options set an OPT_FOO variable for each option. 149# 150.for opt in ${__SINGLE_OPTIONS} 151.if !defined(__${opt}_OPTIONS) || empty(__${opt}_OPTIONS) 152.error __${opt}_OPTIONS not defined or empty 153.endif 154.if !defined(__${opt}_DEFAULT) || empty(__${opt}_DEFAULT) 155.error __${opt}_DEFAULT undefined or empty 156.endif 157.if defined(${opt}) 158OPT_${opt}:= ${${opt}} 159.else 160OPT_${opt}:= ${__${opt}_DEFAULT} 161.endif 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} 164.endif 165.endfor 166.undef __SINGLE_OPTIONS 167 168.for opt val rep in ${BROKEN_SINGLE_OPTIONS} 169.if ${OPT_${opt}} == ${val} 170OPT_${opt}:= ${rep} 171.endif 172.endfor 173#end of bsd.mkopt.mk expanded inline. 174 175# 176# MK_*_SUPPORT options which default to "yes" unless their corresponding 177# MK_* variable is set to "no". 178# 179.for var in \ 180 INET \ 181 INET6 182.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no" 183MK_${var}_SUPPORT:= no 184.else 185.if defined(KERNBUILDDIR) # See if there's an opt_foo.h 186.if !defined(OPT_${var}) 187OPT_${var}!= cat ${KERNBUILDDIR}/opt_${var:tl}.h; echo 188.export OPT_${var} 189.endif 190.if ${OPT_${var}} == "" # nothing -> no 191MK_${var}_SUPPORT:= no 192.else 193MK_${var}_SUPPORT:= yes 194.endif 195.else # otherwise, yes 196MK_${var}_SUPPORT:= yes 197.endif 198.endif 199.endfor 200 201.if ${MK_SPLIT_KERNEL_DEBUG} == "no" 202MK_KERNEL_SYMBOLS:= no 203.endif 204 205.if ${MK_CDDL} == "no" 206MK_DTRACE:= no 207.endif 208 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) 213OPT_FDT!= sed -n '/FDT/p' ${KERNBUILDDIR}/opt_platform.h 214.export OPT_FDT 215.if empty(OPT_FDT) 216MK_FDT:=no 217.else 218MK_FDT:=yes 219.endif 220.endif 221