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 defined(DEBUG) 27_MINUS_O= -O 28CTFFLAGS+= -g 29.else 30_MINUS_O= -O2 31.endif 32.if ${MACHINE_CPUARCH} == "amd64" 33COPTFLAGS?=-O2 -frename-registers -pipe 34.else 35COPTFLAGS?=${_MINUS_O} -pipe 36.endif 37.if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing) 38COPTFLAGS+= -fno-strict-aliasing 39.endif 40.if !defined(NO_CPU_COPTFLAGS) 41COPTFLAGS+= ${_CPUCFLAGS} 42.endif 43C_DIALECT= -std=c99 44NOSTDINC= -nostdinc 45 46INCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S 47 48# This hack lets us use the OpenBSD altq code without spamming a new 49# include path into contrib'ed source files. 50INCLUDES+= -I$S/contrib/altq 51 52.if make(depend) || make(kernel-depend) 53 54# ... and the same for ipfilter 55INCLUDES+= -I$S/contrib/ipfilter 56 57# ... and the same for pf 58INCLUDES+= -I$S/contrib/pf 59 60# ... and the same for ath 61INCLUDES+= -I$S/dev/ath -I$S/dev/ath/ath_hal 62 63# ... and the same for the NgATM stuff 64INCLUDES+= -I$S/contrib/ngatm 65 66# .. and the same for twa 67INCLUDES+= -I$S/dev/twa 68 69# ... and XFS 70INCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs 71 72# ... and the same for cxgb and cxgbe 73INCLUDES+= -I$S/dev/cxgb -I$S/dev/cxgbe 74 75.endif 76 77CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS} 78CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h 79.if ${CC:T:Mclang} != "clang" 80CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT} 81.if ${MACHINE_CPUARCH} != "mips" 82CFLAGS+= --param inline-unit-growth=100 83CFLAGS+= --param large-function-growth=1000 84.else 85# XXX Actually a gross hack just for Octeon because of the Simple Executive. 86CFLAGS+= --param inline-unit-growth=10000 87CFLAGS+= --param large-function-growth=100000 88CFLAGS+= --param max-inline-insns-single=10000 89.endif 90.endif 91WERROR?= -Werror 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 97CFLAGS+= -DGPROF -falign-functions=16 98.if ${PROFLEVEL} >= 2 99CFLAGS+= -DGPROF4 -DGUPROF 100PROF= -pg -mprofiler-epilogue 101.else 102PROF= -pg 103.endif 104.endif 105DEFINED_PROF= ${PROF} 106 107# Put configuration-specific C flags last (except for ${PROF}) so that they 108# can override the others. 109CFLAGS+= ${CONF_CFLAGS} 110 111# Optional linting. This can be overridden in /etc/make.conf. 112LINTFLAGS= ${LINTOBJKERNFLAGS} 113 114NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} 115NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC} 116PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC} 117NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 118 119NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \ 120 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c 121 122NORMAL_CTFCONVERT= [ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 123 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} 124 125NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} 126 127# Infiniband C flags. Correct include paths and omit errors that linux 128# does not honor. 129OFEDINCLUDES= -I$S/ofed/include/ 130OFEDNOERR= -Wno-cast-qual -Wno-pointer-arith -fms-extensions 131OFEDCFLAGS= ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR} 132OFED_C_NOIMP= ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF} 133OFED_C= ${OFED_C_NOIMP} ${.IMPSRC} 134 135GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/} 136SYSTEM_CFILES= config.c env.c hints.c vnode_if.c 137SYSTEM_DEP= Makefile ${SYSTEM_OBJS} 138SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS} 139SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o} 140SYSTEM_OBJS+= hack.So 141SYSTEM_CTFMERGE= [ -z "${CTFMERGE}" -o -n "${NO_CTF}" ] || ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJS} vers.o 142SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} \ 143 -warn-common -export-dynamic -dynamic-linker /red/herring \ 144 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 145SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ 146 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET} 147SYSTEM_DEP+= ${LDSCRIPT} 148 149# MKMODULESENV is set here so that port makefiles can augment 150# them. 151 152MKMODULESENV+= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 153MKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH} 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(WITHOUT_MODULES) 161MKMODULESENV+= WITHOUT_MODULES="${WITHOUT_MODULES}" 162.endif 163.if defined(DEBUG) 164MKMODULESENV+= DEBUG_FLAGS="${DEBUG}" 165.endif 166