Makefile.i386 revision 6875
1# Copyright 1990 W. Jolitz
2#	from: @(#)Makefile.i386	7.1 5/10/91
3#	$Id: Makefile.i386,v 1.56 1995/03/01 10:08:04 gibbs 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#
17CC?=	cc 
18CPP?=	cpp
19LD?=	/usr/bin/ld
20
21.if exists(./@/.)
22S=	./@
23.else
24S=	../..
25.endif
26I386=	${S}/i386
27
28CWARNFLAGS?=-W -Wreturn-type -Wcomment -Wredundant-decls
29#
30# The following flags are next up for working on:
31# -Wimplicit -Wnested-externs 
32#
33# When working on removing warnings from code, the `-Werror' flag should be
34# of material assistance.
35#
36COPTFLAGS?=-O
37# Not ready for -I- yet.  #include "foo.h" where foo.h is in the srcdir fails.
38INCLUDES= -nostdinc -I. -I$S -I$S/sys -I$S/../include
39COPTS=	${INCLUDES} ${IDENT} -DKERNEL -Di386 -DLOAD_ADDRESS=0x${LOAD_ADDRESS}
40ASFLAGS=
41CFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
42LOAD_ADDRESS?=	F0100000
43
44NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $<
45NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
46# XXX errors leak out of all the pipes.  Should use cc *.S.
47# XXX LOCORE means "don't declare C stuff" not "for locore.s".
48NORMAL_S= ${CPP} -DLOCORE ${COPTS} $< | ${AS} ${ASFLAGS} -o $*.o
49DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
50DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
51PROFILE_C= ${CC} -c ${CFLAGS} ${PARAM} $<
52
53SFILES=	${I386}/i386/exception.s ${I386}/i386/microtime.s \
54	${I386}/i386/support.s ${I386}/i386/swtch.s ${I386}/apm/apm_setup.s
55SYSTEM_CFILES= ioconf.c param.c vnode_if.c
56SYSTEM_SFILES= ${I386}/i386/locore.s
57SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o 
58SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS} libkern.a
59SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
60SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o libkern.a
61.if ${CFLAGS:M-g} == ""
62SYMORDER_EXCLUDE=-x symbols.exclude
63.endif
64SYSTEM_LD_TAIL= @echo rearranging symbols; \
65	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
66	size $@; chmod 755 $@
67
68%BEFORE_DEPEND
69
70%OBJS
71
72%CFILES
73
74%LOAD
75
76%CLEAN
77
78# This is slightly different from before in that if you define PROF
79# to anything, it will assume profiling.  Don't do "PROF=" to turn
80# profiling off!
81.if exists($S/libkern/obj)
82LIBKERNP=$S/libkern/obj
83.else
84LIBKERNP=$S/libkern
85.endif
86
87.if defined(PROF)
88LIBKERN=${LIBKERNP}/libkern_p.a
89.else
90LIBKERN=${LIBKERNP}/libkern.a
91.endif
92
93libkern.a: ${LIBKERN}
94	@rm -f libkern.a
95	ln -s ${LIBKERN} libkern.a
96
97${LIBKERN}:
98	@(cd $S/libkern; make)
99
100clean:
101	rm -f eddep kernel tags *.o *.s errs linterrs makelinks genassym \
102	      symbols.exclude symbols.sort ${CLEAN}
103
104#lint: /tmp param.c
105#	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \
106#	  ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \
107#	    grep -v 'struct/union .* never defined' | \
108#	    grep -v 'possible pointer alignment problem'
109
110symbols.exclude: Makefile
111	echo "gcc2_compiled." >symbols.exclude
112	echo "___gnu_compiled_c" >>symbols.exclude
113
114symbols.sort: ${I386}/i386/symbols.raw
115	grep -v '^#' ${I386}/i386/symbols.raw \
116	    | sed 's/^	//' | sort -u > symbols.sort
117
118locore.o: ${I386}/i386/locore.s assym.s
119	${NORMAL_S}
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# depend on network configuration
130af.o uipc_proto.o locore.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
144	${CC} -c ${CFLAGS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
145
146genassym: genassym.o
147	${CC} -static ${CFLAGS} ${PARAM} genassym.o -o $@
148
149# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
150depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND}
151	mkdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
152	mkdep -a ${COPTS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
153	MKDEP_CPP=${CPP} ; export MKDEP_CPP ; \
154	mkdep -a -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
155
156links:
157	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
158	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
159	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
160	  sort -u | comm -23 - dontlink | \
161	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
162	sh makelinks && rm -f dontlink
163
164tags:
165	@echo "see $S/kern/Makefile for tags"
166
167install:
168	chflags noschg /kernel
169	mv /kernel /kernel.old
170	install -c -m 555 -o root -g wheel -fschg kernel /
171
172ioconf.o: ioconf.c $S/sys/param.h machine/pte.h $S/sys/buf.h \
173    ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h
174	${CC} -c ${CFLAGS} ioconf.c
175
176param.c: $S/conf/param.c
177	-rm -f param.c
178	cp $S/conf/param.c .
179
180param.o: param.c Makefile
181	${CC} -c ${CFLAGS} ${PARAM} param.c
182
183vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
184	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
185	${CC} ${CFLAGS} -c vers.c
186
187vnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
188	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
189vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
190	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
191
192%RULES
193
194# DO NOT DELETE THIS LINE -- make depend uses it
195