kern.pre.mk revision 266349
185909Simp# $FreeBSD: head/sys/conf/kern.pre.mk 266349 2014-05-17 20:31:34Z imp $ 285909Simp 3122116Sbde# Part of a unified Makefile for building kernels. This part contains all 4122116Sbde# of the definitions that need to be before %BEFORE_DEPEND. 5122116Sbde 6266349Simp# Allow user to configure things that only effect src tree builds. 7266349Simp# Note: This is duplicated from src.sys.mk to ensure that we include 8266349Simp# /etc/src.conf when building the kernel. Kernels can be built without 9266349Simp# the rest of /usr/src, but they still always process SRCCONF even though 10266349Simp# the normal mechanisms to prevent that (compiling out of tree) won't 11266349Simp# work. To ensure they do work, we have to duplicate thee few lines here. 12266349SimpSRCCONF?= /etc/src.conf 13266349Simp.if (exists(${SRCCONF}) || ${SRCCONF} != "/etc/src.conf") && !target(_srcconf_included_) 14266349Simp.include "${SRCCONF}" 15266349Simp_srcconf_included_: 16266349Simp.endif 17266349Simp 18266349Simp.include <bsd.own.mk> 19240468Sbrooks.include <bsd.compiler.mk> 20265785Simp.include "kern.opts.mk" 21160440Sobrien 2285909Simp# Can be overridden by makeoptions or /etc/make.conf 2385909SimpKERNEL_KO?= kernel 2485909SimpKERNEL?= kernel 2585909SimpKODIR?= /boot/${KERNEL} 26175888SimpLDSCRIPT_NAME?= ldscript.$M 27175888SimpLDSCRIPT?= $S/conf/${LDSCRIPT_NAME} 2885909Simp 29218538SimpM= ${MACHINE_CPUARCH} 3085909Simp 3191512SobrienAWK?= awk 32240451SnpCP?= cp 33116341SmarkmLINT?= lint 3485909SimpNM?= nm 3585909SimpOBJCOPY?= objcopy 3685909SimpSIZE?= size 3785909Simp 38220863Sdim.if defined(DEBUG) 39140606Sobrien_MINUS_O= -O 40187103SgnnCTFFLAGS+= -g 41220863Sdim.else 42224882Snwhitehorn.if ${MACHINE_CPUARCH} == "powerpc" 43224882Snwhitehorn_MINUS_O= -O # gcc miscompiles some code at -O2 44224882Snwhitehorn.else 45140606Sobrien_MINUS_O= -O2 46220863Sdim.endif 47224882Snwhitehorn.endif 48220863Sdim.if ${MACHINE_CPUARCH} == "amd64" 49265832Simp.if ${COMPILER_TYPE} == "clang" 50265832SimpCOPTFLAGS?=-O2 -pipe 51265832Simp.else 52127204SobrienCOPTFLAGS?=-O2 -frename-registers -pipe 53228868Sdim.endif 54228868Sdim.else 55140606SobrienCOPTFLAGS?=${_MINUS_O} -pipe 56220863Sdim.endif 57220863Sdim.if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing) 58124834SruCOPTFLAGS+= -fno-strict-aliasing 59124834Sru.endif 6085909Simp.if !defined(NO_CPU_COPTFLAGS) 6185909SimpCOPTFLAGS+= ${_CPUCFLAGS} 6285909Simp.endif 63160043SobrienC_DIALECT= -std=c99 64126890StrhodesNOSTDINC= -nostdinc 6585909Simp 66192901SthompsaINCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S 67126890Strhodes 68151605Sobrien# This hack lets us use the OpenBSD altq code without spamming a new 69151605Sobrien# include path into contrib'ed source files. 70130416SmlaierINCLUDES+= -I$S/contrib/altq 71130416Smlaier 72149978Sobrien.if make(depend) || make(kernel-depend) 73149978Sobrien 74149978Sobrien# ... and the same for ipfilter 75149978SobrienINCLUDES+= -I$S/contrib/ipfilter 76149978Sobrien 77185522Ssam# ... and the same for ath 78250173SadrianINCLUDES+= -I$S/dev/ath -I$S/dev/ath/ath_hal -I$S/contrib/dev/ath/ath_hal 79149978Sobrien 80149978Sobrien# ... and the same for the NgATM stuff 81149978SobrienINCLUDES+= -I$S/contrib/ngatm 82149978Sobrien 83229353Sgjb# ... and the same for twa 84149978SobrienINCLUDES+= -I$S/dev/twa 85149978Sobrien 86218792Snp# ... and the same for cxgb and cxgbe 87218792SnpINCLUDES+= -I$S/dev/cxgb -I$S/dev/cxgbe 88183292Skmacy 89149978Sobrien.endif 90149978Sobrien 91160043SobrienCFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS} 92150966SglebiusCFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h 93257735SimpCFLAGS_PARAM_INLINE_UNIT_GROWTH?=100 94257735SimpCFLAGS_PARAM_LARGE_FUNCTION_GROWTH?=1000 95257735Simp.if ${MACHINE_CPUARCH} == "mips" 96257735SimpCFLAGS_ARCH_PARAMS?=--param max-inline-insns-single=1000 97257735Simp.endif 98265832SimpCFLAGS.gcc+= -fno-common -finline-limit=${INLINE_LIMIT} 99265832SimpCFLAGS.gcc+= --param inline-unit-growth=${CFLAGS_PARAM_INLINE_UNIT_GROWTH} 100265832SimpCFLAGS.gcc+= --param large-function-growth=${CFLAGS_PARAM_LARGE_FUNCTION_GROWTH} 101257735Simp.if defined(CFLAGS_ARCH_PARAMS) 102265832SimpCFLAGS.gcc+=${CFLAGS_ARCH_PARAMS} 103210311Sjmallett.endif 104171239SpeterWERROR?= -Werror 10585909Simp 10685909Simp# XXX LOCORE means "don't declare C stuff" not "for locore.s". 10785909SimpASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 10885909Simp 109240468Sbrooks.if ${COMPILER_TYPE} == "clang" 110232263SdimCLANG_NO_IAS= -no-integrated-as 111260102Sdim.else 112260102SdimGCC_MS_EXTENSIONS= -fms-extensions 113232263Sdim.endif 114232263Sdim 11599923Sbde.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1 116242715SdimCFLAGS+= -DGPROF 117265832SimpCFLAGS.gcc+= -falign-functions=16 11899932Sbde.if ${PROFLEVEL} >= 2 11999932SbdeCFLAGS+= -DGPROF4 -DGUPROF 120242717SdimPROF= -pg 121265832Simp.if ${COMPILER_TYPE} == "gcc" 122242717SdimPROF+= -mprofiler-epilogue 123242717Sdim.endif 12499932Sbde.else 125242717SdimPROF= -pg 12699923Sbde.endif 12799932Sbde.endif 12885909SimpDEFINED_PROF= ${PROF} 12991002Speter 13085909Simp# Put configuration-specific C flags last (except for ${PROF}) so that they 13185909Simp# can override the others. 13285909SimpCFLAGS+= ${CONF_CFLAGS} 13385909Simp 134116341Smarkm# Optional linting. This can be overridden in /etc/make.conf. 135116341SmarkmLINTFLAGS= ${LINTOBJKERNFLAGS} 136116341Smarkm 13791002SpeterNORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} 13891002SpeterNORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC} 13991002SpeterPROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC} 140105489SmuxNORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 14185909Simp 142105462SmuxNORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \ 143105462Smux ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c 14485909Simp 145239956SjhbNORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC} 146239957SjhbNORMAL_FWO= ${LD} -b binary --no-warn-mismatch -d -warn-common -r \ 147239957Sjhb -o ${.TARGET} ${.ALLSRC:M*.fw} 148239955Sjhb 149233578Speter# Special flags for managing the compat compiles for ZFS 150233578SpeterZFS_CFLAGS= -DFREEBSD_NAMECACHE -DBUILDING_ZFS -nostdinc -I$S/cddl/compat/opensolaris -I$S/cddl/contrib/opensolaris/uts/common/fs/zfs -I$S/cddl/contrib/opensolaris/uts/common/zmod -I$S/cddl/contrib/opensolaris/uts/common -I$S -I$S/cddl/contrib/opensolaris/common/zfs -I$S/cddl/contrib/opensolaris/common ${CFLAGS} -Wno-unknown-pragmas -Wno-missing-prototypes -Wno-undef -Wno-strict-prototypes -Wno-cast-qual -Wno-parentheses -Wno-redundant-decls -Wno-missing-braces -Wno-uninitialized -Wno-unused -Wno-inline -Wno-switch -Wno-pointer-arith -Wno-unknown-pragmas 151253996SavgZFS_CFLAGS+= -include $S/cddl/compat/opensolaris/sys/debug_compat.h 152233578SpeterZFS_ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${ZFS_CFLAGS} 153233578SpeterZFS_C= ${CC} -c ${ZFS_CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} 154233578SpeterZFS_S= ${CC} -c ${ZFS_ASM_CFLAGS} ${WERROR} ${.IMPSRC} 155233578Speter 156228158Sfjoe.if ${MK_CTF} != "no" 157228140SfjoeNORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} 158228158Sfjoe.elif ${MAKE_VERSION} >= 5201111300 159228158SfjoeNORMAL_CTFCONVERT= 160228124Sfjoe.else 161228158SfjoeNORMAL_CTFCONVERT= @: 162228124Sfjoe.endif 163179226Sjb 164116341SmarkmNORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} 165116341Smarkm 166219819Sjeff# Infiniband C flags. Correct include paths and omit errors that linux 167219819Sjeff# does not honor. 168219819SjeffOFEDINCLUDES= -I$S/ofed/include/ 169260102SdimOFEDNOERR= -Wno-cast-qual -Wno-pointer-arith ${GCC_MS_EXTENSIONS} 170219819SjeffOFEDCFLAGS= ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR} 171219819SjeffOFED_C_NOIMP= ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF} 172219819SjeffOFED_C= ${OFED_C_NOIMP} ${.IMPSRC} 173219819Sjeff 174131210SimpGEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/} 175144293SphkSYSTEM_CFILES= config.c env.c hints.c vnode_if.c 17685909SimpSYSTEM_DEP= Makefile ${SYSTEM_OBJS} 177111684SruSYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS} 178111684SruSYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o} 179111684SruSYSTEM_OBJS+= hack.So 180243664SmarcelSYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} ${LDFLAGS} --no-warn-mismatch \ 18189180Smsmith -warn-common -export-dynamic -dynamic-linker /red/herring \ 18285909Simp -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 18385909SimpSYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ 184123966Sbde ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET} 185175888SimpSYSTEM_DEP+= ${LDSCRIPT} 18685909Simp 18788893Simp# MKMODULESENV is set here so that port makefiles can augment 18888893Simp# them. 18988893Simp 190221265SbzMKMODULESENV+= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 191210151SimpMKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH} 192261460SimpMKMODULESENV+= MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} 19390789Sphk.if (${KERN_IDENT} == LINT) 19490789SphkMKMODULESENV+= ALL_MODULES=LINT 19590789Sphk.endif 19688893Simp.if defined(MODULES_OVERRIDE) 19788893SimpMKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" 19888893Simp.endif 199216746Scperciva.if defined(WITHOUT_MODULES) 200216746ScpercivaMKMODULESENV+= WITHOUT_MODULES="${WITHOUT_MODULES}" 201216746Scperciva.endif 20288893Simp.if defined(DEBUG) 203125772SruMKMODULESENV+= DEBUG_FLAGS="${DEBUG}" 20488893Simp.endif 205240402Sobrien 206258753Sandreast# Detect kernel config options that force stack frames to be turned on. 207240402SobrienDDB_ENABLED!= grep DDB opt_ddb.h || true ; echo 208240402SobrienDTR_ENABLED!= grep KDTRACE_FRAME opt_kdtrace.h || true ; echo 209240402SobrienHWPMC_ENABLED!= grep HWPMC opt_hwpmc_hooks.h || true ; echo 210