]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/conf/kern.pre.mk
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.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 .include <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
12 # Can be overridden by makeoptions or /etc/make.conf
13 KERNEL_KO?=     kernel
14 KERNEL?=        kernel
15 KODIR?=         /boot/${KERNEL}
16 LDSCRIPT_NAME?= ldscript.$M
17 LDSCRIPT?=      $S/conf/${LDSCRIPT_NAME}
18
19 M=              ${MACHINE_CPUARCH}
20
21 AWK?=           awk
22 CP?=            cp
23 LINT?=          lint
24 NM?=            nm
25 OBJCOPY?=       objcopy
26 SIZE?=          size
27
28 .if defined(DEBUG)
29 _MINUS_O=       -O
30 CTFFLAGS+=      -g
31 .else
32 .if ${MACHINE_CPUARCH} == "powerpc"
33 _MINUS_O=       -O      # gcc miscompiles some code at -O2
34 .else
35 _MINUS_O=       -O2
36 .endif
37 .endif
38 .if ${MACHINE_CPUARCH} == "amd64"
39 .if ${COMPILER_TYPE} != "clang"
40 COPTFLAGS?=-O2 -frename-registers -pipe
41 .else
42 COPTFLAGS?=-O2 -pipe
43 .endif
44 .else
45 COPTFLAGS?=${_MINUS_O} -pipe
46 .endif
47 .if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
48 COPTFLAGS+= -fno-strict-aliasing
49 .endif
50 .if !defined(NO_CPU_COPTFLAGS)
51 COPTFLAGS+= ${_CPUCFLAGS}
52 .endif
53 C_DIALECT= -std=c99
54 NOSTDINC= -nostdinc
55
56 INCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S
57
58 # This hack lets us use the OpenBSD altq code without spamming a new
59 # include path into contrib'ed source files.
60 INCLUDES+= -I$S/contrib/altq
61
62 .if make(depend) || make(kernel-depend)
63
64 # ... and the same for ipfilter
65 INCLUDES+= -I$S/contrib/ipfilter
66
67 # ... and the same for pf
68 INCLUDES+= -I$S/contrib/pf
69
70 # ... and the same for ath
71 INCLUDES+= -I$S/dev/ath -I$S/dev/ath/ath_hal
72
73 # ... and the same for the NgATM stuff
74 INCLUDES+= -I$S/contrib/ngatm
75
76 # ... and the same for twa
77 INCLUDES+= -I$S/dev/twa
78
79 # ... and the same for XFS
80 INCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs
81
82 # ... and the same for cxgb and cxgbe
83 INCLUDES+= -I$S/dev/cxgb -I$S/dev/cxgbe
84
85 .endif
86
87 CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS}
88 CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
89 .if ${COMPILER_TYPE} != "clang"
90 CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
91 .if ${MACHINE_CPUARCH} != "mips"
92 CFLAGS+= --param inline-unit-growth=100
93 CFLAGS+= --param large-function-growth=1000
94 .else
95 # XXX Actually a gross hack just for Octeon because of the Simple Executive.
96 CFLAGS+= --param inline-unit-growth=10000
97 CFLAGS+= --param large-function-growth=100000
98 CFLAGS+= --param max-inline-insns-single=10000
99 .endif
100 .endif
101 WERROR?= -Werror
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 ${COMPILER_TYPE} == "clang"
107 CLANG_NO_IAS= -no-integrated-as
108 .endif
109
110 .if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
111 CFLAGS+=        -DGPROF
112 .if ${COMPILER_TYPE} != "clang"
113 CFLAGS+=        -falign-functions=16
114 .endif
115 .if ${PROFLEVEL} >= 2
116 CFLAGS+=        -DGPROF4 -DGUPROF
117 PROF=           -pg
118 .if ${COMPILER_TYPE} != "clang"
119 PROF+=          -mprofiler-epilogue
120 .endif
121 .else
122 PROF=           -pg
123 .endif
124 .endif
125 DEFINED_PROF=   ${PROF}
126
127 # Put configuration-specific C flags last (except for ${PROF}) so that they
128 # can override the others.
129 CFLAGS+=        ${CONF_CFLAGS}
130
131 # Optional linting. This can be overridden in /etc/make.conf.
132 LINTFLAGS=      ${LINTOBJKERNFLAGS}
133
134 NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
135 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
136 PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
137 NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
138
139 NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
140           ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
141
142 NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
143 NORMAL_FWO= ${LD} -b binary --no-warn-mismatch -d -warn-common -r \
144         -o ${.TARGET} ${.ALLSRC:M*.fw}
145
146 .if ${MK_CTF} != "no"
147 NORMAL_CTFCONVERT=      ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
148 .elif ${MAKE_VERSION} >= 9201210220
149 NORMAL_CTFCONVERT=
150 .else
151 NORMAL_CTFCONVERT=      @:
152 .endif
153
154 NORMAL_LINT=    ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
155
156 # Infiniband C flags.  Correct include paths and omit errors that linux
157 # does not honor.
158 OFEDINCLUDES=   -I$S/ofed/include/
159 OFEDNOERR=      -Wno-cast-qual -Wno-pointer-arith -fms-extensions
160 OFEDCFLAGS=     ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
161 OFED_C_NOIMP=   ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
162 OFED_C=         ${OFED_C_NOIMP} ${.IMPSRC}
163
164 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
165 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
166 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
167 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
168 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
169 SYSTEM_OBJS+= hack.So
170 SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} --no-warn-mismatch \
171         -warn-common -export-dynamic -dynamic-linker /red/herring \
172         -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
173 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
174         ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
175 SYSTEM_DEP+= ${LDSCRIPT}
176
177 # MKMODULESENV is set here so that port makefiles can augment
178 # them.
179
180 MKMODULESENV+=  MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
181 MKMODULESENV+=  MACHINE_CPUARCH=${MACHINE_CPUARCH}
182 .if (${KERN_IDENT} == LINT)
183 MKMODULESENV+=  ALL_MODULES=LINT
184 .endif
185 .if defined(MODULES_OVERRIDE)
186 MKMODULESENV+=  MODULES_OVERRIDE="${MODULES_OVERRIDE}"
187 .endif
188 .if defined(WITHOUT_MODULES)
189 MKMODULESENV+=  WITHOUT_MODULES="${WITHOUT_MODULES}"
190 .endif
191 .if defined(DEBUG)
192 MKMODULESENV+=  DEBUG_FLAGS="${DEBUG}"
193 .endif