]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/conf/Makefile.i386
Reorg vm_page.c into vm_page.c, vm_pageq.c, and vm_contig.c (for contigmalloc).
[FreeBSD/FreeBSD.git] / sys / conf / Makefile.i386
1 # Makefile.i386 -- with config changes.
2 # Copyright 1990 W. Jolitz
3 #       from: @(#)Makefile.i386 7.1 5/10/91
4 # $FreeBSD$
5 #
6 # Makefile for FreeBSD
7 #
8 # This makefile is constructed from a machine description:
9 #       config machineid
10 # Most changes should be made in the machine description
11 #       /sys/i386/conf/``machineid''
12 # after which you should do
13 #        config machineid
14 # Generic makefile changes should be made in
15 #       /sys/i386/conf/Makefile.i386
16 # after which config should be rerun for all machines.
17 #
18
19 # Which version of config(8) is required.
20 %VERSREQ=       500007
21
22 # Can be overridden by makeoptions or /etc/make.conf
23 KERNEL_KO?=     kernel
24 KERNEL?=        kernel
25 KODIR?=         /boot/${KERNEL}
26 STD8X16FONT?=   iso
27
28 .if !defined(S)
29 .if exists(./@/.)
30 S=      ./@
31 .else
32 S=      ../../..
33 .endif
34 .endif
35 M=      ${MACHINE_ARCH}
36
37 SIZE?=          size
38 OBJCOPY?=       objcopy
39
40 COPTFLAGS?=-O -pipe
41 .if !defined(NO_CPU_COPTFLAGS)
42 COPTFLAGS+= ${_CPUCFLAGS}
43 .endif
44 INCLUDES= -nostdinc -I- ${INCLMAGIC} -I. -I$S -I$S/dev
45
46 # This hack lets us use the Intel ACPICA code without spamming a new 
47 # include path into 100+ source files.
48 INCLUDES+= -I$S/contrib/dev/acpica
49
50 # ... and the same for ipfilter
51 INCLUDES+= -I$S/contrib/ipfilter
52
53 # This hack is to allow kernel compiles to succeed on machines w/out srcdist
54 .if exists($S/../include)
55 INCLUDES+= -I$S/../include
56 .else
57 INCLUDES+= -I/usr/include
58 .endif
59
60 COPTS=  ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
61 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
62
63 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
64 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
65
66 # Select the correct set of tools. Can't set OBJFORMAT here because it
67 # doesn't get exported into the environment, and if it were exported
68 # then it might break building of utilities.
69 FMT=            -elf
70 CFLAGS+=        ${FMT}
71
72 DEFINED_PROF=   ${PROF}
73 .if defined(PROF)
74 CFLAGS+=        -malign-functions=4
75 .if ${PROFLEVEL} >= 2
76 IDENT+= -DGPROF4 -DGUPROF
77 PROF+=  -mprofiler-epilogue
78 .endif
79 .endif
80
81 # Put configuration-specific C flags last (except for ${PROF}) so that they
82 # can override the others.
83 CFLAGS+=        ${CONF_CFLAGS}
84
85 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
86 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
87 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
88 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
89
90 NORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \
91           ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
92
93 GEN_CFILES= $S/$M/$M/genassym.c
94 SYSTEM_CFILES= param.c vnode_if.c hints.c config.c
95 SYSTEM_SFILES= $S/$M/$M/locore.s
96 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
97 SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} param.o hints.o config.o hack.So
98 SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \
99         -export-dynamic -dynamic-linker /red/herring \
100         -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
101 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
102         ${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET}
103 SYSTEM_DEP+= $S/conf/ldscript.$M
104
105 %BEFORE_DEPEND
106
107 %OBJS
108
109 %FILES.c
110
111 %FILES.s
112
113 %FILES.m
114
115 %CLEAN
116
117 .PHONY: all modules
118
119 all: ${KERNEL_KO}
120
121 depend: kernel-depend
122 clean:  kernel-clean
123 cleandepend:  kernel-cleandepend
124 clobber: kernel-clobber
125 tags:  kernel-tags
126 install: kernel-install
127 install.debug: kernel-install.debug
128 reinstall: kernel-reinstall
129 reinstall.debug: kernel-reinstall.debug
130
131 .if !defined(DEBUG)
132 FULLKERNEL=     ${KERNEL_KO}
133 .else
134 FULLKERNEL=     ${KERNEL_KO}.debug
135 ${KERNEL_KO}: ${FULLKERNEL}
136         ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO}
137 .endif
138
139 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
140         @rm -f ${.TARGET}
141         @echo linking ${.TARGET}
142         ${SYSTEM_LD}
143         ${SYSTEM_LD_TAIL}
144
145 .if !exists(.depend)
146 ${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
147 .endif
148
149 .for mfile in ${MFILES}
150 ${mfile:T:S/.m$/.h/}: ${mfile}
151         perl5 $S/kern/makeobjops.pl -h ${mfile}
152 .endfor
153
154 kernel-clean:
155         rm -f *.o *.so *.So *.ko *.s eddep errs \
156               ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks param.c \
157               setdef[01].c setdefs.h tags \
158               vers.c vnode_if.c vnode_if.h \
159               ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
160               ${CLEAN}
161
162 kernel-clobber:
163         find . -type f ! -name version -delete
164
165 #lint: /tmp param.c
166 #       @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
167 #         $S/$M/$M/Locore.c ${CFILES} param.c | \
168 #           grep -v 'struct/union .* never defined' | \
169 #           grep -v 'possible pointer alignment problem'
170
171 locore.o: $S/$M/$M/locore.s assym.s
172         ${NORMAL_S}
173
174 # This is a hack.  BFD "optimizes" away dynamic mode if there are no
175 # dynamic references.  We could probably do a '-Bforcedynamic' mode like
176 # in the a.out ld.  For now, this works.
177 hack.So: Makefile
178         touch hack.c
179         ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So
180         rm -f hack.c
181
182 # this rule stops ./assym.s in .depend from causing problems
183 ./assym.s: assym.s
184
185 assym.s: $S/kern/genassym.sh genassym.o
186         OBJFORMAT=elf sh $S/kern/genassym.sh genassym.o > ${.TARGET}
187
188 genassym.o: $S/$M/$M/genassym.c
189         ${CC} -c ${CFLAGS} -elf $S/$M/$M/genassym.c
190
191 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
192
193 kernel-depend:
194         rm -f .olddep
195         if [ -f .depend ]; then mv .depend .olddep; fi
196         ${MAKE} _kernel-depend
197
198 _kernel-depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \
199             ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
200             ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
201         if [ -f .olddep ]; then mv .olddep .depend; fi
202         rm -f .newdep
203         mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES}
204         env MKDEP_CPP="${CC} -E" \
205             mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES}
206         rm -f .depend
207         mv .newdep .depend
208
209 kernel-cleandepend:
210         rm -f .depend
211
212 links:
213         egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
214           sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
215         echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
216           sort -u | comm -23 - dontlink | \
217           sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
218         sh makelinks; rm -f dontlink
219
220 kernel-tags:
221         @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
222         sh $S/conf/systags.sh
223         rm -f tags1
224         sed -e 's,      ../,    ,' tags > tags1
225
226 kernel-install kernel-install.debug:
227 .if exists(${DESTDIR}/boot)
228         @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \
229                 echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \
230                 exit 1 ; \
231         fi
232         @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \
233                 echo "You must activate /boot/device.hints in loader.conf." ; \
234                 exit 1 ; \
235         fi
236 .endif
237         @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \
238                 echo "You must build a kernel first." ; \
239                 exit 1 ; \
240         fi
241 .if exists(${DESTDIR}${KODIR})
242 .if exists(${DESTDIR}${KODIR}.old)
243         @-chflags -R noschg ${DESTDIR}${KODIR}.old
244         -rm -rf ${DESTDIR}${KODIR}.old
245 .endif
246         mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old
247 .endif
248         mkdir -p ${DESTDIR}${KODIR}
249         install -c -m 555 -o root -g wheel \
250                 ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR}
251
252 kernel-reinstall kernel-reinstall.debug:
253         @-chflags -R noschg ${DESTDIR}${KODIR}
254         install -c -m 555 -o root -g wheel \
255                 ${KERNEL_KO}${.TARGET:S/kernel-reinstall//} ${DESTDIR}${KODIR}
256
257 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
258 all:    modules
259 depend: modules-depend
260 clean:  modules-clean
261 cleandepend:  modules-cleandepend
262 cleandir:  modules-cleandir
263 clobber:  modules-clobber
264 tags:  modules-tags
265 install: modules-install
266 install.debug: modules-install.debug
267 reinstall: modules-reinstall
268 reinstall.debug: modules-reinstall.debug
269 .endif
270
271 MKMODULESENV=   MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
272 .if defined(MODULES_OVERRIDE)
273 MKMODULESENV+=  MODULES_OVERRIDE="${MODULES_OVERRIDE}"
274 .endif
275
276 modules:
277         @mkdir -p ${.OBJDIR}/modules
278         cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
279             env ${MKMODULESENV} ${MAKE} all
280
281 modules-depend:
282         @mkdir -p ${.OBJDIR}/modules
283         cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
284             env ${MKMODULESENV} ${MAKE} depend
285
286 modules-clean:
287         cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean
288
289 modules-cleandepend:
290         cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend
291
292 modules-clobber:        modules-clean
293         rm -rf ${MKMODULESENV}
294
295 modules-cleandir:
296         cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir
297
298 modules-tags:
299         cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags
300
301 modules-install modules-install.debug:
302         cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
303
304 modules-reinstall modules-reinstall.debug:
305         cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
306
307 config.o:
308         ${NORMAL_C}
309
310 param.c: $S/conf/param.c
311         -rm -f param.c
312         cp $S/conf/param.c .
313
314 param.o:
315         ${NORMAL_C}
316
317 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
318         sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
319
320 # XXX strictly, everything depends on Makefile because changes to ${PROF}
321 # only appear there, but we don't handle that.
322 vers.o:
323         ${NORMAL_C}
324
325 hints.o:        hints.c
326         ${NORMAL_C}
327
328 vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src
329         perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src
330
331 vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src
332         perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src
333
334 vnode_if.o:
335         ${NORMAL_C}
336
337 # Commented out for now pending a better solution.
338 # How do we pick up compiler version specific flags??
339 #.if exists($S/../share/mk)
340 #.include "$S/../share/mk/bsd.kern.mk"
341 #.else
342 .include <bsd.kern.mk>
343 #.endif
344
345 %RULES
346
347 # DO NOT DELETE THIS LINE -- make depend uses it