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