3 # Part of a unified Makefile for building kernels. This part contains all
4 # of the definitions that need to be before %BEFORE_DEPEND.
7 .sinclude <bsd.compiler.mk>
9 # backwards compat option for older systems.
10 MACHINE_CPUARCH?=${MACHINE_ARCH:C/mipse[lb]/mips/:C/armeb/arm/:C/powerpc64/powerpc/}
13 # Can be overridden by makeoptions or /etc/make.conf
16 KODIR?= /boot/${KERNEL}
17 LDSCRIPT_NAME?= ldscript.$M
18 LDSCRIPT?= $S/conf/${LDSCRIPT_NAME}
33 .if ${MACHINE_CPUARCH} == "powerpc"
34 _MINUS_O= -O # gcc miscompiles some code at -O2
39 .if ${MACHINE_CPUARCH} == "amd64"
40 .if ${COMPILER_TYPE} != "clang"
41 COPTFLAGS?=-O2 -frename-registers -pipe
46 COPTFLAGS?=${_MINUS_O} -pipe
48 .if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
49 COPTFLAGS+= -fno-strict-aliasing
51 .if !defined(NO_CPU_COPTFLAGS)
52 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
90 .if ${COMPILER_TYPE} != "clang"
91 CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
92 .if ${MACHINE_CPUARCH} != "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=10000
98 CFLAGS+= --param large-function-growth=100000
99 CFLAGS+= --param max-inline-insns-single=10000
104 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
105 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
107 .if ${COMPILER_TYPE} == "clang"
108 CLANG_NO_IAS= -no-integrated-as
110 GCC_MS_EXTENSIONS= -fms-extensions
113 .if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
115 .if ${COMPILER_TYPE} != "clang"
116 CFLAGS+= -falign-functions=16
118 .if ${PROFLEVEL} >= 2
119 CFLAGS+= -DGPROF4 -DGUPROF
121 .if ${COMPILER_TYPE} != "clang"
122 PROF+= -mprofiler-epilogue
128 DEFINED_PROF= ${PROF}
130 # Put configuration-specific C flags last (except for ${PROF}) so that they
131 # can override the others.
132 CFLAGS+= ${CONF_CFLAGS}
134 # Optional linting. This can be overridden in /etc/make.conf.
135 LINTFLAGS= ${LINTOBJKERNFLAGS}
137 NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
138 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
139 PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
140 NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
142 NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
143 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
145 NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
146 NORMAL_FWO= ${LD} -b binary --no-warn-mismatch -d -warn-common -r \
147 -o ${.TARGET} ${.ALLSRC:M*.fw}
149 .if ${MK_CTF} != "no"
150 NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
151 .elif ${MAKE_VERSION} >= 9201210220
154 NORMAL_CTFCONVERT= @:
157 NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
159 # Infiniband C flags. Correct include paths and omit errors that linux
161 OFEDINCLUDES= -I$S/ofed/include/
162 OFEDNOERR= -Wno-cast-qual -Wno-pointer-arith ${GCC_MS_EXTENSIONS}
163 OFEDCFLAGS= ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
164 OFED_C_NOIMP= ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
165 OFED_C= ${OFED_C_NOIMP} ${.IMPSRC}
167 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
168 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
169 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
170 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
171 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
172 SYSTEM_OBJS+= hack.So
173 SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} --no-warn-mismatch \
174 -warn-common -export-dynamic -dynamic-linker /red/herring \
175 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
176 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
177 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
178 SYSTEM_DEP+= ${LDSCRIPT}
180 # MKMODULESENV is set here so that port makefiles can augment
183 MKMODULESENV+= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
184 MKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH}
185 .if (${KERN_IDENT} == LINT)
186 MKMODULESENV+= ALL_MODULES=LINT
188 .if defined(MODULES_OVERRIDE)
189 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
191 .if defined(WITHOUT_MODULES)
192 MKMODULESENV+= WITHOUT_MODULES="${WITHOUT_MODULES}"
195 MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"