3 # Part of a unified Makefile for building kernels. This part contains all
4 # of the definitions that need to be before %BEFORE_DEPEND.
6 # Can be overridden by makeoptions or /etc/make.conf
9 KODIR?= /boot/${KERNEL}
27 . if ${MACHINE_ARCH} == "amd64"
28 COPTFLAGS?=-O2 -frename-registers -pipe
30 COPTFLAGS?=${_MINUS_O} -pipe
32 . if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
33 COPTFLAGS+= -fno-strict-aliasing
36 .if !defined(NO_CPU_COPTFLAGS)
38 COPTFLAGS+= ${_ICC_CPUCFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
40 COPTFLAGS+= ${_CPUCFLAGS}
49 INCLUDES= ${NOSTDINC} -I- ${INCLMAGIC} -I. -I$S
51 # This hack lets us use the OpenBSD altq code without spamming a new
52 # include path into contrib'ed source files.
53 INCLUDES+= -I$S/contrib/altq
55 # ... and the same for ipfilter
56 INCLUDES+= -I$S/contrib/ipfilter
58 # ... and the same for pf
59 INCLUDES+= -I$S/contrib/pf
61 # ... and the same for Atheros HAL
62 INCLUDES+= -I$S/dev/ath
64 # ... and the same for the NgATM stuff
65 INCLUDES+= -I$S/contrib/ngatm
67 # .. and the same for twa
68 INCLUDES+= -I$S/dev/twa
70 # .. and the same for em
71 INCLUDES+= -I$S/dev/em
73 INCLUDES+= -I$S/xen/interface -I$S/xen/interface/io
76 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG}
77 CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
79 CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
80 CFLAGS+= --param inline-unit-growth=100
81 CFLAGS+= --param large-function-growth=1000
85 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
86 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
88 .if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
90 .error "Profiling doesn't work with icc yet"
92 CFLAGS+= -DGPROF -falign-functions=16
94 CFLAGS+= -DGPROF4 -DGUPROF
95 PROF= -pg -mprofiler-epilogue
100 DEFINED_PROF= ${PROF}
102 # Put configuration-specific C flags last (except for ${PROF}) so that they
103 # can override the others.
104 CFLAGS+= ${CONF_CFLAGS}
106 # Optional linting. This can be overridden in /etc/make.conf.
107 LINTFLAGS= ${LINTOBJKERNFLAGS}
109 NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
110 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
111 PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
112 NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
114 NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
115 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
117 NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
119 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
120 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
121 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
122 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
123 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
124 SYSTEM_OBJS+= hack.So
125 SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
126 -warn-common -export-dynamic -dynamic-linker /red/herring \
127 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
128 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
129 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
130 SYSTEM_DEP+= $S/conf/ldscript.$M
132 # MKMODULESENV is set here so that port makefiles can augment
135 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
136 .if (${KERN_IDENT} == LINT)
137 MKMODULESENV+= ALL_MODULES=LINT
139 .if defined(MODULES_OVERRIDE)
140 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
143 MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"