]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/conf/kern.pre.mk
Add support for generating CTF data for the kernel.
[FreeBSD/FreeBSD.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 SRCCONF?=       /etc/src.conf
7 .if exists(${SRCCONF})
8 .include "${SRCCONF}"
9 .endif
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_ARCH}
19
20 AWK?=           awk
21 LINT?=          lint
22 NM?=            nm
23 OBJCOPY?=       objcopy
24 SIZE?=          size
25
26 .if ${CC} == "icc"
27 COPTFLAGS?=     -O
28 .else
29 . if defined(DEBUG)
30 _MINUS_O=       -O
31 . else
32 _MINUS_O=       -O2
33 . endif
34 . if ${MACHINE_ARCH} == "amd64"
35 COPTFLAGS?=-O2 -frename-registers -pipe
36 . elif ${MACHINE_ARCH} == "sparc64"
37 COPTFLAGS?=-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 .endif
45 .if !defined(NO_CPU_COPTFLAGS)
46 . if ${CC} == "icc"
47 COPTFLAGS+= ${_ICC_CPUCFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
48 . else
49 COPTFLAGS+= ${_CPUCFLAGS}
50 . endif
51 .endif
52 .if ${CC} == "icc"
53 C_DIALECT=
54 NOSTDINC= -X
55 .else
56 C_DIALECT= -std=c99
57 NOSTDINC= -nostdinc
58 .endif
59
60 INCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S
61
62 # This hack lets us use the OpenBSD altq code without spamming a new
63 # include path into contrib'ed source files.
64 INCLUDES+= -I$S/contrib/altq
65
66 .if make(depend) || make(kernel-depend)
67
68 # ... and the same for ipfilter
69 INCLUDES+= -I$S/contrib/ipfilter
70
71 # ... and the same for pf
72 INCLUDES+= -I$S/contrib/pf
73
74 # ... and the same for Atheros HAL
75 INCLUDES+= -I$S/dev/ath
76
77 # ... and the same for the NgATM stuff
78 INCLUDES+= -I$S/contrib/ngatm
79
80 # .. and the same for twa
81 INCLUDES+= -I$S/dev/twa
82
83 # ...  and XFS
84 INCLUDES+= -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs
85
86 # ...  and OpenSolaris
87 INCLUDES+= -I$S/contrib/opensolaris/compat
88
89 .endif
90
91 CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS}
92 CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
93 .if ${CC} != "icc"
94 CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
95 CFLAGS+= --param inline-unit-growth=100
96 CFLAGS+= --param large-function-growth=1000
97 WERROR?= -Werror
98 .endif
99
100 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
101 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
102
103 .if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
104 .if ${CC} == "icc"
105 .error "Profiling doesn't work with icc yet"
106 .endif
107 CFLAGS+=        -DGPROF -falign-functions=16
108 .if ${PROFLEVEL} >= 2
109 CFLAGS+=        -DGPROF4 -DGUPROF
110 PROF=   -pg -mprofiler-epilogue
111 .else
112 PROF=   -pg
113 .endif
114 .endif
115 DEFINED_PROF=   ${PROF}
116
117 # Put configuration-specific C flags last (except for ${PROF}) so that they
118 # can override the others.
119 CFLAGS+=        ${CONF_CFLAGS}
120
121 # Optional linting. This can be overridden in /etc/make.conf.
122 LINTFLAGS=      ${LINTOBJKERNFLAGS}
123
124 NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
125 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
126 PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
127 NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
128
129 NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
130           ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
131
132 .if defined(CTFCONVERT)
133 NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
134 .else
135 NORMAL_CTFCONVERT=
136 .endif
137
138 NORMAL_LINT=    ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
139
140 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
141 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
142 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
143 SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
144 SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
145 SYSTEM_OBJS+= hack.So
146 .if defined(CTFMERGE)
147 SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJS} vers.o
148 LD+= -g
149 .endif
150 SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} \
151         -warn-common -export-dynamic -dynamic-linker /red/herring \
152         -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
153 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
154         ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
155 SYSTEM_DEP+= ${LDSCRIPT}
156
157 # MKMODULESENV is set here so that port makefiles can augment
158 # them.
159
160 MKMODULESENV=   MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
161 .if (${KERN_IDENT} == LINT)
162 MKMODULESENV+=  ALL_MODULES=LINT
163 .endif
164 .if defined(MODULES_OVERRIDE)
165 MKMODULESENV+=  MODULES_OVERRIDE="${MODULES_OVERRIDE}"
166 .endif
167 .if defined(DEBUG)
168 MKMODULESENV+=  DEBUG_FLAGS="${DEBUG}"
169 .endif