Makefile.i386 revision 1.105
11.105Sthorpej#	$NetBSD: Makefile.i386,v 1.105 2000/05/09 00:32:23 thorpej Exp $
21.62Smycroft
31.8Scgd# Makefile for NetBSD
41.1Scgd#
51.1Scgd# This makefile is constructed from a machine description:
61.1Scgd#	config machineid
71.1Scgd# Most changes should be made in the machine description
81.36Sderaadt#	/sys/arch/i386/conf/``machineid''
91.1Scgd# after which you should do
101.62Smycroft#	config machineid
111.62Smycroft# Machine generic makefile changes should be made in
121.36Sderaadt#	/sys/arch/i386/conf/Makefile.i386
131.42Smycroft# after which config should be rerun for all machines of that type.
141.1Scgd#
151.42Smycroft# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
161.1Scgd#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
171.1Scgd#
181.1Scgd# -DTRACE	compile in kernel tracing hooks
191.1Scgd# -DQUOTA	compile in file system quotas
201.42Smycroft
211.97Schristos.include <bsd.own.mk>
221.97Schristos
231.62Smycroft# DEBUG is set to -g if debugging.
241.62Smycroft# PROF is set to -pg if profiling.
251.62Smycroft
261.88SthorpejAR?=	ar
271.88SthorpejAS?=	as
281.65SmycroftCC?=	cc
291.88SthorpejCPP?=	cpp
301.65SmycroftLD?=	ld
311.87SthorpejLORDER?=lorder
321.68SmycroftMKDEP?=	mkdep
331.87SthorpejNM?=	nm
341.88SthorpejRANLIB?=ranlib
351.85SlukemSIZE?=	size
361.103StsutsuiSTRIP?=	strip
371.87SthorpejTSORT?=	tsort -q
381.88Sthorpej
391.85SlukemCOPTS?=	-O2
401.1Scgd
411.42Smycroft# source tree is located via $S relative to the compilation directory
421.73Smycroft.ifndef S
431.68SmycroftS!=	cd ../../../..; pwd
441.73Smycroft.endif
451.68SmycroftI386=	$S/arch/i386
461.1Scgd
471.105SthorpejHAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
481.69SmycroftINCLUDES=	-I. -I$S/arch -I$S -nostdinc
491.96SthorpejCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -Di386
501.95SaugustssCWARNFLAGS?=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes \
511.95Saugustss		-Wpointer-arith
521.105Sthorpej# XXX Delete -Wuninitialized for now, since the compiler doesn't
531.105Sthorpej# XXX always get it right.  --thorpej
541.105SthorpejCWARNFLAGS+=	-Wno-uninitialized
551.105Sthorpej.if (${HAVE_EGCS} != "")
561.90StvCWARNFLAGS+=	-Wno-main
571.90Stv.endif
581.77SjonathanCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
591.64SmycroftAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
601.104SthorpejLINKFLAGS=	-Ttext c0100000 -e start
611.97Schristos.if (${OBJECT_FMT} == "ELF")
621.97Schristos#LINKFLAGS+=	-N
631.97Schristos.else
641.97SchristosLINKFLAGS+=	-z
651.97Schristos.endif
661.100StsutsuiSTRIPFLAGS=	-g
671.98Smrg
681.98Smrg%INCLUDES
691.74Smycroft
701.33Scgd### find out what to use for libkern
711.94SdrochnerKERN_AS=	obj
721.33Scgd.include "$S/lib/libkern/Makefile.inc"
731.33Scgd.ifndef PROF
741.33ScgdLIBKERN=	${KERNLIB}
751.33Scgd.else
761.33ScgdLIBKERN=	${KERNLIB_PROF}
771.33Scgd.endif
781.33Scgd
791.56Schristos### find out what to use for libcompat
801.56Schristos.include "$S/compat/common/Makefile.inc"
811.56Schristos.ifndef PROF
821.56SchristosLIBCOMPAT=	${COMPATLIB}
831.56Schristos.else
841.56SchristosLIBCOMPAT=	${COMPATLIB_PROF}
851.56Schristos.endif
861.56Schristos
871.71Smycroft# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
881.71Smycroft# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
891.42Smycroft
901.62SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
911.91SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
921.64SmycroftNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
931.42Smycroft
941.1Scgd%OBJS
951.1Scgd
961.1Scgd%CFILES
971.1Scgd
981.62Smycroft%SFILES
991.62Smycroft
1001.42Smycroft# load lines for config "xxx" will be emitted as:
1011.42Smycroft# xxx: ${SYSTEM_DEP} swapxxx.o
1021.42Smycroft#	${SYSTEM_LD_HEAD}
1031.42Smycroft#	${SYSTEM_LD} swapxxx.o
1041.42Smycroft#	${SYSTEM_LD_TAIL}
1051.62SmycroftSYSTEM_OBJ=	locore.o \
1061.94Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1071.42SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1081.42SmycroftSYSTEM_LD_HEAD=	rm -f $@
1091.62SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1101.62Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1111.85SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1121.62Smycroft
1131.62SmycroftDEBUG?=
1141.62Smycroft.if ${DEBUG} == "-g"
1151.62SmycroftLINKFLAGS+=	-X
1161.62SmycroftSYSTEM_LD_TAIL+=; \
1171.99Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1181.103Stsutsui		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1191.103Stsutsui		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1201.62Smycroft.else
1211.89SmrgLINKFLAGS+=	-X
1221.62Smycroft.endif
1231.42Smycroft
1241.1Scgd%LOAD
1251.50Smycroft
1261.82Smycroftassym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
1271.82Smycroft	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1281.82Smycroft	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
1291.82Smycroft	mv -f assym.h.tmp assym.h
1301.1Scgd
1311.62Smycroftparam.c: $S/conf/param.c
1321.62Smycroft	rm -f param.c
1331.62Smycroft	cp $S/conf/param.c .
1341.1Scgd
1351.62Smycroftparam.o: param.c Makefile
1361.71Smycroft	${NORMAL_C}
1371.1Scgd
1381.62Smycroftioconf.o: ioconf.c
1391.62Smycroft	${NORMAL_C}
1401.42Smycroft
1411.62Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1421.62Smycroft	sh $S/conf/newvers.sh
1431.62Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1441.1Scgd
1451.1Scgd
1461.84Schristos__CLEANKERNEL: .USE
1471.84Schristos	@echo "${.TARGET}ing the kernel objects"
1481.66Scgd	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1491.82Smycroft	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1501.84Schristos
1511.84Schristos__CLEANDEPEND: .USE
1521.84Schristos	rm -f .depend
1531.84Schristos
1541.84Schristosclean: __CLEANKERNEL
1551.84Schristos
1561.93Slukemcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1571.1Scgd
1581.62Smycroftlint:
1591.79Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1601.80Sperry	    ${I386}/i386/Locore.c ${CFILES} \
1611.62Smycroft	    ioconf.c param.c | \
1621.62Smycroft	    grep -v 'static function .* unused'
1631.1Scgd
1641.62Smycrofttags:
1651.62Smycroft	@echo "see $S/kern/Makefile for tags"
1661.1Scgd
1671.1Scgdlinks:
1681.1Scgd	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1691.1Scgd	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1701.1Scgd	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1711.1Scgd	  sort -u | comm -23 - dontlink | \
1721.62Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1731.1Scgd	sh makelinks && rm -f dontlink
1741.1Scgd
1751.62SmycroftSRCS=	${I386}/i386/locore.s \
1761.66Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1771.78Scgddepend: .depend
1781.75Sjtk.depend: ${SRCS} assym.h param.c
1791.68Smycroft	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
1801.68Smycroft	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1811.68Smycroft	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
1821.83Sleo	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1831.83Sleo	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
1841.83Sleo	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1851.83Sleo	@rm -f assym.dep
1861.102Stron
1871.102Strondependall: depend all
1881.62Smycroft
1891.62Smycroft
1901.62Smycroft# depend on root or device configuration
1911.62Smycroftautoconf.o conf.o: Makefile
1921.92Senami
1931.92Senami# depend on network or filesystem configuration
1941.92Senamiuipc_proto.o vfs_conf.o: Makefile
1951.1Scgd
1961.62Smycroft# depend on maxusers
1971.82Smycroftmachdep.o: Makefile
1981.1Scgd
1991.92Senami# depend on CPU configuration
2001.62Smycroftlocore.o machdep.o: Makefile
2011.1Scgd
2021.2Scgd
2031.62Smycroftlocore.o: ${I386}/i386/locore.s assym.h
2041.62Smycroft	${NORMAL_S}
2051.1Scgd
2061.1Scgd%RULES
207