kern.pre.mk revision 160440
185909Simp# $FreeBSD: head/sys/conf/kern.pre.mk 160440 2006-07-17 18:43:16Z obrien $
285909Simp
3122116Sbde# Part of a unified Makefile for building kernels.  This part contains all
4122116Sbde# of the definitions that need to be before %BEFORE_DEPEND.
5122116Sbde
6160440SobrienSRCCONF?=	/etc/src.conf
7160440Sobrien.if exists(${SRCCONF})
8160440Sobrien.include "${SRCCONF}"
9160440Sobrien.endif
10160440Sobrien
1185909Simp# Can be overridden by makeoptions or /etc/make.conf
1285909SimpKERNEL_KO?=	kernel
1385909SimpKERNEL?=	kernel
1485909SimpKODIR?=		/boot/${KERNEL}
1585909Simp
1685909SimpM=	${MACHINE_ARCH}
1785909Simp
1891512SobrienAWK?=		awk
19116341SmarkmLINT?=		lint
2085909SimpNM?=		nm
2185909SimpOBJCOPY?=	objcopy
2285909SimpSIZE?=		size
2385909Simp
24126890Strhodes.if ${CC} == "icc"
25140606SobrienCOPTFLAGS?=	-O
26126890Strhodes.else
27140606Sobrien. if defined(DEBUG)
28140606Sobrien_MINUS_O=	-O
29140606Sobrien. else
30140606Sobrien_MINUS_O=	-O2
31140606Sobrien. endif
32127543Skensmith. if ${MACHINE_ARCH} == "amd64"
33127204SobrienCOPTFLAGS?=-O2 -frename-registers -pipe
34136951Sobrien. else
35140606SobrienCOPTFLAGS?=${_MINUS_O} -pipe
36127204Sobrien. endif
37141782Sobrien. if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
38124834SruCOPTFLAGS+= -fno-strict-aliasing
39126890Strhodes. endif
40124834Sru.endif
4185909Simp.if !defined(NO_CPU_COPTFLAGS)
42126890Strhodes. if ${CC} == "icc"
43126890StrhodesCOPTFLAGS+= ${_ICC_CPUCFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
44126890Strhodes. else
4585909SimpCOPTFLAGS+= ${_CPUCFLAGS}
46126890Strhodes. endif
4785909Simp.endif
48126890Strhodes.if ${CC} == "icc"
49126890StrhodesNOSTDINC= -X
50126890Strhodes.else
51160043SobrienC_DIALECT= -std=c99
52126890StrhodesNOSTDINC= -nostdinc
53126890Strhodes.endif
5485909Simp
55126890StrhodesINCLUDES= ${NOSTDINC} -I- ${INCLMAGIC} -I. -I$S
56126890Strhodes
57151605Sobrien# This hack lets us use the OpenBSD altq code without spamming a new
58151605Sobrien# include path into contrib'ed source files.
59130416SmlaierINCLUDES+= -I$S/contrib/altq
60130416Smlaier
61149973Sobrien# ... and the same for Atheros HAL when the author builds it from
62149973Sobrien#     non-distributable sources.
63149973Sobrien.if defined(ATH_BUILDING_FROM_SOURCE)
64149973SobrienINCLUDES+= -I$S/contrib/dev/ath
65149973Sobrien.endif
66116817Ssam
67149978Sobrien.if make(depend) || make(kernel-depend)
68149978Sobrien
69149978Sobrien# ... and the same for ipfilter
70149978SobrienINCLUDES+= -I$S/contrib/ipfilter
71149978Sobrien
72149978Sobrien# ... and the same for pf
73149978SobrienINCLUDES+= -I$S/contrib/pf
74149978Sobrien
75149978Sobrien# ... and the same for Atheros HAL
76149978SobrienINCLUDES+= -I$S/contrib/dev/ath/freebsd
77149978Sobrien
78149978Sobrien# ... and the same for the NgATM stuff
79149978SobrienINCLUDES+= -I$S/contrib/ngatm
80149978Sobrien
81149978Sobrien# .. and the same for twa
82149978SobrienINCLUDES+= -I$S/dev/twa
83149978Sobrien
84153325Srodrigc# ...  and XFS
85153325SrodrigcINCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs
86153325Srodrigc
87149978Sobrien.endif
88149978Sobrien
89160043SobrienCFLAGS=	${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS}
90150966SglebiusCFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
91126890Strhodes.if ${CC} != "icc"
92124834SruCFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
93132766SkanCFLAGS+= --param inline-unit-growth=100
94132766SkanCFLAGS+= --param large-function-growth=1000
95122116SbdeWERROR?= -Werror
96126890Strhodes.endif
9785909Simp
9885909Simp# XXX LOCORE means "don't declare C stuff" not "for locore.s".
9985909SimpASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
10085909Simp
10199923Sbde.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
102126938Strhodes.if ${CC} == "icc"
103126938Strhodes.error Profiling doesn't work with ICC yet.
104126938Strhodes.else
10599932SbdeCFLAGS+=	-DGPROF -falign-functions=16
106126938Strhodes.endif
10799932Sbde.if ${PROFLEVEL} >= 2
10899932SbdeCFLAGS+=	-DGPROF4 -DGUPROF
109126890Strhodes. if ${CC} == "icc"
110126890Strhodes# XXX doesn't work yet
111126890Strhodes#PROF=	-prof_gen
112126890Strhodes. else
113132766SkanPROF=	-finstrument-functions -Wno-inline
114126890Strhodes. endif
11599932Sbde.else
116126890Strhodes. if ${CC} == "icc"
117126890StrhodesPROF=	-p
118126890Strhodes. else
11999923SbdePROF=	-pg
120126890Strhodes. endif
12199923Sbde.endif
12299932Sbde.endif
12385909SimpDEFINED_PROF=	${PROF}
12491002Speter
12585909Simp# Put configuration-specific C flags last (except for ${PROF}) so that they
12685909Simp# can override the others.
12785909SimpCFLAGS+=	${CONF_CFLAGS}
12885909Simp
129116341Smarkm# Optional linting. This can be overridden in /etc/make.conf.
130116341SmarkmLINTFLAGS=	${LINTOBJKERNFLAGS}
131116341Smarkm
13291002SpeterNORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
13391002SpeterNORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
13491002SpeterPROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
135105489SmuxNORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
13685909Simp
137105462SmuxNORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
138105462Smux	  ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
13985909Simp
140116341SmarkmNORMAL_LINT=	${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
141116341Smarkm
142131210SimpGEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
143144293SphkSYSTEM_CFILES= config.c env.c hints.c vnode_if.c
14485909SimpSYSTEM_DEP= Makefile ${SYSTEM_OBJS}
145111684SruSYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
146111684SruSYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
147111684SruSYSTEM_OBJS+= hack.So
148123966SbdeSYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
14989180Smsmith	-warn-common -export-dynamic -dynamic-linker /red/herring \
15085909Simp	-o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
15185909SimpSYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
152123966Sbde	${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
15385909SimpSYSTEM_DEP+= $S/conf/ldscript.$M
15485909Simp
15588893Simp# MKMODULESENV is set here so that port makefiles can augment
15688893Simp# them.
15788893Simp
15888893SimpMKMODULESENV=	MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
15990789Sphk.if (${KERN_IDENT} == LINT)
16090789SphkMKMODULESENV+=	ALL_MODULES=LINT
16190789Sphk.endif
16288893Simp.if defined(MODULES_OVERRIDE)
16388893SimpMKMODULESENV+=	MODULES_OVERRIDE="${MODULES_OVERRIDE}"
16488893Simp.endif
16588893Simp.if defined(DEBUG)
166125772SruMKMODULESENV+=	DEBUG_FLAGS="${DEBUG}"
16788893Simp.endif
168