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