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