Makefile.i386 revision 2627
1# Copyright 1990 W. Jolitz
2#	from: @(#)Makefile.i386	7.1 5/10/91
3#	$Id: Makefile.i386,v 1.35 1994/09/05 19:10:01 jkh 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
104${LIBKERN}:
105	@(cd $S/libkern; make)
106
107clean:
108	rm -f eddep *kernel tags *.o locore.i [a-uw-z]*.s \
109		errs linterrs makelinks genassym ,assym.s stamp-assym
110
111#lint: /tmp param.c
112#	@lint -hbxn -I. -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.sort: ${I386}/i386/symbols.raw
118	grep -v '^#' ${I386}/i386/symbols.raw \
119	    | sed 's/^	//' | sort -u > symbols.sort
120
121locore.o: ${I386}/i386/locore.s assym.s
122	${NORMAL_S}
123
124# everything potentially depends on the Makefile since everything potentially
125# depends on the options.  Some things are more dependent on the Makefile for
126# historical reasons.
127machdep.o: Makefile
128
129# the following is necessary because autoconf.o depends on #if GENERIC
130autoconf.o: Makefile
131
132# depend on network configuration
133af.o uipc_proto.o locore.o: Makefile
134
135# depends on KDB (cons.o also depends on GENERIC)
136trap.o cons.o: Makefile
137
138# this rule stops ./assym.s in .depend from causing problems
139./assym.s: assym.s
140
141assym.s: genassym
142	./genassym >,assym.s
143	if cmp -s assym.s ,assym.s; then \
144		rm -f ,assym.s; \
145	else \
146		rm -f assym.s; \
147		mv ,assym.s assym.s; \
148	fi
149
150# Some of the defines that genassym outputs may well depend on the 
151# value of kernel options.
152genassym:	Makefile
153	${CC} ${INCLUDES} -DKERNEL ${IDENT} ${PARAM} \
154		 ${I386}/i386/genassym.c -static -o genassym
155
156# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
157depend: assym.s param.c vnode_if.h
158	mkdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
159	mkdep -a -p ${INCLUDES} -DKERNEL ${IDENT} ${PARAM} \
160		${I386}/i386/genassym.c
161	MKDEP_CPP=${CPP} ; export MKDEP_CPP ; \
162	mkdep -a -I. -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
163
164links:
165	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
166	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
167	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
168	  sort -u | comm -23 - dontlink | \
169	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
170	sh makelinks && rm -f dontlink
171
172tags:
173	@echo "see $S/kern/Makefile for tags"
174
175install:
176	mv /kernel /kernel.old
177	install -c -m 555 -o root -g wheel -fschg kernel /
178
179ioconf.o: ioconf.c $S/sys/param.h machine/pte.h $S/sys/buf.h \
180    ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h
181	${CC} -c ${CFLAGS} ioconf.c
182
183param.c: $S/conf/param.c
184	-rm -f param.c
185	cp $S/conf/param.c .
186
187param.o: param.c Makefile
188	${CC} -c ${CFLAGS} ${PARAM} param.c
189
190vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
191	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
192	${CC} ${CFLAGS} -c vers.c
193
194vnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
195	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
196vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
197	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
198
199%RULES
200
201# DO NOT DELETE THIS LINE -- make depend uses it
202