1# $FreeBSD: head/sys/conf/kern.pre.mk 145016 2005-04-13 14:49:57Z imp $
2
3# Part of a unified Makefile for building kernels. This part contains all
4# of the definitions that need to be before %BEFORE_DEPEND.
5
6# Can be overridden by makeoptions or /etc/make.conf
7KERNEL_KO?= kernel
8KERNEL?= kernel
9KODIR?= /boot/${KERNEL}
10
11M= ${MACHINE_ARCH}
12
13AWK?= awk
14LINT?= lint
15NM?= nm
16OBJCOPY?= objcopy
17SIZE?= size
18
19.if ${CC} == "icc"
20COPTFLAGS?= -O
21.else
22. if defined(DEBUG)
23_MINUS_O= -O
24. else
25_MINUS_O= -O2
26. endif
27. if ${MACHINE_ARCH} == "amd64"
28COPTFLAGS?=-O2 -frename-registers -pipe
29. else
30COPTFLAGS?=${_MINUS_O} -pipe
31. endif
32. if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
33COPTFLAGS+= -fno-strict-aliasing
34. endif
35.endif
36.if !defined(NO_CPU_COPTFLAGS)
37. if ${CC} == "icc"
38COPTFLAGS+= ${_ICC_CPUCFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
39. else
40COPTFLAGS+= ${_CPUCFLAGS}
41. endif
42.endif
43.if ${CC} == "icc"
44NOSTDINC= -X
45.else
46NOSTDINC= -nostdinc
47.endif
48
49INCLUDES= ${NOSTDINC} -I- ${INCLMAGIC} -I. -I$S
50
51# This hack lets us use the Intel ACPICA code without spamming a new
52# include path into 100+ source files.
53INCLUDES+= -I$S/contrib/dev/acpica
54
55# ... and the same for altq
56INCLUDES+= -I$S/contrib/altq
57
58# ... and the same for ipfilter
59INCLUDES+= -I$S/contrib/ipfilter
60
61# ... and the same for pf
62INCLUDES+= -I$S/contrib/pf
63
64# ... and the same for Atheros HAL
65INCLUDES+= -I$S/contrib/dev/ath -I$S/contrib/dev/ath/freebsd
66
67# ... and the same for the NgATM stuff
68INCLUDES+= -I$S/contrib/ngatm
69
70# .. and the same for twa
71INCLUDES+= -I$S/dev/twa
72
73CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG}
74CFLAGS+= ${INCLUDES} -D_KERNEL -include opt_global.h
75.if ${CC} != "icc"
76CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
77CFLAGS+= --param inline-unit-growth=100
78CFLAGS+= --param large-function-growth=1000
79WERROR?= -Werror
80.endif
81
82# XXX LOCORE means "don't declare C stuff" not "for locore.s".
83ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
84
85.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
86.if ${CC} == "icc"
87.error Profiling doesn't work with ICC yet.
88.else
89CFLAGS+= -DGPROF -falign-functions=16
90.endif
91.if ${PROFLEVEL} >= 2
92CFLAGS+= -DGPROF4 -DGUPROF
93. if ${CC} == "icc"
94# XXX doesn't work yet
95#PROF= -prof_gen
96. else
97PROF= -finstrument-functions -Wno-inline
98. endif
99.else
100. if ${CC} == "icc"
101PROF= -p
102. else
103PROF= -pg
104. endif
105.endif
106.endif
107DEFINED_PROF= ${PROF}
108
109# Put configuration-specific C flags last (except for ${PROF}) so that they
110# can override the others.
111CFLAGS+= ${CONF_CFLAGS}
112
113# Optional linting. This can be overridden in /etc/make.conf.
114LINTFLAGS= ${LINTOBJKERNFLAGS}
115
116NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
117NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
118PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
119NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
120
121NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
122 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
123
124NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
125
126GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
127SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
128SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
129SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
130SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
131SYSTEM_OBJS+= hack.So
132SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
133 -warn-common -export-dynamic -dynamic-linker /red/herring \
134 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
135SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
136 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
137SYSTEM_DEP+= $S/conf/ldscript.$M
138
139# MKMODULESENV is set here so that port makefiles can augment
140# them.
141
142MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
143.if (${KERN_IDENT} == LINT)
144MKMODULESENV+= ALL_MODULES=LINT
145.endif
146.if defined(MODULES_OVERRIDE)
147MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
148.endif
149.if defined(DEBUG)
150MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"
151.endif
2
3# Part of a unified Makefile for building kernels. This part contains all
4# of the definitions that need to be before %BEFORE_DEPEND.
5
6# Can be overridden by makeoptions or /etc/make.conf
7KERNEL_KO?= kernel
8KERNEL?= kernel
9KODIR?= /boot/${KERNEL}
10
11M= ${MACHINE_ARCH}
12
13AWK?= awk
14LINT?= lint
15NM?= nm
16OBJCOPY?= objcopy
17SIZE?= size
18
19.if ${CC} == "icc"
20COPTFLAGS?= -O
21.else
22. if defined(DEBUG)
23_MINUS_O= -O
24. else
25_MINUS_O= -O2
26. endif
27. if ${MACHINE_ARCH} == "amd64"
28COPTFLAGS?=-O2 -frename-registers -pipe
29. else
30COPTFLAGS?=${_MINUS_O} -pipe
31. endif
32. if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
33COPTFLAGS+= -fno-strict-aliasing
34. endif
35.endif
36.if !defined(NO_CPU_COPTFLAGS)
37. if ${CC} == "icc"
38COPTFLAGS+= ${_ICC_CPUCFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
39. else
40COPTFLAGS+= ${_CPUCFLAGS}
41. endif
42.endif
43.if ${CC} == "icc"
44NOSTDINC= -X
45.else
46NOSTDINC= -nostdinc
47.endif
48
49INCLUDES= ${NOSTDINC} -I- ${INCLMAGIC} -I. -I$S
50
51# This hack lets us use the Intel ACPICA code without spamming a new
52# include path into 100+ source files.
53INCLUDES+= -I$S/contrib/dev/acpica
54
55# ... and the same for altq
56INCLUDES+= -I$S/contrib/altq
57
58# ... and the same for ipfilter
59INCLUDES+= -I$S/contrib/ipfilter
60
61# ... and the same for pf
62INCLUDES+= -I$S/contrib/pf
63
64# ... and the same for Atheros HAL
65INCLUDES+= -I$S/contrib/dev/ath -I$S/contrib/dev/ath/freebsd
66
67# ... and the same for the NgATM stuff
68INCLUDES+= -I$S/contrib/ngatm
69
70# .. and the same for twa
71INCLUDES+= -I$S/dev/twa
72
73CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG}
74CFLAGS+= ${INCLUDES} -D_KERNEL -include opt_global.h
75.if ${CC} != "icc"
76CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
77CFLAGS+= --param inline-unit-growth=100
78CFLAGS+= --param large-function-growth=1000
79WERROR?= -Werror
80.endif
81
82# XXX LOCORE means "don't declare C stuff" not "for locore.s".
83ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
84
85.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
86.if ${CC} == "icc"
87.error Profiling doesn't work with ICC yet.
88.else
89CFLAGS+= -DGPROF -falign-functions=16
90.endif
91.if ${PROFLEVEL} >= 2
92CFLAGS+= -DGPROF4 -DGUPROF
93. if ${CC} == "icc"
94# XXX doesn't work yet
95#PROF= -prof_gen
96. else
97PROF= -finstrument-functions -Wno-inline
98. endif
99.else
100. if ${CC} == "icc"
101PROF= -p
102. else
103PROF= -pg
104. endif
105.endif
106.endif
107DEFINED_PROF= ${PROF}
108
109# Put configuration-specific C flags last (except for ${PROF}) so that they
110# can override the others.
111CFLAGS+= ${CONF_CFLAGS}
112
113# Optional linting. This can be overridden in /etc/make.conf.
114LINTFLAGS= ${LINTOBJKERNFLAGS}
115
116NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
117NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
118PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
119NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
120
121NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
122 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
123
124NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
125
126GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
127SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
128SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
129SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
130SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
131SYSTEM_OBJS+= hack.So
132SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
133 -warn-common -export-dynamic -dynamic-linker /red/herring \
134 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
135SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
136 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
137SYSTEM_DEP+= $S/conf/ldscript.$M
138
139# MKMODULESENV is set here so that port makefiles can augment
140# them.
141
142MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
143.if (${KERN_IDENT} == LINT)
144MKMODULESENV+= ALL_MODULES=LINT
145.endif
146.if defined(MODULES_OVERRIDE)
147MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
148.endif
149.if defined(DEBUG)
150MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"
151.endif