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# Can be overridden by makeoptions or /etc/make.conf 7KERNEL_KO?= kernel 8KERNEL?= kernel 9KODIR?= /boot/${KERNEL} 10 11M= ${MACHINE_ARCH} 12 13AWK?= awk 14LINT?= lint 15NM?= nm 16OBJCOPY?= objcopy 17SIZE?= size 18 19.if ${CC} == "icc" 20COPTFLAGS?= -O 21.else 22. if defined(DEBUG) 23_MINUS_O= -O 24. else 25_MINUS_O= -O2 26. endif 27. if ${MACHINE_ARCH} == "amd64" 28COPTFLAGS?=-O2 -frename-registers -pipe 29. else 30COPTFLAGS?=${_MINUS_O} -pipe 31. endif 32. if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing) 33COPTFLAGS+= -fno-strict-aliasing 34. endif 35.endif 36.if !defined(NO_CPU_COPTFLAGS) 37. if ${CC} == "icc" 38COPTFLAGS+= ${_ICC_CPUCFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/} 39. else 40COPTFLAGS+= ${_CPUCFLAGS} 41. endif 42.endif 43.if ${CC} == "icc" 44NOSTDINC= -X 45.else 46NOSTDINC= -nostdinc 47.endif 48 49INCLUDES= ${NOSTDINC} -I- ${INCLMAGIC} -I. -I$S 50 51# This hack lets us use the OpenBSD altq code without spamming a new 52# include path into contrib'ed source files. 53INCLUDES+= -I$S/contrib/altq 54 55# ... and the same for Atheros HAL when the author builds it from 56# non-distributable sources. 57.if defined(ATH_BUILDING_FROM_SOURCE) 58INCLUDES+= -I$S/contrib/dev/ath 59.endif 60 61.if make(depend) || make(kernel-depend) 62 63# ... and the same for ipfilter 64INCLUDES+= -I$S/contrib/ipfilter 65 66# ... and the same for pf 67INCLUDES+= -I$S/contrib/pf 68 69# ... and the same for Atheros HAL 70INCLUDES+= -I$S/contrib/dev/ath/freebsd 71 72# ... and the same for the NgATM stuff 73INCLUDES+= -I$S/contrib/ngatm 74 75# .. and the same for twa 76INCLUDES+= -I$S/dev/twa 77 78# ... and XFS 79INCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs 80 81.endif 82 83CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} 84CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h 85.if ${CC} != "icc" 86CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT} 87CFLAGS+= --param inline-unit-growth=100 88CFLAGS+= --param large-function-growth=1000 89WERROR?= -Werror 90.endif 91 92# XXX LOCORE means "don't declare C stuff" not "for locore.s". 93ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} 94 95.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1 96.if ${CC} == "icc" 97.error Profiling doesn't work with ICC yet. 98.else 99CFLAGS+= -DGPROF -falign-functions=16 100.endif 101.if ${PROFLEVEL} >= 2 102CFLAGS+= -DGPROF4 -DGUPROF 103. if ${CC} == "icc" 104# XXX doesn't work yet 105#PROF= -prof_gen 106. else 107PROF= -finstrument-functions -Wno-inline 108. endif 109.else 110. if ${CC} == "icc" 111PROF= -p 112. else 113PROF= -pg 114. endif 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_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} 135 136GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/} 137SYSTEM_CFILES= config.c env.c hints.c vnode_if.c 138SYSTEM_DEP= Makefile ${SYSTEM_OBJS} 139SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS} 140SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o} 141SYSTEM_OBJS+= hack.So 142SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \ 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+= $S/conf/ldscript.$M 148 149# MKMODULESENV is set here so that port makefiles can augment 150# them. 151 152MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 153.if (${KERN_IDENT} == LINT) 154MKMODULESENV+= ALL_MODULES=LINT 155.endif 156.if defined(MODULES_OVERRIDE) 157MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" 158.endif 159.if defined(DEBUG) 160MKMODULESENV+= DEBUG_FLAGS="${DEBUG}" 161.endif 162