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