]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - sys/conf/kern.pre.mk
MFC 227429,228121,228124,228137,228140,228141,228147,228153,228158,228311,
[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
8 # backwards compat option for older systems.
9 MACHINE_CPUARCH?=${MACHINE_ARCH:C/mipse[lb]/mips/:C/armeb/arm/:C/powerpc64/powerpc/}
10
11 # Can be overridden by makeoptions or /etc/make.conf
12 KERNEL_KO?=     kernel
13 KERNEL?=        kernel
14 KODIR?=         /boot/${KERNEL}
15 LDSCRIPT_NAME?= ldscript.$M
16 LDSCRIPT?=      $S/conf/${LDSCRIPT_NAME}
17
18 M=              ${MACHINE_CPUARCH}
19
20 AWK?=           awk
21 CP?=            cp
22 LINT?=          lint
23 NM?=            nm
24 OBJCOPY?=       objcopy
25 SIZE?=          size
26
27 .if defined(DEBUG)
28 _MINUS_O=       -O
29 CTFFLAGS+=      -g
30 .else
31 .if ${MACHINE_CPUARCH} == "powerpc"
32 _MINUS_O=       -O      # gcc miscompiles some code at -O2
33 .else
34 _MINUS_O=       -O2
35 .endif
36 .endif
37 .if ${MACHINE_CPUARCH} == "amd64"
38 .if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
39 COPTFLAGS?=-O2 -frename-registers -pipe
40 .else
41 COPTFLAGS?=-O2 -pipe
42 .endif
43 .else
44 COPTFLAGS?=${_MINUS_O} -pipe
45 .endif
46 .if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
47 COPTFLAGS+= -fno-strict-aliasing
48 .endif
49 .if !defined(NO_CPU_COPTFLAGS)
50 COPTFLAGS+= ${_CPUCFLAGS}
51 .endif
52 C_DIALECT= -std=c99
53 NOSTDINC= -nostdinc
54
55 INCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S
56
57 # This hack lets us use the OpenBSD altq code without spamming a new
58 # include path into contrib'ed source files.
59 INCLUDES+= -I$S/contrib/altq
60
61 .if make(depend) || make(kernel-depend)
62
63 # ... and the same for ipfilter
64 INCLUDES+= -I$S/contrib/ipfilter
65
66 # ... and the same for pf
67 INCLUDES+= -I$S/contrib/pf
68
69 # ... and the same for ath
70 INCLUDES+= -I$S/dev/ath -I$S/dev/ath/ath_hal
71
72 # ... and the same for the NgATM stuff
73 INCLUDES+= -I$S/contrib/ngatm
74
75 # ... and the same for twa
76 INCLUDES+= -I$S/dev/twa
77
78 # ... and the same for XFS
79 INCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs
80
81 # ... and the same for cxgb and cxgbe
82 INCLUDES+= -I$S/dev/cxgb -I$S/dev/cxgbe
83
84 .endif
85
86 CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS}
87 CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
88 .if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
89 CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
90 .if ${MACHINE_CPUARCH} != "mips"
91 CFLAGS+= --param inline-unit-growth=100
92 CFLAGS+= --param large-function-growth=1000
93 .else
94 # XXX Actually a gross hack just for Octeon because of the Simple Executive.
95 CFLAGS+= --param inline-unit-growth=10000
96 CFLAGS+= --param large-function-growth=100000
97 CFLAGS+= --param max-inline-insns-single=10000
98 .endif
99 .endif
100 WERROR?= -Werror
101
102 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
103 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
104
105 .if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang"
106 CLANG_NO_IAS= -no-integrated-as
107 .endif
108
109 .if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
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 .elif ${MAKE_VERSION} >= 5201111300
142 NORMAL_CTFCONVERT=
143 .else
144 NORMAL_CTFCONVERT=      @:
145 .endif
146
147 NORMAL_LINT=    ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
148
149 # Infiniband C flags.  Correct include paths and omit errors that linux
150 # does not honor.
151 OFEDINCLUDES=   -I$S/ofed/include/
152 OFEDNOERR=      -Wno-cast-qual -Wno-pointer-arith -fms-extensions
153 OFEDCFLAGS=     ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
154 OFED_C_NOIMP=   ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
155 OFED_C=         ${OFED_C_NOIMP} ${.IMPSRC}
156
157 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
158 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
159 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
160 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
161 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
162 SYSTEM_OBJS+= hack.So
163 SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} --no-warn-mismatch \
164         -warn-common -export-dynamic -dynamic-linker /red/herring \
165         -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
166 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
167         ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
168 SYSTEM_DEP+= ${LDSCRIPT}
169
170 # MKMODULESENV is set here so that port makefiles can augment
171 # them.
172
173 MKMODULESENV+=  MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
174 MKMODULESENV+=  MACHINE_CPUARCH=${MACHINE_CPUARCH}
175 .if (${KERN_IDENT} == LINT)
176 MKMODULESENV+=  ALL_MODULES=LINT
177 .endif
178 .if defined(MODULES_OVERRIDE)
179 MKMODULESENV+=  MODULES_OVERRIDE="${MODULES_OVERRIDE}"
180 .endif
181 .if defined(WITHOUT_MODULES)
182 MKMODULESENV+=  WITHOUT_MODULES="${WITHOUT_MODULES}"
183 .endif
184 .if defined(DEBUG)
185 MKMODULESENV+=  DEBUG_FLAGS="${DEBUG}"
186 .endif