3 # Part of a unified Makefile for building kernels. This part contains all
4 # of the definitions that need to be before %BEFORE_DEPEND.
8 # Can be overridden by makeoptions or /etc/make.conf
11 KODIR?= /boot/${KERNEL}
30 . if ${MACHINE_ARCH} == "amd64"
31 COPTFLAGS?=-O2 -frename-registers -pipe
33 COPTFLAGS?=${_MINUS_O} -pipe
35 . if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
36 COPTFLAGS+= -fno-strict-aliasing
39 .if !defined(NO_CPU_COPTFLAGS)
41 COPTFLAGS+= ${_ICC_CPUCFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
43 COPTFLAGS+= ${_CPUCFLAGS}
54 INCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S
56 # This hack lets us use the OpenBSD altq code without spamming a new
57 # include path into contrib'ed source files.
58 INCLUDES+= -I$S/contrib/altq
60 .if make(depend) || make(kernel-depend)
62 # ... and the same for ipfilter
63 INCLUDES+= -I$S/contrib/ipfilter
65 # ... and the same for pf
66 INCLUDES+= -I$S/contrib/pf
68 # ... and the same for ath
69 INCLUDES+= -I$S/dev/ath -I$S/dev/ath/ath_hal
71 # ... and the same for the NgATM stuff
72 INCLUDES+= -I$S/contrib/ngatm
74 # .. and the same for twa
75 INCLUDES+= -I$S/dev/twa
78 INCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs
81 INCLUDES+= -I$S/contrib/opensolaris/compat
85 CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS}
86 CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
88 CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
89 CFLAGS+= --param inline-unit-growth=100
90 CFLAGS+= --param large-function-growth=1000
91 .if ${MACHINE_ARCH} == "amd64" || ${MACHINE} == "i386" || \
92 ${MACHINE_ARCH} == "ia64" || ${MACHINE_ARCH} == "powerpc" || \
93 ${MACHINE_ARCH} == "sparc64"
98 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
99 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
101 .if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
103 .error "Profiling doesn't work with icc yet"
105 CFLAGS+= -DGPROF -falign-functions=16
106 .if ${PROFLEVEL} >= 2
107 CFLAGS+= -DGPROF4 -DGUPROF
108 PROF= -pg -mprofiler-epilogue
113 DEFINED_PROF= ${PROF}
115 # Put configuration-specific C flags last (except for ${PROF}) so that they
116 # can override the others.
117 CFLAGS+= ${CONF_CFLAGS}
119 # Optional linting. This can be overridden in /etc/make.conf.
120 LINTFLAGS= ${LINTOBJKERNFLAGS}
122 NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
123 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
124 PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
125 NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
127 NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
128 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
130 .if defined(CTFCONVERT)
131 NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
136 NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
138 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
139 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
140 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
141 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
142 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
143 SYSTEM_OBJS+= hack.So
144 .if defined(CTFMERGE)
145 SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJS} vers.o
148 SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
149 -warn-common -export-dynamic -dynamic-linker /red/herring \
150 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
151 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
152 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
153 SYSTEM_DEP+= $S/conf/ldscript.$M
155 # MKMODULESENV is set here so that port makefiles can augment
158 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
159 .if (${KERN_IDENT} == LINT)
160 MKMODULESENV+= ALL_MODULES=LINT
162 .if defined(MODULES_OVERRIDE)
163 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
166 MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"