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