Makefile.i386 revision 25083
1# Makefile.i386 -- with config changes.
2# Copyright 1990 W. Jolitz
3#	from: @(#)Makefile.i386	7.1 5/10/91
4#	$Id: Makefile.i386,v 1.93 1997/02/22 09:31:39 peter Exp $
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
19BINFORMAT?=	aout
20#BINFORMAT?=	elf
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= ${I386}/i386/setdef0.c ioconf.c param.c vnode_if.c config.c \
58	${I386}/i386/setdef1.c
59SYSTEM_SFILES= ${I386}/i386/locore.s
60SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \
61	setdef1.o
62SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS}
63.if ${CFLAGS:M-g} == ""
64SYMORDER_EXCLUDE=-x symbols.exclude
65.endif
66SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
67.if ${BINFORMAT} == aout
68SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o
69SYSTEM_LD_TAIL= @echo rearranging symbols; \
70	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
71	size $@; chmod 755 $@
72.endif
73.if ${BINFORMAT} == elf
74SYSTEM_LD= @${LD} -Bstatic -Ttext ${LOAD_ADDRESS} -e btext -o $@ -X ${SYSTEM_OBJS} vers.o
75SYSTEM_LD_TAIL= @size $@; chmod 755 $@
76.endif
77
78%BEFORE_DEPEND
79
80%OBJS
81
82%CFILES
83
84%SFILES
85
86%LOAD
87
88%CLEAN
89
90clean:
91	rm -f *.o *.s eddep errs genassym kernel linterrs \
92	      makelinks param.c symbols.exclude symbols.sort tags \
93	      vers.c vnode_if.c vnode_if.h ${CLEAN}
94
95#lint: /tmp param.c
96#	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \
97#	  ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \
98#	    grep -v 'struct/union .* never defined' | \
99#	    grep -v 'possible pointer alignment problem'
100
101symbols.exclude: Makefile
102	echo "gcc2_compiled." >symbols.exclude
103	echo "___gnu_compiled_c" >>symbols.exclude
104
105symbols.sort: ${I386}/i386/symbols.raw
106	grep -v '^#' ${I386}/i386/symbols.raw \
107	    | sed 's/^	//' | sort -u > symbols.sort
108
109locore.o: ${I386}/i386/locore.s assym.s
110	${NORMAL_S}
111
112setdef0.o: ${I386}/i386/setdef0.c
113	${NORMAL_C}
114
115setdef1.o: ${I386}/i386/setdef1.c
116	${NORMAL_C}
117
118# everything potentially depends on the Makefile since everything potentially
119# depends on the options.  Some things are more dependent on the Makefile for
120# historical reasons.
121machdep.o: Makefile
122
123# the following is necessary because autoconf.o depends on #if GENERIC
124autoconf.o: Makefile
125
126# XXX - may no longer be needed
127locore.o: Makefile
128
129# depends on KDB (cons.o also depends on GENERIC)
130trap.o cons.o: Makefile
131
132# this rule stops ./assym.s in .depend from causing problems
133./assym.s: assym.s
134
135assym.s: genassym
136	./genassym >assym.s
137
138# Some of the defines that genassym outputs may well depend on the
139# value of kernel options.
140genassym.o: ${I386}/i386/genassym.c Makefile
141	${CC} -c ${CFLAGS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
142
143genassym: genassym.o
144	${CC} ${CFLAGS} ${PARAM} genassym.o -o $@
145
146# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
147depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND}
148	rm -f .newdep
149	mkdep -a -f .newdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
150	mkdep -a -f .newdep ${COPTS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
151	MKDEP_CPP="${CC} -E -x assembler-with-cpp" ; export MKDEP_CPP ; \
152	mkdep -a -f .newdep -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
153	rm -f .depend
154	mv -f .newdep .depend
155
156links:
157	egrep '#if' ${CFILES:Nswapkernel.c} | sed -f $S/conf/defines | \
158	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
159	echo ${CFILES:Nswapkernel.c} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
160	  sort -u | comm -23 - dontlink | \
161	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
162	sh makelinks && rm -f dontlink
163
164tags:
165	@echo "see $S/kern/Makefile for tags"
166
167install:
168	@if [ ! -f kernel ] ; then \
169		echo "You must first build your kernel before trying to install." ; \
170		exit 1 ; \
171	fi
172	chflags noschg /kernel
173	mv /kernel /kernel.old
174	if [ `/usr/sbin/sysctl -n kern.bootfile` = /kernel ] ; then \
175		/usr/sbin/sysctl -w kern.bootfile=/kernel.old ; \
176		mv -f /var/db/kvm_kernel.db /var/db/kvm_kernel.old.db ; \
177	fi
178	install -c -m 555 -o root -g wheel -fschg kernel /
179
180ioconf.o: ioconf.c $S/sys/param.h $S/sys/buf.h \
181    ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h
182	${CC} -c ${CFLAGS} ioconf.c
183
184param.c: $S/conf/param.c
185	-rm -f param.c
186	cp $S/conf/param.c .
187
188param.o: param.c Makefile
189	${CC} -c ${CFLAGS} ${PARAM} param.c
190
191vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
192	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
193	${CC} ${CFLAGS} -c vers.c
194
195vnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
196	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
197vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
198	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
199
200.include <bsd.kern.mk>
201
202%RULES
203
204# DO NOT DELETE THIS LINE -- make depend uses it
205