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