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