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