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