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