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/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/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 ${MK_CLANG_IS_CC} == "no" && ${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 ${MK_CLANG_IS_CC} == "no" && ${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 ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang" 105CLANG_NO_IAS= -no-integrated-as 106.endif 107 108.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1 109CFLAGS+= -DGPROF -falign-functions=16 110.if ${PROFLEVEL} >= 2 111CFLAGS+= -DGPROF4 -DGUPROF 112PROF= -pg -mprofiler-epilogue 113.else 114PROF= -pg 115.endif 116.endif 117DEFINED_PROF= ${PROF} 118 119# Put configuration-specific C flags last (except for ${PROF}) so that they 120# can override the others. 121CFLAGS+= ${CONF_CFLAGS} 122 123# Optional linting. This can be overridden in /etc/make.conf. 124LINTFLAGS= ${LINTOBJKERNFLAGS} 125 126NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} 127NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC} 128PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC} 129NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC} 130 131NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \ 132 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c 133 134NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC} 135NORMAL_FWO= ${LD} -b binary --no-warn-mismatch -d -warn-common -r \ 136 -o ${.TARGET} ${.ALLSRC:M*.fw} 137 138# Special flags for managing the compat compiles for ZFS 139ZFS_CFLAGS= -DFREEBSD_NAMECACHE -DBUILDING_ZFS -nostdinc -I$S/cddl/compat/opensolaris -I$S/cddl/contrib/opensolaris/uts/common/fs/zfs -I$S/cddl/contrib/opensolaris/uts/common/zmod -I$S/cddl/contrib/opensolaris/uts/common -I$S -I$S/cddl/contrib/opensolaris/common/zfs -I$S/cddl/contrib/opensolaris/common ${CFLAGS} -Wno-unknown-pragmas -Wno-missing-prototypes -Wno-undef -Wno-strict-prototypes -Wno-cast-qual -Wno-parentheses -Wno-redundant-decls -Wno-missing-braces -Wno-uninitialized -Wno-unused -Wno-inline -Wno-switch -Wno-pointer-arith -Wno-unknown-pragmas 140ZFS_ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${ZFS_CFLAGS} 141ZFS_C= ${CC} -c ${ZFS_CFLAGS} ${WERROR} ${PROF} ${.IMPSRC} 142ZFS_S= ${CC} -c ${ZFS_ASM_CFLAGS} ${WERROR} ${.IMPSRC} 143 144.if ${MK_CTF} != "no" 145NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} 146.elif ${MAKE_VERSION} >= 5201111300 147NORMAL_CTFCONVERT= 148.else 149NORMAL_CTFCONVERT= @: 150.endif 151 152NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} 153 154# Infiniband C flags. Correct include paths and omit errors that linux 155# does not honor. 156OFEDINCLUDES= -I$S/ofed/include/ 157OFEDNOERR= -Wno-cast-qual -Wno-pointer-arith -fms-extensions 158OFEDCFLAGS= ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR} 159OFED_C_NOIMP= ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF} 160OFED_C= ${OFED_C_NOIMP} ${.IMPSRC} 161 162GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/} 163SYSTEM_CFILES= config.c env.c hints.c vnode_if.c 164SYSTEM_DEP= Makefile ${SYSTEM_OBJS} 165SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS} 166SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o} 167SYSTEM_OBJS+= hack.So 168SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} --no-warn-mismatch \ 169 -warn-common -export-dynamic -dynamic-linker /red/herring \ 170 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o 171SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ 172 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET} 173SYSTEM_DEP+= ${LDSCRIPT} 174 175# MKMODULESENV is set here so that port makefiles can augment 176# them. 177 178MKMODULESENV+= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 179MKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH} 180.if (${KERN_IDENT} == LINT) 181MKMODULESENV+= ALL_MODULES=LINT 182.endif 183.if defined(MODULES_OVERRIDE) 184MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" 185.endif 186.if defined(WITHOUT_MODULES) 187MKMODULESENV+= WITHOUT_MODULES="${WITHOUT_MODULES}" 188.endif 189.if defined(DEBUG) 190MKMODULESENV+= DEBUG_FLAGS="${DEBUG}" 191.endif 192