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