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