]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - sys/conf/kern.pre.mk
MFC r358694:
[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 .else
110 GCC_MS_EXTENSIONS= -fms-extensions
111 .endif
112
113 .if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
114 CFLAGS+=        -DGPROF
115 .if ${COMPILER_TYPE} != "clang"
116 CFLAGS+=        -falign-functions=16
117 .endif
118 .if ${PROFLEVEL} >= 2
119 CFLAGS+=        -DGPROF4 -DGUPROF
120 PROF=           -pg
121 .if ${COMPILER_TYPE} != "clang"
122 PROF+=          -mprofiler-epilogue
123 .endif
124 .else
125 PROF=           -pg
126 .endif
127 .endif
128 DEFINED_PROF=   ${PROF}
129
130 # Put configuration-specific C flags last (except for ${PROF}) so that they
131 # can override the others.
132 CFLAGS+=        ${CONF_CFLAGS}
133
134 # Optional linting. This can be overridden in /etc/make.conf.
135 LINTFLAGS=      ${LINTOBJKERNFLAGS}
136
137 NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
138 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
139 PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
140 NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
141
142 NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
143           ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
144
145 NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
146 NORMAL_FWO= ${LD} -b binary --no-warn-mismatch -d -warn-common -r \
147         -o ${.TARGET} ${.ALLSRC:M*.fw}
148
149 .if ${MK_CTF} != "no"
150 NORMAL_CTFCONVERT=      ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
151 .elif ${MAKE_VERSION} >= 9201210220
152 NORMAL_CTFCONVERT=
153 .else
154 NORMAL_CTFCONVERT=      @:
155 .endif
156
157 NORMAL_LINT=    ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
158
159 # Infiniband C flags.  Correct include paths and omit errors that linux
160 # does not honor.
161 OFEDINCLUDES=   -I$S/ofed/include/
162 OFEDNOERR=      -Wno-cast-qual -Wno-pointer-arith ${GCC_MS_EXTENSIONS}
163 OFEDCFLAGS=     ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
164 OFED_C_NOIMP=   ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
165 OFED_C=         ${OFED_C_NOIMP} ${.IMPSRC}
166
167 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
168 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
169 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
170 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
171 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
172 SYSTEM_OBJS+= hack.So
173 SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} --no-warn-mismatch \
174         -warn-common -export-dynamic -dynamic-linker /red/herring \
175         -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
176 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
177         ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
178 SYSTEM_DEP+= ${LDSCRIPT}
179
180 # MKMODULESENV is set here so that port makefiles can augment
181 # them.
182
183 MKMODULESENV+=  MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
184 MKMODULESENV+=  MACHINE_CPUARCH=${MACHINE_CPUARCH}
185 .if (${KERN_IDENT} == LINT)
186 MKMODULESENV+=  ALL_MODULES=LINT
187 .endif
188 .if defined(MODULES_OVERRIDE)
189 MKMODULESENV+=  MODULES_OVERRIDE="${MODULES_OVERRIDE}"
190 .endif
191 .if defined(WITHOUT_MODULES)
192 MKMODULESENV+=  WITHOUT_MODULES="${WITHOUT_MODULES}"
193 .endif
194 .if defined(DEBUG)
195 MKMODULESENV+=  DEBUG_FLAGS="${DEBUG}"
196 .endif