Makefile.i386 revision 1.90
11.90Stv#	$NetBSD: Makefile.i386,v 1.90 1998/04/12 23:47:43 tv 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.62Smycroft# DEBUG is set to -g if debugging.
221.62Smycroft# PROF is set to -pg if profiling.
231.62Smycroft
241.88SthorpejAR?=	ar
251.88SthorpejAS?=	as
261.65SmycroftCC?=	cc
271.88SthorpejCPP?=	cpp
281.65SmycroftLD?=	ld
291.87SthorpejLORDER?=lorder
301.68SmycroftMKDEP?=	mkdep
311.87SthorpejNM?=	nm
321.88SthorpejRANLIB?=ranlib
331.85SlukemSIZE?=	size
341.74SmycroftSTRIP?=	strip
351.87SthorpejTSORT?=	tsort -q
361.88Sthorpej
371.85SlukemCOPTS?=	-O2
381.1Scgd
391.42Smycroft# source tree is located via $S relative to the compilation directory
401.73Smycroft.ifndef S
411.68SmycroftS!=	cd ../../../..; pwd
421.73Smycroft.endif
431.68SmycroftI386=	$S/arch/i386
441.1Scgd
451.90StvHAVE_GCC28!=	${CC} --version | egrep "^(2\.8|egcs)" ; echo 
461.69SmycroftINCLUDES=	-I. -I$S/arch -I$S -nostdinc
471.71SmycroftCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL \
481.71Smycroft		-Di386
491.90StvCWARNFLAGS?=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes
501.90Stv.if (${HAVE_GCC28} != "")
511.90StvCWARNFLAGS+=	-Wno-main
521.90Stv.endif
531.77SjonathanCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
541.64SmycroftAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
551.86SfvdlLINKFLAGS=	-z -Ttext F0100000 -e start
561.74SmycroftSTRIPFLAGS=	-d
571.74Smycroft
581.33Scgd### find out what to use for libkern
591.33Scgd.include "$S/lib/libkern/Makefile.inc"
601.33Scgd.ifndef PROF
611.33ScgdLIBKERN=	${KERNLIB}
621.33Scgd.else
631.33ScgdLIBKERN=	${KERNLIB_PROF}
641.33Scgd.endif
651.33Scgd
661.56Schristos### find out what to use for libcompat
671.56Schristos.include "$S/compat/common/Makefile.inc"
681.56Schristos.ifndef PROF
691.56SchristosLIBCOMPAT=	${COMPATLIB}
701.56Schristos.else
711.56SchristosLIBCOMPAT=	${COMPATLIB_PROF}
721.56Schristos.endif
731.56Schristos
741.71Smycroft# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
751.71Smycroft# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
761.42Smycroft
771.62SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
781.64SmycroftNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
791.42Smycroft
801.1Scgd%OBJS
811.1Scgd
821.1Scgd%CFILES
831.1Scgd
841.62Smycroft%SFILES
851.62Smycroft
861.42Smycroft# load lines for config "xxx" will be emitted as:
871.42Smycroft# xxx: ${SYSTEM_DEP} swapxxx.o
881.42Smycroft#	${SYSTEM_LD_HEAD}
891.42Smycroft#	${SYSTEM_LD} swapxxx.o
901.42Smycroft#	${SYSTEM_LD_TAIL}
911.62SmycroftSYSTEM_OBJ=	locore.o \
921.66Scgd		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
931.42SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
941.42SmycroftSYSTEM_LD_HEAD=	rm -f $@
951.62SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
961.62Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
971.85SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
981.62Smycroft
991.62SmycroftDEBUG?=
1001.62Smycroft.if ${DEBUG} == "-g"
1011.62SmycroftLINKFLAGS+=	-X
1021.62SmycroftSYSTEM_LD_TAIL+=; \
1031.62Smycroft		echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
1041.74Smycroft		echo ${STRIP} ${STRIPFLAGS} $@; ${STRIP} ${STRIPFLAGS} $@
1051.62Smycroft.else
1061.89SmrgLINKFLAGS+=	-X
1071.62Smycroft.endif
1081.42Smycroft
1091.1Scgd%LOAD
1101.50Smycroft
1111.82Smycroftassym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
1121.82Smycroft	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1131.82Smycroft	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
1141.82Smycroft	mv -f assym.h.tmp assym.h
1151.1Scgd
1161.62Smycroftparam.c: $S/conf/param.c
1171.62Smycroft	rm -f param.c
1181.62Smycroft	cp $S/conf/param.c .
1191.1Scgd
1201.62Smycroftparam.o: param.c Makefile
1211.71Smycroft	${NORMAL_C}
1221.1Scgd
1231.62Smycroftioconf.o: ioconf.c
1241.62Smycroft	${NORMAL_C}
1251.42Smycroft
1261.62Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1271.62Smycroft	sh $S/conf/newvers.sh
1281.62Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1291.1Scgd
1301.1Scgd
1311.84Schristos__CLEANKERNEL: .USE
1321.84Schristos	@echo "${.TARGET}ing the kernel objects"
1331.66Scgd	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1341.82Smycroft	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1351.84Schristos
1361.84Schristos__CLEANDEPEND: .USE
1371.84Schristos	rm -f .depend
1381.84Schristos
1391.84Schristosclean: __CLEANKERNEL
1401.84Schristos
1411.84Schristoscleandir: __CLEANKERNEL __CLEANDEPEND
1421.1Scgd
1431.62Smycroftlint:
1441.79Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1451.80Sperry	    ${I386}/i386/Locore.c ${CFILES} \
1461.62Smycroft	    ioconf.c param.c | \
1471.62Smycroft	    grep -v 'static function .* unused'
1481.1Scgd
1491.62Smycrofttags:
1501.62Smycroft	@echo "see $S/kern/Makefile for tags"
1511.1Scgd
1521.1Scgdlinks:
1531.1Scgd	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1541.1Scgd	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1551.1Scgd	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1561.1Scgd	  sort -u | comm -23 - dontlink | \
1571.62Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1581.1Scgd	sh makelinks && rm -f dontlink
1591.1Scgd
1601.62SmycroftSRCS=	${I386}/i386/locore.s \
1611.66Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1621.78Scgddepend: .depend
1631.75Sjtk.depend: ${SRCS} assym.h param.c
1641.68Smycroft	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
1651.68Smycroft	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1661.68Smycroft	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
1671.83Sleo	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1681.83Sleo	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
1691.83Sleo	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1701.83Sleo	@rm -f assym.dep
1711.62Smycroft
1721.62Smycroft
1731.62Smycroft# depend on root or device configuration
1741.62Smycroftautoconf.o conf.o: Makefile
1751.62Smycroft 
1761.62Smycroft# depend on network or filesystem configuration 
1771.62Smycroftuipc_proto.o vfs_conf.o: Makefile 
1781.1Scgd
1791.62Smycroft# depend on maxusers
1801.82Smycroftmachdep.o: Makefile
1811.1Scgd
1821.62Smycroft# depend on CPU configuration 
1831.62Smycroftlocore.o machdep.o: Makefile
1841.1Scgd
1851.2Scgd
1861.62Smycroftlocore.o: ${I386}/i386/locore.s assym.h
1871.62Smycroft	${NORMAL_S}
1881.1Scgd
1891.1Scgd%RULES
190