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 SRCCONF?= /etc/src.conf
11 # Can be overridden by makeoptions or /etc/make.conf
14 KODIR?= /boot/${KERNEL}
32 . if ${MACHINE_ARCH} == "amd64"
33 COPTFLAGS?=-O2 -frename-registers -pipe
35 COPTFLAGS?=${_MINUS_O} -pipe
37 . if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
38 COPTFLAGS+= -fno-strict-aliasing
41 .if !defined(NO_CPU_COPTFLAGS)
43 COPTFLAGS+= ${_ICC_CPUCFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
45 COPTFLAGS+= ${_CPUCFLAGS}
56 INCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S
58 # This hack lets us use the OpenBSD altq code without spamming a new
59 # include path into contrib'ed source files.
60 INCLUDES+= -I$S/contrib/altq
62 .if make(depend) || make(kernel-depend)
64 # ... and the same for ipfilter
65 INCLUDES+= -I$S/contrib/ipfilter
67 # ... and the same for pf
68 INCLUDES+= -I$S/contrib/pf
70 # ... and the same for Atheros HAL
71 INCLUDES+= -I$S/dev/ath
73 # ... and the same for the NgATM stuff
74 INCLUDES+= -I$S/contrib/ngatm
76 # .. and the same for twa
77 INCLUDES+= -I$S/dev/twa
79 # .. and the same for em
80 INCLUDES+= -I$S/dev/em
83 INCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs
87 CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS}
88 CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
90 CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
91 CFLAGS+= --param inline-unit-growth=100
92 CFLAGS+= --param large-function-growth=1000
93 .if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" || \
94 ${MACHINE_ARCH} == "sparc64"
99 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
100 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
102 .if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
104 .error "Profiling doesn't work with icc yet"
106 CFLAGS+= -DGPROF -falign-functions=16
107 .if ${PROFLEVEL} >= 2
108 CFLAGS+= -DGPROF4 -DGUPROF
109 PROF= -pg -mprofiler-epilogue
114 DEFINED_PROF= ${PROF}
116 # Put configuration-specific C flags last (except for ${PROF}) so that they
117 # can override the others.
118 CFLAGS+= ${CONF_CFLAGS}
120 # Optional linting. This can be overridden in /etc/make.conf.
121 LINTFLAGS= ${LINTOBJKERNFLAGS}
123 NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
124 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
125 PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
126 NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
128 NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
129 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
131 NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
133 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
134 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
135 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
136 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
137 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
138 SYSTEM_OBJS+= hack.So
139 SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
140 -warn-common -export-dynamic -dynamic-linker /red/herring \
141 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
142 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
143 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
144 SYSTEM_DEP+= $S/conf/ldscript.$M
146 # MKMODULESENV is set here so that port makefiles can augment
149 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
150 .if (${KERN_IDENT} == LINT)
151 MKMODULESENV+= ALL_MODULES=LINT
153 .if defined(MODULES_OVERRIDE)
154 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
157 MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"