Deleted Added
full compact
kern.pre.mk (233644) kern.pre.mk (239272)
1# $FreeBSD: head/sys/conf/kern.pre.mk 233644 2012-03-29 02:54:35Z jmallett $
1# $FreeBSD: head/sys/conf/kern.pre.mk 239272 2012-08-15 03:21:56Z gonzo $
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.
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.
9MACHINE_CPUARCH?=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/armeb/arm/:C/powerpc64/powerpc/}
9MACHINE_CPUARCH?=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc64/powerpc/}
10
11# Can be overridden by makeoptions or /etc/make.conf
12KERNEL_KO?= kernel
13KERNEL?= kernel
14KODIR?= /boot/${KERNEL}
15LDSCRIPT_NAME?= ldscript.$M
16LDSCRIPT?= $S/conf/${LDSCRIPT_NAME}
17
18M= ${MACHINE_CPUARCH}
19
20AWK?= awk
21LINT?= lint
22NM?= nm
23OBJCOPY?= objcopy
24SIZE?= size
25
26.if defined(DEBUG)
27_MINUS_O= -O
28CTFFLAGS+= -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"
38COPTFLAGS?=-O2 -frename-registers -pipe
39.else
40COPTFLAGS?=-O2 -pipe
41.endif
42.else
43COPTFLAGS?=${_MINUS_O} -pipe
44.endif
45.if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
46COPTFLAGS+= -fno-strict-aliasing
47.endif
48.if !defined(NO_CPU_COPTFLAGS)
49COPTFLAGS+= ${_CPUCFLAGS}
50.endif
51C_DIALECT= -std=c99
52NOSTDINC= -nostdinc
53
54INCLUDES= ${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.
58INCLUDES+= -I$S/contrib/altq
59
60.if make(depend) || make(kernel-depend)
61
62# ... and the same for ipfilter
63INCLUDES+= -I$S/contrib/ipfilter
64
65# ... and the same for pf
66INCLUDES+= -I$S/contrib/pf
67
68# ... and the same for ath
69INCLUDES+= -I$S/dev/ath -I$S/dev/ath/ath_hal
70
71# ... and the same for the NgATM stuff
72INCLUDES+= -I$S/contrib/ngatm
73
74# ... and the same for twa
75INCLUDES+= -I$S/dev/twa
76
77# ... and the same for XFS
78INCLUDES+= -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
81INCLUDES+= -I$S/dev/cxgb -I$S/dev/cxgbe
82
83.endif
84
85CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS}
86CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
87.if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
88CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
89.if ${MACHINE_CPUARCH} != "mips"
90CFLAGS+= --param inline-unit-growth=100
91CFLAGS+= --param large-function-growth=1000
92.else
93# XXX Actually a gross hack just for Octeon because of the Simple Executive.
94CFLAGS+= --param inline-unit-growth=10000
95CFLAGS+= --param large-function-growth=100000
96CFLAGS+= --param max-inline-insns-single=10000
97.endif
98.endif
99WERROR?= -Werror
100
101# XXX LOCORE means "don't declare C stuff" not "for locore.s".
102ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
103
104.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang"
105CLANG_NO_IAS= -no-integrated-as
106.endif
107
108.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
109CFLAGS+= -DGPROF -falign-functions=16
110.if ${PROFLEVEL} >= 2
111CFLAGS+= -DGPROF4 -DGUPROF
112PROF= -pg -mprofiler-epilogue
113.else
114PROF= -pg
115.endif
116.endif
117DEFINED_PROF= ${PROF}
118
119# Put configuration-specific C flags last (except for ${PROF}) so that they
120# can override the others.
121CFLAGS+= ${CONF_CFLAGS}
122
123# Optional linting. This can be overridden in /etc/make.conf.
124LINTFLAGS= ${LINTOBJKERNFLAGS}
125
126NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
127NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
128PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
129NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
130
131NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
132 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
133
134# Special flags for managing the compat compiles for ZFS
135ZFS_CFLAGS= -DFREEBSD_NAMECACHE -DBUILDING_ZFS -nostdinc -I$S/cddl/compat/opensolaris -I$S/cddl/contrib/opensolaris/uts/common/fs/zfs -I$S/cddl/contrib/opensolaris/uts/common/zmod -I$S/cddl/contrib/opensolaris/uts/common -I$S -I$S/cddl/contrib/opensolaris/common/zfs -I$S/cddl/contrib/opensolaris/common ${CFLAGS} -Wno-unknown-pragmas -Wno-missing-prototypes -Wno-undef -Wno-strict-prototypes -Wno-cast-qual -Wno-parentheses -Wno-redundant-decls -Wno-missing-braces -Wno-uninitialized -Wno-unused -Wno-inline -Wno-switch -Wno-pointer-arith -Wno-unknown-pragmas
136ZFS_ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${ZFS_CFLAGS}
137ZFS_C= ${CC} -c ${ZFS_CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
138ZFS_S= ${CC} -c ${ZFS_ASM_CFLAGS} ${WERROR} ${.IMPSRC}
139
140.if ${MK_CTF} != "no"
141NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
142.elif ${MAKE_VERSION} >= 5201111300
143NORMAL_CTFCONVERT=
144.else
145NORMAL_CTFCONVERT= @:
146.endif
147
148NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
149
150# Infiniband C flags. Correct include paths and omit errors that linux
151# does not honor.
152OFEDINCLUDES= -I$S/ofed/include/
153OFEDNOERR= -Wno-cast-qual -Wno-pointer-arith -fms-extensions
154OFEDCFLAGS= ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
155OFED_C_NOIMP= ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
156OFED_C= ${OFED_C_NOIMP} ${.IMPSRC}
157
158GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
159SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
160SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
161SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
162SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
163SYSTEM_OBJS+= hack.So
164SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} \
165 -warn-common -export-dynamic -dynamic-linker /red/herring \
166 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
167SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
168 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
169SYSTEM_DEP+= ${LDSCRIPT}
170
171# MKMODULESENV is set here so that port makefiles can augment
172# them.
173
174MKMODULESENV+= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
175MKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH}
176.if (${KERN_IDENT} == LINT)
177MKMODULESENV+= ALL_MODULES=LINT
178.endif
179.if defined(MODULES_OVERRIDE)
180MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
181.endif
182.if defined(WITHOUT_MODULES)
183MKMODULESENV+= WITHOUT_MODULES="${WITHOUT_MODULES}"
184.endif
185.if defined(DEBUG)
186MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"
187.endif
10
11# Can be overridden by makeoptions or /etc/make.conf
12KERNEL_KO?= kernel
13KERNEL?= kernel
14KODIR?= /boot/${KERNEL}
15LDSCRIPT_NAME?= ldscript.$M
16LDSCRIPT?= $S/conf/${LDSCRIPT_NAME}
17
18M= ${MACHINE_CPUARCH}
19
20AWK?= awk
21LINT?= lint
22NM?= nm
23OBJCOPY?= objcopy
24SIZE?= size
25
26.if defined(DEBUG)
27_MINUS_O= -O
28CTFFLAGS+= -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"
38COPTFLAGS?=-O2 -frename-registers -pipe
39.else
40COPTFLAGS?=-O2 -pipe
41.endif
42.else
43COPTFLAGS?=${_MINUS_O} -pipe
44.endif
45.if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
46COPTFLAGS+= -fno-strict-aliasing
47.endif
48.if !defined(NO_CPU_COPTFLAGS)
49COPTFLAGS+= ${_CPUCFLAGS}
50.endif
51C_DIALECT= -std=c99
52NOSTDINC= -nostdinc
53
54INCLUDES= ${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.
58INCLUDES+= -I$S/contrib/altq
59
60.if make(depend) || make(kernel-depend)
61
62# ... and the same for ipfilter
63INCLUDES+= -I$S/contrib/ipfilter
64
65# ... and the same for pf
66INCLUDES+= -I$S/contrib/pf
67
68# ... and the same for ath
69INCLUDES+= -I$S/dev/ath -I$S/dev/ath/ath_hal
70
71# ... and the same for the NgATM stuff
72INCLUDES+= -I$S/contrib/ngatm
73
74# ... and the same for twa
75INCLUDES+= -I$S/dev/twa
76
77# ... and the same for XFS
78INCLUDES+= -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
81INCLUDES+= -I$S/dev/cxgb -I$S/dev/cxgbe
82
83.endif
84
85CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS}
86CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
87.if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
88CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
89.if ${MACHINE_CPUARCH} != "mips"
90CFLAGS+= --param inline-unit-growth=100
91CFLAGS+= --param large-function-growth=1000
92.else
93# XXX Actually a gross hack just for Octeon because of the Simple Executive.
94CFLAGS+= --param inline-unit-growth=10000
95CFLAGS+= --param large-function-growth=100000
96CFLAGS+= --param max-inline-insns-single=10000
97.endif
98.endif
99WERROR?= -Werror
100
101# XXX LOCORE means "don't declare C stuff" not "for locore.s".
102ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
103
104.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang"
105CLANG_NO_IAS= -no-integrated-as
106.endif
107
108.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
109CFLAGS+= -DGPROF -falign-functions=16
110.if ${PROFLEVEL} >= 2
111CFLAGS+= -DGPROF4 -DGUPROF
112PROF= -pg -mprofiler-epilogue
113.else
114PROF= -pg
115.endif
116.endif
117DEFINED_PROF= ${PROF}
118
119# Put configuration-specific C flags last (except for ${PROF}) so that they
120# can override the others.
121CFLAGS+= ${CONF_CFLAGS}
122
123# Optional linting. This can be overridden in /etc/make.conf.
124LINTFLAGS= ${LINTOBJKERNFLAGS}
125
126NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
127NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
128PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
129NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
130
131NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
132 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
133
134# Special flags for managing the compat compiles for ZFS
135ZFS_CFLAGS= -DFREEBSD_NAMECACHE -DBUILDING_ZFS -nostdinc -I$S/cddl/compat/opensolaris -I$S/cddl/contrib/opensolaris/uts/common/fs/zfs -I$S/cddl/contrib/opensolaris/uts/common/zmod -I$S/cddl/contrib/opensolaris/uts/common -I$S -I$S/cddl/contrib/opensolaris/common/zfs -I$S/cddl/contrib/opensolaris/common ${CFLAGS} -Wno-unknown-pragmas -Wno-missing-prototypes -Wno-undef -Wno-strict-prototypes -Wno-cast-qual -Wno-parentheses -Wno-redundant-decls -Wno-missing-braces -Wno-uninitialized -Wno-unused -Wno-inline -Wno-switch -Wno-pointer-arith -Wno-unknown-pragmas
136ZFS_ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${ZFS_CFLAGS}
137ZFS_C= ${CC} -c ${ZFS_CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
138ZFS_S= ${CC} -c ${ZFS_ASM_CFLAGS} ${WERROR} ${.IMPSRC}
139
140.if ${MK_CTF} != "no"
141NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
142.elif ${MAKE_VERSION} >= 5201111300
143NORMAL_CTFCONVERT=
144.else
145NORMAL_CTFCONVERT= @:
146.endif
147
148NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
149
150# Infiniband C flags. Correct include paths and omit errors that linux
151# does not honor.
152OFEDINCLUDES= -I$S/ofed/include/
153OFEDNOERR= -Wno-cast-qual -Wno-pointer-arith -fms-extensions
154OFEDCFLAGS= ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
155OFED_C_NOIMP= ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
156OFED_C= ${OFED_C_NOIMP} ${.IMPSRC}
157
158GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
159SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
160SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
161SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
162SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
163SYSTEM_OBJS+= hack.So
164SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} \
165 -warn-common -export-dynamic -dynamic-linker /red/herring \
166 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
167SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
168 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
169SYSTEM_DEP+= ${LDSCRIPT}
170
171# MKMODULESENV is set here so that port makefiles can augment
172# them.
173
174MKMODULESENV+= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
175MKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH}
176.if (${KERN_IDENT} == LINT)
177MKMODULESENV+= ALL_MODULES=LINT
178.endif
179.if defined(MODULES_OVERRIDE)
180MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
181.endif
182.if defined(WITHOUT_MODULES)
183MKMODULESENV+= WITHOUT_MODULES="${WITHOUT_MODULES}"
184.endif
185.if defined(DEBUG)
186MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"
187.endif