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