]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - sys/conf/kern.pre.mk
Revert MFC of r260102 for now, until I can merge the required fix from
[FreeBSD/stable/9.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 .sinclude <bsd.compiler.mk>
8
9 # backwards compat option for older systems.
10 MACHINE_CPUARCH?=${MACHINE_ARCH:C/mipse[lb]/mips/:C/armeb/arm/:C/powerpc64/powerpc/}
11 COMPILER_TYPE?="gcc"
12
13 # Can be overridden by makeoptions or /etc/make.conf
14 KERNEL_KO?=     kernel
15 KERNEL?=        kernel
16 KODIR?=         /boot/${KERNEL}
17 LDSCRIPT_NAME?= ldscript.$M
18 LDSCRIPT?=      $S/conf/${LDSCRIPT_NAME}
19
20 M=              ${MACHINE_CPUARCH}
21
22 AWK?=           awk
23 CP?=            cp
24 LINT?=          lint
25 NM?=            nm
26 OBJCOPY?=       objcopy
27 SIZE?=          size
28
29 .if defined(DEBUG)
30 _MINUS_O=       -O
31 CTFFLAGS+=      -g
32 .else
33 .if ${MACHINE_CPUARCH} == "powerpc"
34 _MINUS_O=       -O      # gcc miscompiles some code at -O2
35 .else
36 _MINUS_O=       -O2
37 .endif
38 .endif
39 .if ${MACHINE_CPUARCH} == "amd64"
40 .if ${COMPILER_TYPE} != "clang"
41 COPTFLAGS?=-O2 -frename-registers -pipe
42 .else
43 COPTFLAGS?=-O2 -pipe
44 .endif
45 .else
46 COPTFLAGS?=${_MINUS_O} -pipe
47 .endif
48 .if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
49 COPTFLAGS+= -fno-strict-aliasing
50 .endif
51 .if !defined(NO_CPU_COPTFLAGS)
52 COPTFLAGS+= ${_CPUCFLAGS}
53 .endif
54 C_DIALECT= -std=c99
55 NOSTDINC= -nostdinc
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 ${COMPILER_TYPE} != "clang"
91 CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
92 .if ${MACHINE_CPUARCH} != "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=10000
98 CFLAGS+= --param large-function-growth=100000
99 CFLAGS+= --param max-inline-insns-single=10000
100 .endif
101 .endif
102 WERROR?= -Werror
103
104 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
105 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
106
107 .if ${COMPILER_TYPE} == "clang"
108 CLANG_NO_IAS= -no-integrated-as
109 .endif
110
111 .if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
112 CFLAGS+=        -DGPROF
113 .if ${COMPILER_TYPE} != "clang"
114 CFLAGS+=        -falign-functions=16
115 .endif
116 .if ${PROFLEVEL} >= 2
117 CFLAGS+=        -DGPROF4 -DGUPROF
118 PROF=           -pg
119 .if ${COMPILER_TYPE} != "clang"
120 PROF+=          -mprofiler-epilogue
121 .endif
122 .else
123 PROF=           -pg
124 .endif
125 .endif
126 DEFINED_PROF=   ${PROF}
127
128 # Put configuration-specific C flags last (except for ${PROF}) so that they
129 # can override the others.
130 CFLAGS+=        ${CONF_CFLAGS}
131
132 # Optional linting. This can be overridden in /etc/make.conf.
133 LINTFLAGS=      ${LINTOBJKERNFLAGS}
134
135 NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
136 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
137 PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
138 NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
139
140 NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
141           ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
142
143 NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
144 NORMAL_FWO= ${LD} -b binary --no-warn-mismatch -d -warn-common -r \
145         -o ${.TARGET} ${.ALLSRC:M*.fw}
146
147 .if ${MK_CTF} != "no"
148 NORMAL_CTFCONVERT=      ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
149 .elif ${MAKE_VERSION} >= 9201210220
150 NORMAL_CTFCONVERT=
151 .else
152 NORMAL_CTFCONVERT=      @:
153 .endif
154
155 NORMAL_LINT=    ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
156
157 # Infiniband C flags.  Correct include paths and omit errors that linux
158 # does not honor.
159 OFEDINCLUDES=   -I$S/ofed/include/
160 OFEDNOERR=      -Wno-cast-qual -Wno-pointer-arith -fms-extensions
161 OFEDCFLAGS=     ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
162 OFED_C_NOIMP=   ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
163 OFED_C=         ${OFED_C_NOIMP} ${.IMPSRC}
164
165 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
166 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
167 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
168 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
169 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
170 SYSTEM_OBJS+= hack.So
171 SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} --no-warn-mismatch \
172         -warn-common -export-dynamic -dynamic-linker /red/herring \
173         -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
174 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
175         ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
176 SYSTEM_DEP+= ${LDSCRIPT}
177
178 # MKMODULESENV is set here so that port makefiles can augment
179 # them.
180
181 MKMODULESENV+=  MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
182 MKMODULESENV+=  MACHINE_CPUARCH=${MACHINE_CPUARCH}
183 .if (${KERN_IDENT} == LINT)
184 MKMODULESENV+=  ALL_MODULES=LINT
185 .endif
186 .if defined(MODULES_OVERRIDE)
187 MKMODULESENV+=  MODULES_OVERRIDE="${MODULES_OVERRIDE}"
188 .endif
189 .if defined(WITHOUT_MODULES)
190 MKMODULESENV+=  WITHOUT_MODULES="${WITHOUT_MODULES}"
191 .endif
192 .if defined(DEBUG)
193 MKMODULESENV+=  DEBUG_FLAGS="${DEBUG}"
194 .endif