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