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}
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 ath
71 INCLUDES+= -I$S/dev/ath -I$S/dev/ath/ath_hal
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
80 INCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs
83 INCLUDES+= -I$S/contrib/opensolaris/compat
85 # ... and the same for cxgb
86 INCLUDES+= -I$S/dev/cxgb
90 CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS}
91 CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
93 CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
94 CFLAGS+= --param inline-unit-growth=100
95 CFLAGS+= --param large-function-growth=1000
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 .if defined(CTFCONVERT)
132 NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
137 NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
139 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
140 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
141 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
142 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
143 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
144 SYSTEM_OBJS+= hack.So
145 .if defined(CTFMERGE)
146 SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJS} vers.o
149 SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} \
150 -warn-common -export-dynamic -dynamic-linker /red/herring \
151 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
152 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
153 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
154 SYSTEM_DEP+= ${LDSCRIPT}
156 # MKMODULESENV is set here so that port makefiles can augment
159 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
160 .if (${KERN_IDENT} == LINT)
161 MKMODULESENV+= ALL_MODULES=LINT
163 .if defined(MODULES_OVERRIDE)
164 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
167 MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"