Makefile.i386 revision 3281
1# Copyright 1990 W. Jolitz
2#	from: @(#)Makefile.i386	7.1 5/10/91
3#	$Id: Makefile.i386,v 1.40 1994/10/01 02:55:56 davidg 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#
17# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE INVISIBLE TO MAKEFILE
18#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
19#
20# -DTRACE	compile in kernel tracing hooks
21# -DQUOTA	compile in file system quotas
22#
23TOUCH=	touch -f -c
24LD=	/usr/bin/ld
25CC=	cc 
26CPP=	cpp
27DBSYM=	/usr/sbin/dbsym
28.if defined(DEBUG)
29.if defined(NOSTRIP)
30STRIP=  echo '(skipping) strip'
31.else
32STRIP=  cp $@ $@.sym; strip
33.endif
34.else
35STRIP=  strip
36.endif
37
38.if exists(./@/.)
39S=	./@
40.else
41S=	../..
42.endif
43I386=	${S}/i386
44
45CWARNFLAGS=-W -Wreturn-type -Wcomment -Wredundant-decls
46#
47# The following flag is next up for working on:
48# -Wnested-externs 
49#
50# When working on removing warnings from code, the `-Werror' flag should be
51# of material assistance.
52#
53COPTFLAGS=-O
54INCLUDES= -I. -I$S -I$S/sys
55COPTS=	${INCLUDES} ${IDENT} -DKERNEL -Di386 -DLOAD_ADDRESS=0x${LOAD_ADDRESS}
56ASFLAGS=
57CFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
58LOAD_ADDRESS?=	F0100000
59
60NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $<
61NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
62# XXX errors leak out of all the pipes.  Should use cc *.S.
63# XXX LOCORE means "don't declare C stuff" not "for locore.s".
64NORMAL_S= ${CPP} -I. -DLOCORE ${COPTS} $< | ${AS} ${ASFLAGS} -o $*.o
65DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
66DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
67
68SFILES=	${I386}/i386/exception.s ${I386}/i386/microtime.s \
69	${I386}/i386/support.s ${I386}/i386/swtch.s ${I386}/apm/apm_setup.s
70SYSTEM_CFILES= ioconf.c param.c vnode_if.c
71SYSTEM_SFILES= ${I386}/i386/locore.s
72SYSTEM_OBJS=locore.o vnode_if.o ${OBJS} ioconf.o param.o 
73SYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS} libkern.a
74SYSTEM_LD_HEAD= 	@echo loading $@; rm -f $@
75SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o libkern.a
76SYSTEM_LD_TAIL= @echo rearranging symbols; symorder symbols.sort $@; \
77	${DBSYM} -fT ${LOAD_ADDRESS} $@; ${STRIP} -x $@; size $@; chmod 755 $@
78
79# (XXX) ok, this is weird.  but we've got a working ed, and a broken ex, and
80# the script is identical for either... -- cgd
81#
82GPROF.EX=	/usr/src/lib/csu.i386/gprof.ex
83PROFILE_C=	${CC} -S -c ${CFLAGS} $< ; \
84		ed - $*.s < ${GPROF.EX} ; \
85		${AS} -o $@ $*.s ; \
86		rm -f $*.s
87
88%OBJS
89
90%CFILES
91
92%LOAD
93
94# This is slightly different from before in that if you define PROF
95# to anything, it will assume profiling.  Don't do "PROF=" to turn
96# profiling off!
97.if exists($S/libkern/obj)
98LIBKERNP=$S/libkern/obj
99.else
100LIBKERNP=$S/libkern
101.endif
102
103.if defined(PROF)
104LIBKERN=${LIBKERNP}/libkern_p.a
105.else
106LIBKERN=${LIBKERNP}/libkern.a
107.endif
108
109libkern.a: ${LIBKERN}
110	@rm -f libkern.a
111	ln -s ${LIBKERN} libkern.a
112
113${LIBKERN}:
114	@(cd $S/libkern; make)
115
116clean:
117	rm -f eddep *kernel tags *.o locore.i [a-uw-z]*.s \
118		errs linterrs makelinks genassym ,assym.s stamp-assym
119
120#lint: /tmp param.c
121#	@lint -hbxn -I. -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \
122#	  ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \
123#	    grep -v 'struct/union .* never defined' | \
124#	    grep -v 'possible pointer alignment problem'
125
126symbols.sort: ${I386}/i386/symbols.raw
127	grep -v '^#' ${I386}/i386/symbols.raw \
128	    | sed 's/^	//' | sort -u > symbols.sort
129
130locore.o: ${I386}/i386/locore.s assym.s
131	${NORMAL_S}
132
133# everything potentially depends on the Makefile since everything potentially
134# depends on the options.  Some things are more dependent on the Makefile for
135# historical reasons.
136machdep.o: Makefile
137
138# the following is necessary because autoconf.o depends on #if GENERIC
139autoconf.o: Makefile
140
141# depend on network configuration
142af.o uipc_proto.o locore.o: Makefile
143
144# depends on KDB (cons.o also depends on GENERIC)
145trap.o cons.o: Makefile
146
147# this rule stops ./assym.s in .depend from causing problems
148./assym.s: assym.s
149
150assym.s: genassym
151	./genassym >,assym.s
152	if cmp -s assym.s ,assym.s; then \
153		rm -f ,assym.s; \
154	else \
155		rm -f assym.s; \
156		mv ,assym.s assym.s; \
157	fi
158
159# Some of the defines that genassym outputs may well depend on the 
160# value of kernel options.
161genassym:	Makefile ${I386}/i386/genassym.c
162	${CC} ${INCLUDES} -DKERNEL ${IDENT} ${PARAM} \
163		 ${I386}/i386/genassym.c -static -o genassym
164
165# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
166depend: assym.s param.c vnode_if.h
167	mkdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
168	mkdep -a -p ${INCLUDES} -DKERNEL ${IDENT} ${PARAM} \
169		${I386}/i386/genassym.c
170	MKDEP_CPP=${CPP} ; export MKDEP_CPP ; \
171	mkdep -a -I. -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
172
173links:
174	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
175	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
176	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
177	  sort -u | comm -23 - dontlink | \
178	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
179	sh makelinks && rm -f dontlink
180
181tags:
182	@echo "see $S/kern/Makefile for tags"
183
184install:
185	chflags noschg /kernel
186	mv /kernel /kernel.old
187	install -c -m 555 -o root -g wheel -fschg kernel /
188
189ioconf.o: ioconf.c $S/sys/param.h machine/pte.h $S/sys/buf.h \
190    ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h
191	${CC} -c ${CFLAGS} ioconf.c
192
193param.c: $S/conf/param.c
194	-rm -f param.c
195	cp $S/conf/param.c .
196
197param.o: param.c Makefile
198	${CC} -c ${CFLAGS} ${PARAM} param.c
199
200vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
201	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
202	${CC} ${CFLAGS} -c vers.c
203
204vnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
205	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
206vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
207	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
208
209%RULES
210
211# DO NOT DELETE THIS LINE -- make depend uses it
212