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