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