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