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