Makefile.i386 revision 12880
142120Sdes# Copyright 1990 W. Jolitz
242120Sdes#	from: @(#)Makefile.i386	7.1 5/10/91
342120Sdes#	$Id: Makefile.i386,v 1.70 1995/11/19 19:49:43 davidg Exp $
442120Sdes#
542120Sdes# Makefile for FreeBSD
642120Sdes#
742120Sdes# This makefile is constructed from a machine description:
842120Sdes#	config machineid
942120Sdes# Most changes should be made in the machine description
1042120Sdes#	/sys/i386/conf/``machineid''
1142120Sdes# after which you should do
1242120Sdes#	 config machineid
1342120Sdes# Generic makefile changes should be made in
1442120Sdes#	/sys/i386/conf/Makefile.i386
1542120Sdes# after which config should be rerun for all machines.
1642120Sdes#
1742120SdesCC?=	cc
1842120SdesCPP?=	cpp
1942120SdesLD?=	/usr/bin/ld
2042120Sdes
2142120Sdes.if exists(./@/.)
2242120SdesS=	./@
2342120Sdes.else
2442120SdesS=	../..
2542120Sdes.endif
2642120SdesI386=	${S}/i386
2742120Sdes
2848104SyokotaCWARNFLAGS?=	-W -Wreturn-type -Wcomment -Wredundant-decls -Wimplicit \
2942120Sdes		-Wnested-externs -Wstrict-prototypes -Wmissing-prototypes \
3042120Sdes		-Winline
3142120Sdes#
3242120Sdes# The following flags are next up for working on:
3342120Sdes#	-Wall
3442120Sdes#
3542120Sdes# When working on removing warnings from code, the `-Werror' flag should be
3648104Syokota# of material assistance.
3748104Syokota#
3842120SdesCOPTFLAGS?=-O
3948104Syokota# Not ready for -I- yet.  #include "foo.h" where foo.h is in the srcdir fails.
4048104SyokotaINCLUDES= -nostdinc -I. -I$S -I$S/sys
4148104Syokota# This hack is to allow kernel compiles to succeed on machines w/out srcdist
4242120Sdes.if exists($S/../include)
4342120SdesINCLUDES+= -I$S/../include
4443673Sdes.else
4542504SyokotaINCLUDES+= -I/usr/include
4642120Sdes.endif
4742120SdesCOPTS=	${INCLUDES} ${IDENT} -DKERNEL
4842120SdesASFLAGS=
4942120SdesCFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
5042504SyokotaLOAD_ADDRESS?=	F0100000
5142120Sdes
5242120SdesNORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $<
5342120SdesNORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
5443673Sdes# XXX errors leak out of all the pipes.  Should use cc *.S.
5542120Sdes# XXX LOCORE means "don't declare C stuff" not "for locore.s".
5642504SyokotaNORMAL_S= ${CPP} -DLOCORE ${COPTS} $< | ${AS} ${ASFLAGS} -o $*.o
5742120SdesDRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
5842120SdesDRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
5942120SdesDRIVER_S= ${CPP} -DLOCORE ${COPTS} $< | ${AS} ${ASFLAGS} -o $*.o
6042120SdesPROFILE_C= ${CC} -c ${CFLAGS} ${PARAM} $<
6143673Sdes
6242120SdesSYSTEM_CFILES= ioconf.c param.c vnode_if.c
6342120SdesSYSTEM_SFILES= ${I386}/i386/locore.s
6442120SdesSYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o
6542504SyokotaSYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS} libkern.a
6642120SdesSYSTEM_LD_HEAD= @echo loading $@; rm -f $@
6743673SdesSYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o libkern.a
6842120Sdes.if ${CFLAGS:M-g} == ""
6942120SdesSYMORDER_EXCLUDE=-x symbols.exclude
7042504Syokota.endif
7142120SdesSYSTEM_LD_TAIL= @echo rearranging symbols; \
7243673Sdes	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
7342120Sdes	size $@; chmod 755 $@
7442120Sdes
7542120Sdes%BEFORE_DEPEND
7642120Sdes
7742120Sdes%OBJS
7842504Syokota
7942120Sdes%CFILES
8042120Sdes
8142120Sdes%SFILES
8242120Sdes
8342120Sdes%LOAD
8442236Sdes
8542236Sdes%CLEAN
8642236Sdes
8742236Sdes# This is slightly different from before in that if you define PROF
8842236Sdes# to anything, it will assume profiling.  Don't do "PROF=" to turn
8942236Sdes# profiling off!
9042120Sdes.if exists($S/libkern/obj)
9142120SdesLIBKERNP=$S/libkern/obj
9242504Syokota.else
9342120SdesLIBKERNP=$S/libkern
9442120Sdes.endif
9542504Syokota
9642504Syokota.if defined(PROF)
9742120SdesLIBKERN=${LIBKERNP}/libkern_p.a
9842236Sdes.else
9942120SdesLIBKERN=${LIBKERNP}/libkern.a
10042120Sdes.endif
10142120Sdes
10242504Syokotalibkern.a: ${LIBKERN}
10342120Sdes	@rm -f libkern.a
10445616Sdes	ln -s ${LIBKERN} libkern.a
10545616Sdes
10645616Sdes${LIBKERN}:
10745616Sdes	@(cd $S/libkern; make)
10845616Sdes
10942504Syokotaclean:
11042504Syokota	rm -f *.o *.s eddep errs genassym kernel libkern.a linterrs \
11148104Syokota	      makelinks param.c symbols.exclude symbols.sort tags \
11243673Sdes	      vers.c vnode_if.c vnode_if.h ${CLEAN}
11342120Sdes
11443673Sdes#lint: /tmp param.c
11542504Syokota#	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \
11642236Sdes#	  ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \
11742236Sdes#	    grep -v 'struct/union .* never defined' | \
11842120Sdes#	    grep -v 'possible pointer alignment problem'
11942504Syokota
12042120Sdessymbols.exclude: Makefile
12142504Syokota	echo "gcc2_compiled." >symbols.exclude
12242120Sdes	echo "___gnu_compiled_c" >>symbols.exclude
12342504Syokota
12442120Sdessymbols.sort: ${I386}/i386/symbols.raw
12542120Sdes	grep -v '^#' ${I386}/i386/symbols.raw \
12642120Sdes	    | sed 's/^	//' | sort -u > symbols.sort
12742504Syokota
12842120Sdeslocore.o: ${I386}/i386/locore.s assym.s
12942120Sdes	${NORMAL_S}
13042236Sdes
13142504Syokota# everything potentially depends on the Makefile since everything potentially
13242236Sdes# depends on the options.  Some things are more dependent on the Makefile for
13342504Syokota# historical reasons.
13442236Sdesmachdep.o: Makefile
13542236Sdes
13642236Sdes# the following is necessary because autoconf.o depends on #if GENERIC
13742120Sdesautoconf.o: Makefile
13842120Sdes
13942120Sdes# depend on network configuration
14042236Sdesaf.o uipc_proto.o locore.o: Makefile
14142236Sdes
14242504Syokota# depends on KDB (cons.o also depends on GENERIC)
14342236Sdestrap.o cons.o: Makefile
14442504Syokota
14542120Sdes# this rule stops ./assym.s in .depend from causing problems
14642120Sdes./assym.s: assym.s
14742120Sdes
14842504Syokotaassym.s: genassym
14942120Sdes	./genassym >assym.s
15042504Syokota
15142120Sdes# Some of the defines that genassym outputs may well depend on the
15242120Sdes# value of kernel options.
15342504Syokotagenassym.o: ${I386}/i386/genassym.c Makefile
15442504Syokota	${CC} -c ${CFLAGS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
15542504Syokota
15642504Syokotagenassym: genassym.o
15742504Syokota	${CC} -static ${CFLAGS} ${PARAM} genassym.o -o $@
158
159# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
160depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND}
161	mkdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
162	mkdep -a ${COPTS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
163	MKDEP_CPP=${CPP} ; export MKDEP_CPP ; \
164	mkdep -a -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
165
166links:
167	egrep '#if' ${CFILES:Nswapkernel.c} | sed -f $S/conf/defines | \
168	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
169	echo ${CFILES:Nswapkernel.c} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
170	  sort -u | comm -23 - dontlink | \
171	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
172	sh makelinks && rm -f dontlink
173
174tags:
175	@echo "see $S/kern/Makefile for tags"
176
177install:
178	chflags noschg /kernel
179	mv /kernel /kernel.old
180	sysctl -w kern.bootfile=/kernel.old
181	install -c -m 555 -o root -g wheel -fschg kernel /
182
183ioconf.o: ioconf.c $S/sys/param.h machine/pte.h $S/sys/buf.h \
184    ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h
185	${CC} -c ${CFLAGS} ioconf.c
186
187param.c: $S/conf/param.c
188	-rm -f param.c
189	cp $S/conf/param.c .
190
191param.o: param.c Makefile
192	${CC} -c ${CFLAGS} ${PARAM} param.c
193
194vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
195	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
196	${CC} ${CFLAGS} -c vers.c
197
198vnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
199	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
200vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
201	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
202
203%RULES
204
205# DO NOT DELETE THIS LINE -- make depend uses it
206