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. elif ${MACHINE_ARCH} == "ia64" 25COPTFLAGS?=-O2 -pipe 26. elif ${MACHINE_ARCH} == "sparc64" 27COPTFLAGS?=-O2 -pipe 28. 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 69CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} 70CFLAGS+= ${INCLUDES} -D_KERNEL -include opt_global.h 71.if ${CC} != "icc" 72CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT} 73CFLAGS+= --param inline-unit-growth=100 74CFLAGS+= --param large-function-growth=1000 75WERROR?= -Werror 76.endif 77 78# XXX LOCORE means "don't declare C stuff" not "for locore.s". 79ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 80 81.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1 82.if ${CC} == "icc" 83.error Profiling doesn't work with ICC yet. 84.else 85CFLAGS+= -DGPROF -falign-functions=16 86.endif 87.if ${PROFLEVEL} >= 2 88CFLAGS+= -DGPROF4 -DGUPROF 89. if ${CC} == "icc" 90# XXX doesn't work yet 91#PROF= -prof_gen 92. else 93PROF= -finstrument-functions -Wno-inline 94. endif 95.else 96. if ${CC} == "icc" 97PROF= -p 98. else 99PROF= -pg 100. endif 101.endif 102.endif 103DEFINED_PROF= ${PROF} 104 105# Put configuration-specific C flags last (except for ${PROF}) so that they 106# can override the others. 107CFLAGS+= ${CONF_CFLAGS} 108 109# Optional linting. This can be overridden in /etc/make.conf. 110LINTFLAGS= ${LINTOBJKERNFLAGS} 111 112NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} 113NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC} 114PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC} 115NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 116 117NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \ 118 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c 119 120NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} 121 122GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/} 123SYSTEM_CFILES= config.c env.c hints.c majors.c vnode_if.c 124SYSTEM_DEP= Makefile ${SYSTEM_OBJS} 125SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS} 126SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o} 127SYSTEM_OBJS+= hack.So 128SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \ 129 -warn-common -export-dynamic -dynamic-linker /red/herring \ 130 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 131SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ 132 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET} 133SYSTEM_DEP+= $S/conf/ldscript.$M 134 135# MKMODULESENV is set here so that port makefiles can augment 136# them. 137 138MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 139.if (${KERN_IDENT} == LINT) 140MKMODULESENV+= ALL_MODULES=LINT 141.endif 142.if defined(MODULES_OVERRIDE) 143MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" 144.endif 145.if defined(DEBUG) 146MKMODULESENV+= DEBUG_FLAGS="${DEBUG}" 147.endif 148