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