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}
12 LDSCRIPT_NAME?= ldscript.$M
13 LDSCRIPT?= $S/conf/${LDSCRIPT_NAME}
33 . if ${MACHINE_ARCH} == "amd64"
34 COPTFLAGS?=-O2 -frename-registers -pipe
36 COPTFLAGS?=${_MINUS_O} -pipe
38 . if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
39 COPTFLAGS+= -fno-strict-aliasing
42 .if !defined(NO_CPU_COPTFLAGS)
44 COPTFLAGS+= ${_ICC_CPUCFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
46 COPTFLAGS+= ${_CPUCFLAGS}
57 INCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S
59 # This hack lets us use the OpenBSD altq code without spamming a new
60 # include path into contrib'ed source files.
61 INCLUDES+= -I$S/contrib/altq
63 .if make(depend) || make(kernel-depend)
65 # ... and the same for ipfilter
66 INCLUDES+= -I$S/contrib/ipfilter
68 # ... and the same for pf
69 INCLUDES+= -I$S/contrib/pf
71 # ... and the same for ath
72 INCLUDES+= -I$S/dev/ath -I$S/dev/ath/ath_hal
74 # ... and the same for the NgATM stuff
75 INCLUDES+= -I$S/contrib/ngatm
77 # ... and the same for twa
78 INCLUDES+= -I$S/dev/twa
80 # ... and the same for XFS
81 INCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs
83 # ... and the same for cxgb and cxgbe
84 INCLUDES+= -I$S/dev/cxgb -I$S/dev/cxgbe
88 CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS}
89 CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
91 CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
92 .if ${MACHINE_ARCH} != "mips"
93 CFLAGS+= --param inline-unit-growth=100
94 CFLAGS+= --param large-function-growth=1000
96 # XXX Actually a gross hack just for Octeon because of the Simple Executive.
97 CFLAGS+= --param inline-unit-growth=1000
98 CFLAGS+= --param large-function-growth=100000
103 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
104 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
106 .if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
108 .error "Profiling doesn't work with icc yet"
110 CFLAGS+= -DGPROF -falign-functions=16
111 .if ${PROFLEVEL} >= 2
112 CFLAGS+= -DGPROF4 -DGUPROF
113 PROF= -pg -mprofiler-epilogue
118 DEFINED_PROF= ${PROF}
120 # Put configuration-specific C flags last (except for ${PROF}) so that they
121 # can override the others.
122 CFLAGS+= ${CONF_CFLAGS}
124 # Optional linting. This can be overridden in /etc/make.conf.
125 LINTFLAGS= ${LINTOBJKERNFLAGS}
127 NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
128 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
129 PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
130 NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
132 NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
133 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
135 NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
136 NORMAL_FWO= ${LD} -b binary --no-warn-mismatch -d -warn-common -r \
137 -o ${.TARGET} ${.ALLSRC:M*.fw}
139 .if ${MK_CTF} != "no"
140 NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
142 NORMAL_CTFCONVERT= @:
145 NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
147 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
148 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
149 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
150 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
151 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
152 SYSTEM_OBJS+= hack.So
153 SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} --no-warn-mismatch \
154 -warn-common -export-dynamic -dynamic-linker /red/herring \
155 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
156 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
157 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
158 SYSTEM_DEP+= ${LDSCRIPT}
160 # MKMODULESENV is set here so that port makefiles can augment
163 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
164 .if (${KERN_IDENT} == LINT)
165 MKMODULESENV+= ALL_MODULES=LINT
167 .if defined(MODULES_OVERRIDE)
168 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
170 .if defined(WITHOUT_MODULES)
171 MKMODULESENV+= WITHOUT_MODULES="${WITHOUT_MODULES}"
174 MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"