kern.pre.mk revision 131210
1239281Sgonzo# $FreeBSD: head/sys/conf/kern.pre.mk 131210 2004-06-27 23:03:43Z imp $ 2239281Sgonzo 3239281Sgonzo# Part of a unified Makefile for building kernels. This part contains all 4239281Sgonzo# of the definitions that need to be before %BEFORE_DEPEND. 5278727Sian 6239281Sgonzo# Can be overridden by makeoptions or /etc/make.conf 7239281SgonzoKERNEL_KO?= kernel 8239281SgonzoKERNEL?= kernel 9239281SgonzoKODIR?= /boot/${KERNEL} 10239281Sgonzo 11239281SgonzoM= ${MACHINE_ARCH} 12239281Sgonzo 13266277SianAWK?= awk 14239281SgonzoLINT?= lint 15239281SgonzoNM?= nm 16239281SgonzoOBJCOPY?= objcopy 17239281SgonzoSIZE?= size 18273625Srpaulo 19273625Srpaulo.if ${CC} == "icc" 20273625SrpauloCOPTFLAGS?=-O 21273624Srpaulo.else 22266338Sloos. if ${MACHINE_ARCH} == "amd64" 23239281SgonzoCOPTFLAGS?=-O2 -frename-registers -pipe 24239281Sgonzo. elif ${MACHINE_ARCH} == "ia64" 25239281SgonzoCOPTFLAGS?=-O2 -pipe 26254598Sian. elif ${MACHINE_ARCH} == "sparc64" 27239281SgonzoCOPTFLAGS?=-O2 -pipe 28239281Sgonzo. else 29COPTFLAGS?=-O -pipe 30. endif 31. if ${COPTFLAGS:M-O[23s]} != "" 32COPTFLAGS+= -fno-strict-aliasing 33. endif 34.endif 35.if !defined(NO_CPU_COPTFLAGS) 36. if ${CC} == "icc" 37COPTFLAGS+= ${_ICC_CPUCFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/} 38. else 39COPTFLAGS+= ${_CPUCFLAGS} 40. endif 41.endif 42.if ${CC} == "icc" 43NOSTDINC= -X 44.else 45NOSTDINC= -nostdinc 46.endif 47 48INCLUDES= ${NOSTDINC} -I- ${INCLMAGIC} -I. -I$S 49 50# This hack lets us use the Intel ACPICA code without spamming a new 51# include path into 100+ source files. 52INCLUDES+= -I$S/contrib/dev/acpica 53 54# ... and the same for altq 55INCLUDES+= -I$S/contrib/altq 56 57# ... and the same for ipfilter 58INCLUDES+= -I$S/contrib/ipfilter 59 60# ... and the same for pf 61INCLUDES+= -I$S/contrib/pf 62 63# ... and the same for Atheros HAL 64INCLUDES+= -I$S/contrib/dev/ath -I$S/contrib/dev/ath/freebsd 65 66# ... and the same for the NgATM stuff 67INCLUDES+= -I$S/contrib/ngatm 68 69COPTS= ${INCLUDES} -D_KERNEL -include opt_global.h 70CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} 71.if ${CC} != "icc" 72CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT} 73WERROR?= -Werror 74.endif 75 76# XXX LOCORE means "don't declare C stuff" not "for locore.s". 77ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 78 79.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1 80.if ${CC} == "icc" 81.error Profiling doesn't work with ICC yet. 82.else 83CFLAGS+= -DGPROF -falign-functions=16 84.endif 85.if ${PROFLEVEL} >= 2 86CFLAGS+= -DGPROF4 -DGUPROF 87. if ${CC} == "icc" 88# XXX doesn't work yet 89#PROF= -prof_gen 90. else 91PROF= -finstrument-functions 92. endif 93.else 94. if ${CC} == "icc" 95PROF= -p 96. else 97PROF= -pg 98. endif 99.endif 100.endif 101DEFINED_PROF= ${PROF} 102 103# Put configuration-specific C flags last (except for ${PROF}) so that they 104# can override the others. 105CFLAGS+= ${CONF_CFLAGS} 106 107# Optional linting. This can be overridden in /etc/make.conf. 108LINTFLAGS= ${LINTOBJKERNFLAGS} 109 110NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} 111NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC} 112PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC} 113NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 114 115NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \ 116 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c 117 118NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} 119 120GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/} 121SYSTEM_CFILES= config.c env.c hints.c majors.c vnode_if.c 122SYSTEM_DEP= Makefile ${SYSTEM_OBJS} 123SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS} 124SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o} 125SYSTEM_OBJS+= hack.So 126SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \ 127 -warn-common -export-dynamic -dynamic-linker /red/herring \ 128 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 129SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ 130 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET} 131SYSTEM_DEP+= $S/conf/ldscript.$M 132 133# MKMODULESENV is set here so that port makefiles can augment 134# them. 135 136MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 137.if (${KERN_IDENT} == LINT) 138MKMODULESENV+= ALL_MODULES=LINT 139.endif 140.if defined(MODULES_OVERRIDE) 141MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" 142.endif 143.if defined(DEBUG) 144MKMODULESENV+= DEBUG_FLAGS="${DEBUG}" 145.endif 146