Makefile.i386 revision 2823
11590Srgrimes# Copyright 1990 W. Jolitz
21590Srgrimes#	from: @(#)Makefile.i386	7.1 5/10/91
31590Srgrimes#	$Id: Makefile.i386,v 1.36 1994/09/09 22:03:51 wollman Exp $
41590Srgrimes#
51590Srgrimes# Makefile for FreeBSD
61590Srgrimes#
71590Srgrimes# This makefile is constructed from a machine description:
81590Srgrimes#	config machineid
91590Srgrimes# Most changes should be made in the machine description
101590Srgrimes#	/sys/i386/conf/``machineid''
111590Srgrimes# after which you should do
121590Srgrimes#	 config machineid
131590Srgrimes# Generic makefile changes should be made in
141590Srgrimes#	/sys/i386/conf/Makefile.i386
151590Srgrimes# after which config should be rerun for all machines.
161590Srgrimes#
171590Srgrimes# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE INVISIBLE TO MAKEFILE
181590Srgrimes#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
191590Srgrimes#
201590Srgrimes# -DTRACE	compile in kernel tracing hooks
211590Srgrimes# -DQUOTA	compile in file system quotas
221590Srgrimes#
231590SrgrimesTOUCH=	touch -f -c
241590SrgrimesLD=	/usr/bin/ld
251590SrgrimesCC=	cc 
261590SrgrimesCPP=	cpp
271590SrgrimesDBSYM=	/usr/sbin/dbsym
281590Srgrimes
291590Srgrimes.if exists(./@/.)
301590SrgrimesS=	./@
311590Srgrimes.else
321590SrgrimesS=	../..
331590Srgrimes.endif
341590SrgrimesI386=	${S}/i386
3514440Smarkm
361590SrgrimesCWARNFLAGS=-W -Wreturn-type -Wcomment -Wredundant-decls
371590Srgrimes#
381590Srgrimes# The following flag is next up for working on:
391590Srgrimes# -Wnested-externs 
401590Srgrimes#
4128099Scharnier# When working on removing warnings from code, the `-Werror' flag should be
421590Srgrimes# of material assistance.
4328099Scharnier#
4414440SmarkmCOPTFLAGS=-O
4550477SpeterINCLUDES= -I. -I$S -I$S/sys
461590SrgrimesCOPTS=	${INCLUDES} ${IDENT} -DKERNEL -Di386 -DLOAD_ADDRESS=0x${LOAD_ADDRESS}
471590SrgrimesASFLAGS=
481590SrgrimesCFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
491590SrgrimesLOAD_ADDRESS?=	F0100000
501590Srgrimes
511590SrgrimesNORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $<
521590SrgrimesNORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
531590Srgrimes# XXX errors leak out of all the pipes.  Should use cc *.S.
541590Srgrimes# XXX LOCORE means "don't declare C stuff" not "for locore.s".
551590SrgrimesNORMAL_S= ${CPP} -I. -DLOCORE ${COPTS} $< | ${AS} ${ASFLAGS} -o $*.o
561590SrgrimesDRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
571590SrgrimesDRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
581590Srgrimes
591590SrgrimesSFILES=	${I386}/i386/exception.s ${I386}/i386/microtime.s \
601590Srgrimes	${I386}/i386/support.s ${I386}/i386/swtch.s
611590SrgrimesSYSTEM_CFILES= ioconf.c param.c vnode_if.c
6240128SmarkmSYSTEM_SFILES= ${I386}/i386/locore.s
6321646SdavidnSYSTEM_OBJS=locore.o ${OBJS} ioconf.o param.o vnode_if.o
6421646SdavidnSYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS} libkern.a
6574874SmarkmSYSTEM_LD_HEAD= 	@echo loading $@; rm -f $@
6674874SmarkmSYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o libkern.a
6774874SmarkmSYSTEM_LD_TAIL= @echo rearranging symbols; symorder symbols.sort $@; \
6874874Smarkm	${DBSYM} -fT ${LOAD_ADDRESS} $@; size $@; chmod 755 $@
6974874Smarkm
7074874Smarkm# (XXX) ok, this is weird.  but we've got a working ed, and a broken ex, and
7174874Smarkm# the script is identical for either... -- cgd
7274874Smarkm#
7374874SmarkmGPROF.EX=	/usr/src/lib/csu.i386/gprof.ex
7474874SmarkmPROFILE_C=	${CC} -S -c ${CFLAGS} $< ; \
7574874Smarkm		ed - $*.s < ${GPROF.EX} ; \
7674874Smarkm		${AS} -o $@ $*.s ; \
7774874Smarkm		rm -f $*.s
7874874Smarkm
7974874Smarkm%OBJS
8074874Smarkm
8174874Smarkm%CFILES
8274874Smarkm
8374874Smarkm%LOAD
8474874Smarkm
8574874Smarkm# This is slightly different from before in that if you define PROF
863702Spst# to anything, it will assume profiling.  Don't do "PROF=" to turn
873702Spst# profiling off!
883702Spst.if exists($S/libkern/obj)
8974874SmarkmLIBKERNP=$S/libkern/obj
903702Spst.else
911590SrgrimesLIBKERNP=$S/libkern
9257450Smarkm.endif
9330820Sguido
941590Srgrimes.if defined(PROF)
951590SrgrimesLIBKERN=${LIBKERNP}/libkern_p.a
9630793Sguido.else
971590SrgrimesLIBKERN=${LIBKERNP}/libkern.a
9814440Smarkm.endif
9914440Smarkm
10014440Smarkmlibkern.a: ${LIBKERN}
1011590Srgrimes	@rm -f libkern.a
10221646Sdavidn	ln -s ${LIBKERN} libkern.a
10330793Sguido
10421646Sdavidn${LIBKERN}:
1051590Srgrimes	@(cd $S/libkern; make)
1061590Srgrimes
1071590Srgrimesclean:
10828099Scharnier	rm -f eddep *kernel tags *.o locore.i [a-uw-z]*.s \
1091590Srgrimes		errs linterrs makelinks genassym ,assym.s stamp-assym
1101590Srgrimes
1111590Srgrimes#lint: /tmp param.c
1121590Srgrimes#	@lint -hbxn -I. -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \
1131590Srgrimes#	  ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \
1141590Srgrimes#	    grep -v 'struct/union .* never defined' | \
1151590Srgrimes#	    grep -v 'possible pointer alignment problem'
1161590Srgrimes
1179502Swollmansymbols.sort: ${I386}/i386/symbols.raw
1189502Swollman	grep -v '^#' ${I386}/i386/symbols.raw \
1199502Swollman	    | sed 's/^	//' | sort -u > symbols.sort
1209502Swollman
12174874Smarkmlocore.o: ${I386}/i386/locore.s assym.s
1221590Srgrimes	${NORMAL_S}
12336348Ssteve
12410586Sjoerg# everything potentially depends on the Makefile since everything potentially
1251590Srgrimes# depends on the options.  Some things are more dependent on the Makefile for
12621646Sdavidn# historical reasons.
12730793Sguidomachdep.o: Makefile
12821646Sdavidn
12974874Smarkm# the following is necessary because autoconf.o depends on #if GENERIC
13074874Smarkmautoconf.o: Makefile
13174874Smarkm
13274874Smarkm# depend on network configuration
13374874Smarkmaf.o uipc_proto.o locore.o: Makefile
13474874Smarkm
13574874Smarkm# depends on KDB (cons.o also depends on GENERIC)
13674874Smarkmtrap.o cons.o: Makefile
13774874Smarkm
13874874Smarkm# this rule stops ./assym.s in .depend from causing problems
13929923Smarkm./assym.s: assym.s
14029923Smarkm
14129923Smarkmassym.s: genassym
1421590Srgrimes	./genassym >,assym.s
1431590Srgrimes	if cmp -s assym.s ,assym.s; then \
1449502Swollman		rm -f ,assym.s; \
1459502Swollman	else \
1469502Swollman		rm -f assym.s; \
1471590Srgrimes		mv ,assym.s assym.s; \
14810586Sjoerg	fi
14939538Sroberto
1501590Srgrimes# Some of the defines that genassym outputs may well depend on the 
1511590Srgrimes# value of kernel options.
1521590Srgrimesgenassym:	Makefile
1531590Srgrimes	${CC} ${INCLUDES} -DKERNEL ${IDENT} ${PARAM} \
1541590Srgrimes		 ${I386}/i386/genassym.c -static -o genassym
1551590Srgrimes
1561590Srgrimes# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
1571590Srgrimesdepend: assym.s param.c vnode_if.h
1581590Srgrimes	mkdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
1591590Srgrimes	mkdep -a -p ${INCLUDES} -DKERNEL ${IDENT} ${PARAM} \
1601590Srgrimes		${I386}/i386/genassym.c
1611590Srgrimes	MKDEP_CPP=${CPP} ; export MKDEP_CPP ; \
1621590Srgrimes	mkdep -a -I. -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
1631590Srgrimes
1641590Srgrimeslinks:
1651590Srgrimes	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1661590Srgrimes	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1671590Srgrimes	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
16830793Sguido	  sort -u | comm -23 - dontlink | \
16930793Sguido	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
17030793Sguido	sh makelinks && rm -f dontlink
1711590Srgrimes
1721590Srgrimestags:
17328099Scharnier	@echo "see $S/kern/Makefile for tags"
17428099Scharnier
17539538Srobertoinstall:
17639538Sroberto	chflags noschg /kernel
17710586Sjoerg	mv /kernel /kernel.old
17810586Sjoerg	install -c -m 555 -o root -g wheel -fschg kernel /
17936391Sdanny
18074874Smarkmioconf.o: ioconf.c $S/sys/param.h machine/pte.h $S/sys/buf.h \
18136391Sdanny    ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h
18236391Sdanny	${CC} -c ${CFLAGS} ioconf.c
18328612Sjoerg
18428612Sjoergparam.c: $S/conf/param.c
18528612Sjoerg	-rm -f param.c
18628612Sjoerg	cp $S/conf/param.c .
18710586Sjoerg
18810586Sjoergparam.o: param.c Makefile
18910586Sjoerg	${CC} -c ${CFLAGS} ${PARAM} param.c
19010586Sjoerg
19110586Sjoergvers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
19210586Sjoerg	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
19310586Sjoerg	${CC} ${CFLAGS} -c vers.c
19410586Sjoerg
1951590Srgrimesvnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
1961590Srgrimes	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
19740128Smarkmvnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
19840128Smarkm	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
19940128Smarkm
20040128Smarkm%RULES
20140128Smarkm
2021590Srgrimes# DO NOT DELETE THIS LINE -- make depend uses it
2031590Srgrimes