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