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