Makefile.i386 revision 22975
1# Makefile.i386 -- with config changes.
2# Copyright 1990 W. Jolitz
3#	from: @(#)Makefile.i386	7.1 5/10/91
4#	$Id$
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#
18CC?=	cc
19CPP?=	cpp
20LD?=	/usr/bin/ld
21
22.if exists(./@/.)
23S=	./@
24.else
25S=	../..
26.endif
27I386=	${S}/i386
28
29COPTFLAGS?=-O
30INCLUDES= -nostdinc -I- -I. -I$S
31# This hack is to allow kernel compiles to succeed on machines w/out srcdist
32.if exists($S/../include)
33INCLUDES+= -I$S/../include
34.else
35INCLUDES+= -I/usr/include
36.endif
37COPTS=	${INCLUDES} ${IDENT} -DKERNEL
38CFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
39LOAD_ADDRESS?=	F0100000
40.if defined(PROF)
41PROF+=	-malign-functions=4
42.if ${PROFLEVEL} >= 2
43IDENT+=	-DGPROF4 -DGUPROF
44PROF+=	-mprofiler-epilogue
45.endif
46.endif
47
48NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $<
49NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
50# XXX LOCORE means "don't declare C stuff" not "for locore.s".
51NORMAL_S= ${CC} -c -x assembler-with-cpp -DLOCORE ${COPTS} $<
52DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
53DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
54DRIVER_S= ${CC} -c -x assembler-with-cpp -DLOCORE ${COPTS} $<
55PROFILE_C= ${CC} -c ${CFLAGS} ${PARAM} $<
56
57SYSTEM_CFILES= ioconf.c param.c vnode_if.c config.c
58SYSTEM_SFILES= ${I386}/i386/locore.s
59SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o config.o
60SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS}
61SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
62SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o
63.if ${CFLAGS:M-g} == ""
64SYMORDER_EXCLUDE=-x symbols.exclude
65.endif
66SYSTEM_LD_TAIL= @echo rearranging symbols; \
67	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
68	size $@; chmod 755 $@
69
70%BEFORE_DEPEND
71
72%OBJS
73
74%CFILES
75
76%SFILES
77
78%LOAD
79
80%CLEAN
81
82clean:
83	rm -f *.o *.s eddep errs genassym kernel linterrs \
84	      makelinks param.c symbols.exclude symbols.sort tags \
85	      vers.c vnode_if.c vnode_if.h ${CLEAN}
86
87#lint: /tmp param.c
88#	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \
89#	  ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \
90#	    grep -v 'struct/union .* never defined' | \
91#	    grep -v 'possible pointer alignment problem'
92
93symbols.exclude: Makefile
94	echo "gcc2_compiled." >symbols.exclude
95	echo "___gnu_compiled_c" >>symbols.exclude
96
97symbols.sort: ${I386}/i386/symbols.raw
98	grep -v '^#' ${I386}/i386/symbols.raw \
99	    | sed 's/^	//' | sort -u > symbols.sort
100
101locore.o: ${I386}/i386/locore.s assym.s
102	${NORMAL_S}
103
104# everything potentially depends on the Makefile since everything potentially
105# depends on the options.  Some things are more dependent on the Makefile for
106# historical reasons.
107machdep.o: Makefile
108
109# the following is necessary because autoconf.o depends on #if GENERIC
110autoconf.o: Makefile
111
112# XXX - may no longer be needed
113locore.o: Makefile
114
115# depends on KDB (cons.o also depends on GENERIC)
116trap.o cons.o: Makefile
117
118# this rule stops ./assym.s in .depend from causing problems
119./assym.s: assym.s
120
121assym.s: genassym
122	./genassym >assym.s
123
124# Some of the defines that genassym outputs may well depend on the
125# value of kernel options.
126genassym.o: ${I386}/i386/genassym.c Makefile
127	${CC} -c ${CFLAGS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
128
129genassym: genassym.o
130	${CC} ${CFLAGS} ${PARAM} genassym.o -o $@
131
132# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
133depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND}
134	rm -f .newdep
135	mkdep -a -f .newdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
136	mkdep -a -f .newdep ${COPTS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
137	MKDEP_CPP="${CPP}" ; export MKDEP_CPP ; \
138	mkdep -a -f .newdep -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
139	rm -f .depend
140	mv -f .newdep .depend
141
142links:
143	egrep '#if' ${CFILES:Nswapkernel.c} | sed -f $S/conf/defines | \
144	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
145	echo ${CFILES:Nswapkernel.c} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
146	  sort -u | comm -23 - dontlink | \
147	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
148	sh makelinks && rm -f dontlink
149
150tags:
151	@echo "see $S/kern/Makefile for tags"
152
153install:
154	@if [ ! -f kernel ] ; then \
155		echo "You must first build your kernel before trying to install." ; \
156		exit 1 ; \
157	fi
158	chflags noschg /kernel
159	mv /kernel /kernel.old
160	if [ `/usr/sbin/sysctl -n kern.bootfile` = /kernel ] ; then \
161		/usr/sbin/sysctl -w kern.bootfile=/kernel.old ; \
162		mv -f /var/db/kvm_kernel.db /var/db/kvm_kernel.old.db ; \
163	fi
164	install -c -m 555 -o root -g wheel -fschg kernel /
165
166ioconf.o: ioconf.c $S/sys/param.h $S/sys/buf.h \
167    ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h
168	${CC} -c ${CFLAGS} ioconf.c
169
170param.c: $S/conf/param.c
171	-rm -f param.c
172	cp $S/conf/param.c .
173
174param.o: param.c Makefile
175	${CC} -c ${CFLAGS} ${PARAM} param.c
176
177vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
178	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
179	${CC} ${CFLAGS} -c vers.c
180
181vnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
182	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
183vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
184	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
185
186.include <bsd.kern.mk>
187
188%RULES
189
190# DO NOT DELETE THIS LINE -- make depend uses it
191