kern.pre.mk revision 210394
11556Srgrimes# $FreeBSD: head/sys/conf/kern.pre.mk 210394 2010-07-22 21:31:35Z rpaulo $ 21556Srgrimes 31556Srgrimes# Part of a unified Makefile for building kernels. This part contains all 41556Srgrimes# of the definitions that need to be before %BEFORE_DEPEND. 51556Srgrimes 61556Srgrimes.include <bsd.own.mk> 71556Srgrimes 81556Srgrimes# backwards compat option for older systems. 91556SrgrimesMACHINE_CPUARCH?=${MACHINE_ARCH:C/mipse[lb]/mips/:C/armeb/arm/:C/powerpc64/powerpc/} 101556Srgrimes 111556Srgrimes# Can be overridden by makeoptions or /etc/make.conf 121556SrgrimesKERNEL_KO?= kernel 131556SrgrimesKERNEL?= kernel 141556SrgrimesKODIR?= /boot/${KERNEL} 151556SrgrimesLDSCRIPT_NAME?= ldscript.$M 161556SrgrimesLDSCRIPT?= $S/conf/${LDSCRIPT_NAME} 171556Srgrimes 181556SrgrimesM= ${MACHINE_CPUARCH} 191556Srgrimes 201556SrgrimesAWK?= awk 211556SrgrimesLINT?= lint 221556SrgrimesNM?= nm 231556SrgrimesOBJCOPY?= objcopy 241556SrgrimesSIZE?= size 251556Srgrimes 261556Srgrimes.if ${CC} == "icc" 271556SrgrimesCOPTFLAGS?= -O 281556Srgrimes.else 291556Srgrimes. if defined(DEBUG) 301556Srgrimes_MINUS_O= -O 311556SrgrimesCTFFLAGS+= -g 3217987Speter. else 3350471Speter_MINUS_O= -O2 341556Srgrimes. endif 351556Srgrimes. if ${MACHINE_ARCH} == "amd64" 36111422SmarcelCOPTFLAGS?=-O2 -frename-registers -pipe 3717987Speter. else 38196483SjillesCOPTFLAGS?=${_MINUS_O} -pipe 391556Srgrimes. endif 401556Srgrimes. if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing) 411556SrgrimesCOPTFLAGS+= -fno-strict-aliasing 421556Srgrimes. endif 431556Srgrimes.endif 441556Srgrimes.if !defined(NO_CPU_COPTFLAGS) 451556Srgrimes. if ${CC} == "icc" 461556SrgrimesCOPTFLAGS+= ${_ICC_CPUCFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/} 471556Srgrimes. else 481556SrgrimesCOPTFLAGS+= ${_CPUCFLAGS} 49117261Sdds. endif 50117261Sdds.endif 51117261Sdds.if ${CC} == "icc" 52117261SddsC_DIALECT= 531556SrgrimesNOSTDINC= -X 541556Srgrimes.else 551556SrgrimesC_DIALECT= -std=c99 561556SrgrimesNOSTDINC= -nostdinc 5790111Simp.endif 5890111Simp 5990111SimpINCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S 6090111Simp 6190111Simp# This hack lets us use the OpenBSD altq code without spamming a new 621556Srgrimes# include path into contrib'ed source files. 631556SrgrimesINCLUDES+= -I$S/contrib/altq 641556Srgrimes 651556Srgrimes.if make(depend) || make(kernel-depend) 661556Srgrimes 671556Srgrimes# ... and the same for ipfilter 681556SrgrimesINCLUDES+= -I$S/contrib/ipfilter 69196483Sjilles 7090111Simp# ... and the same for pf 7117987SpeterINCLUDES+= -I$S/contrib/pf 72196483Sjilles 73196483Sjilles# ... and the same for ath 7417987SpeterINCLUDES+= -I$S/dev/ath -I$S/dev/ath/ath_hal 7517987Speter 76196483Sjilles# ... and the same for the NgATM stuff 7717987SpeterINCLUDES+= -I$S/contrib/ngatm 7817987Speter 79196483Sjilles# .. and the same for twa 80196483SjillesINCLUDES+= -I$S/dev/twa 81196483Sjilles 82196483Sjilles# ... and XFS 83196483SjillesINCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs 84196483Sjilles 851556Srgrimes# ... and OpenSolaris 861556SrgrimesINCLUDES+= -I$S/contrib/opensolaris/compat 871556Srgrimes 881556Srgrimes# ... and the same for cxgb 891556SrgrimesINCLUDES+= -I$S/dev/cxgb 9090111Simp 9117987Speter.endif 9217987Speter 931556SrgrimesCFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS} 941556SrgrimesCFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h 951556Srgrimes.if ${CC} != "icc" 961556Srgrimes.if ${CC} != "clang" 971556SrgrimesCFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT} 9890111Simp.if ${MACHINE_CPUARCH} != "mips" 9917987SpeterCFLAGS+= --param inline-unit-growth=100 10017987SpeterCFLAGS+= --param large-function-growth=1000 10117987Speter.else 10217987Speter# XXX Actually a gross hack just for Octeon because of the Simple Executive. 10317987SpeterCFLAGS+= --param inline-unit-growth=1000 10417987SpeterCFLAGS+= --param large-function-growth=100000 1051556Srgrimes.endif 1061556Srgrimes.endif 1071556SrgrimesWERROR?= -Werror 1081556Srgrimes.endif 1091556Srgrimes 11090111Simp# XXX LOCORE means "don't declare C stuff" not "for locore.s". 11117987SpeterASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 11217987Speter 1131556Srgrimes.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1 11417987Speter.if ${CC} == "icc" || ${CC} == "clang" 11517987Speter.error "Profiling doesn't work with icc or clang yet" 1161556Srgrimes.endif 1171556SrgrimesCFLAGS+= -DGPROF -falign-functions=16 1181556Srgrimes.if ${PROFLEVEL} >= 2 1191556SrgrimesCFLAGS+= -DGPROF4 -DGUPROF 12090111SimpPROF= -pg -mprofiler-epilogue 12117987Speter.else 12217987SpeterPROF= -pg 12317987Speter.endif 1241556Srgrimes.endif 12517987SpeterDEFINED_PROF= ${PROF} 12617987Speter 12717987Speter# Put configuration-specific C flags last (except for ${PROF}) so that they 12825226Ssteve# can override the others. 12917987SpeterCFLAGS+= ${CONF_CFLAGS} 13017987Speter 13117987Speter# Optional linting. This can be overridden in /etc/make.conf. 13217987SpeterLINTFLAGS= ${LINTOBJKERNFLAGS} 13317987Speter 13417987SpeterNORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} 1351556SrgrimesNORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC} 1361556SrgrimesPROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC} 1371556SrgrimesNORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 1381556Srgrimes 1391556SrgrimesNORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \ 14090111Simp ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c 14117987Speter 14225226SsteveNORMAL_CTFCONVERT= [ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 14325226Ssteve ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} 14417987Speter 1451556SrgrimesNORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} 14617987Speter 14717987SpeterGEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/} 14817987SpeterSYSTEM_CFILES= config.c env.c hints.c vnode_if.c 14917987SpeterSYSTEM_DEP= Makefile ${SYSTEM_OBJS} 1501556SrgrimesSYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS} 1511556SrgrimesSYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o} 1521556SrgrimesSYSTEM_OBJS+= hack.So 153196483SjillesSYSTEM_CTFMERGE= [ -z "${CTFMERGE}" -o -n "${NO_CTF}" ] || ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJS} vers.o 154196483SjillesSYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} \ 155196483Sjilles -warn-common -export-dynamic -dynamic-linker /red/herring \ 156196483Sjilles -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 157196483SjillesSYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ 1581556Srgrimes ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET} 159196483SjillesSYSTEM_DEP+= ${LDSCRIPT} 1601556Srgrimes 161196483Sjilles# MKMODULESENV is set here so that port makefiles can augment 162196483Sjilles# them. 1631556Srgrimes 1641556SrgrimesMKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 1651556SrgrimesMKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH} 166196483Sjilles.if (${KERN_IDENT} == LINT) 16717987SpeterMKMODULESENV+= ALL_MODULES=LINT 168196483Sjilles.endif 169196483Sjilles.if defined(MODULES_OVERRIDE) 170196483SjillesMKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" 171196483Sjilles.endif 172196483Sjilles.if defined(DEBUG) 173196483SjillesMKMODULESENV+= DEBUG_FLAGS="${DEBUG}" 1741556Srgrimes.endif 175