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 .include <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/}
12 # Can be overridden by makeoptions or /etc/make.conf
15 KODIR?= /boot/${KERNEL}
16 LDSCRIPT_NAME?= ldscript.$M
17 LDSCRIPT?= $S/conf/${LDSCRIPT_NAME}
32 .if ${MACHINE_CPUARCH} == "powerpc"
33 _MINUS_O= -O # gcc miscompiles some code at -O2
38 .if ${MACHINE_CPUARCH} == "amd64"
39 .if ${COMPILER_TYPE} != "clang"
40 COPTFLAGS?=-O2 -frename-registers -pipe
45 COPTFLAGS?=${_MINUS_O} -pipe
47 .if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
48 COPTFLAGS+= -fno-strict-aliasing
50 .if !defined(NO_CPU_COPTFLAGS)
51 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
79 # ... and the same for XFS
80 INCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs
82 # ... and the same for cxgb and cxgbe
83 INCLUDES+= -I$S/dev/cxgb -I$S/dev/cxgbe
87 CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS}
88 CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
89 .if ${COMPILER_TYPE} != "clang"
90 CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
91 .if ${MACHINE_CPUARCH} != "mips"
92 CFLAGS+= --param inline-unit-growth=100
93 CFLAGS+= --param large-function-growth=1000
95 # XXX Actually a gross hack just for Octeon because of the Simple Executive.
96 CFLAGS+= --param inline-unit-growth=10000
97 CFLAGS+= --param large-function-growth=100000
98 CFLAGS+= --param max-inline-insns-single=10000
103 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
104 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
106 .if ${COMPILER_TYPE} == "clang"
107 CLANG_NO_IAS= -no-integrated-as
110 .if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
112 .if ${COMPILER_TYPE} != "clang"
113 CFLAGS+= -falign-functions=16
115 .if ${PROFLEVEL} >= 2
116 CFLAGS+= -DGPROF4 -DGUPROF
118 .if ${COMPILER_TYPE} != "clang"
119 PROF+= -mprofiler-epilogue
125 DEFINED_PROF= ${PROF}
127 # Put configuration-specific C flags last (except for ${PROF}) so that they
128 # can override the others.
129 CFLAGS+= ${CONF_CFLAGS}
131 # Optional linting. This can be overridden in /etc/make.conf.
132 LINTFLAGS= ${LINTOBJKERNFLAGS}
134 NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
135 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
136 PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
137 NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
139 NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
140 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
142 NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
143 NORMAL_FWO= ${LD} -b binary --no-warn-mismatch -d -warn-common -r \
144 -o ${.TARGET} ${.ALLSRC:M*.fw}
146 .if ${MK_CTF} != "no"
147 NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
148 .elif ${MAKE_VERSION} >= 9201210220
151 NORMAL_CTFCONVERT= @:
154 NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
156 # Infiniband C flags. Correct include paths and omit errors that linux
158 OFEDINCLUDES= -I$S/ofed/include/
159 OFEDNOERR= -Wno-cast-qual -Wno-pointer-arith -fms-extensions
160 OFEDCFLAGS= ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
161 OFED_C_NOIMP= ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
162 OFED_C= ${OFED_C_NOIMP} ${.IMPSRC}
164 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
165 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
166 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
167 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
168 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
169 SYSTEM_OBJS+= hack.So
170 SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} --no-warn-mismatch \
171 -warn-common -export-dynamic -dynamic-linker /red/herring \
172 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
173 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
174 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
175 SYSTEM_DEP+= ${LDSCRIPT}
177 # MKMODULESENV is set here so that port makefiles can augment
180 MKMODULESENV+= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
181 MKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH}
182 .if (${KERN_IDENT} == LINT)
183 MKMODULESENV+= ALL_MODULES=LINT
185 .if defined(MODULES_OVERRIDE)
186 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
188 .if defined(WITHOUT_MODULES)
189 MKMODULESENV+= WITHOUT_MODULES="${WITHOUT_MODULES}"
192 MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"