Makefile.i386 revision 1.110
11.396.2.1Spgoyette#	$NetBSD: Makefile.i386,v 1.110 2001/01/09 12:03:15 fvdl Exp $
21.1Sperry
31.1Sperry# Makefile for NetBSD
41.1Sperry#
51.267Stls# This makefile is constructed from a machine description:
61.360Stls#	config machineid
71.332Sjruoho# Most changes should be made in the machine description
81.382Sriastrad#	/sys/arch/i386/conf/``machineid''
91.382Sriastrad# after which you should do
101.379Swiz#	config machineid
111.294Srmind# Machine generic makefile changes should be made in
121.234Syamt#	/sys/arch/i386/conf/Makefile.i386
131.184Srpaulo# after which config should be rerun for all machines of that type.
141.235Syamt
151.232Syamt.include <bsd.own.mk>
161.351Sjruoho
171.326Sjruoho# DEBUG is set to -g if debugging.
181.234Syamt# PROF is set to -pg if profiling.
191.387Spgoyette
201.147SdslAR?=	ar
211.195SgdamoreAS?=	as
221.345SahokaCC?=	cc
231.382SriastradCPP?=	cpp
241.382SriastradLD?=	ld
251.199SchapLORDER?=lorder
261.171SdyoungMKDEP?=	mkdep
271.171SdyoungNM?=	nm
281.207SgdtRANLIB?=ranlib
291.221SdyoungSIZE?=	size
301.391SknakaharSTRIP?=	strip
311.391SknakaharTSORT?=	tsort -q
321.393Smrg
331.126SjdolecekCOPTS?=	-O2
341.396.2.1Spgoyette
351.257Syamt# source tree is located via $S relative to the compilation directory
361.222Syamt.ifndef S
371.225SadS!=	cd ../../../..; pwd
381.223Selad.endif
391.373SsorenI386=	$S/arch/i386
401.247Sdsieger
411.374SrmindHAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
421.385SknakaharINCLUDES=	-I. -I$S/arch -I$S -nostdinc
431.391SknakaharCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -Di386
441.385SknakaharCWARNFLAGS?=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes \
451.385Sknakahar		-Wpointer-arith
461.395Sriastrad# XXX Delete -Wuninitialized for now, since the compiler doesn't
471.373Ssoren# XXX always get it right.  --thorpej
481.373SsorenCWARNFLAGS+=	-Wno-uninitialized
491.356Syamt.if (${HAVE_EGCS} != "")
501.320SdsiegerCWARNFLAGS+=	-Wno-main
511.362Sjym.endif
521.362SjymCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
531.362SjymAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
541.357SyamtLINKFLAGS=	-Ttext c0100000 -e start
551.265Splunky.if (${OBJECT_FMT} == "ELF")
561.313Sjruoho#LINKFLAGS+=	-N
571.371Schristos.else
581.355SyamtLINKFLAGS+=	-z
591.269Sjmcneill.endif
601.269Sjmcneill
611.353Snjoly.if defined(KERN_LDSCRIPT)
621.365SmrgLINKFLAGS+=	-T ${I386}/conf/${KERN_LDSCRIPT}
631.381Sriastrad.endif
641.307Sdyoung
651.308SrmindSTRIPFLAGS=	-g
661.118Sthorpej
671.289Sapb%INCLUDES
681.290Sapb
691.289Sapb### find out what to use for libkern
701.360StlsKERN_AS=	obj
711.360Stls.include "$S/lib/libkern/Makefile.inc"
721.360Stls.ifndef PROF
731.360StlsLIBKERN=	${KERNLIB}
741.360Stls.else
751.360StlsLIBKERN=	${KERNLIB_PROF}
761.360Stls.endif
771.360Stls
781.360Stls### find out what to use for libcompat
791.361Stls.include "$S/compat/common/Makefile.inc"
801.361Stls.ifndef PROF
811.361StlsLIBCOMPAT=	${COMPATLIB}
821.382Sriastrad.else
831.297SdyoungLIBCOMPAT=	${COMPATLIB_PROF}
841.297Sdyoung.endif
851.297Sdyoung
861.297Sdyoung# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
871.297Sdyoung# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
881.297Sdyoung
891.118SthorpejNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
901.118SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
911.118SthorpejNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
921.118Sthorpej
931.118Sthorpej%OBJS
941.118Sthorpej
951.118Sthorpej%CFILES
961.118Sthorpej
971.118Sthorpej%SFILES
981.94Sgmcgarry
991.310Sjruoho# load lines for config "xxx" will be emitted as:
1001.207Sgdt# xxx: ${SYSTEM_DEP} swapxxx.o
1011.346Sjruoho#	${SYSTEM_LD_HEAD}
1021.350Sjym#	${SYSTEM_LD} swapxxx.o
1031.350Sjym#	${SYSTEM_LD_TAIL}
1041.207SgdtSYSTEM_OBJ=	locore.o \
1051.267Stls		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1061.267StlsSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1071.267StlsSYSTEM_LD_HEAD=	rm -f $@
1081.267StlsSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1091.267Stls		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1101.18SisSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1111.217Scube
1121.217ScubeDEBUG?=
1131.277Suebayasi.if ${DEBUG} == "-g"
1141.217ScubeLINKFLAGS+=	-X
1151.84SgmcgarrySYSTEM_LD_TAIL+=; \
1161.127Sgmcgarry		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1171.217Scube		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1181.84Sgmcgarry		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1191.217Scube.else
1201.84SgmcgarryLINKFLAGS+=	-X
1211.363Splunky.endif
1221.84Sgmcgarry
1231.84Sgmcgarry%LOAD
1241.84Sgmcgarry
1251.334Stsutsuiassym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
1261.84Sgmcgarry	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1271.217Scube	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
1281.217Scube	mv -f assym.h.tmp assym.h
1291.194Skleink
1301.332Sjruohoparam.c: $S/conf/param.c
1311.332Sjruoho	rm -f param.c
1321.332Sjruoho	cp $S/conf/param.c .
1331.332Sjruoho
1341.332Sjruohoparam.o: param.c Makefile
1351.332Sjruoho	${NORMAL_C}
1361.143Syamt
1371.143Syamtioconf.o: ioconf.c
1381.143Syamt	${NORMAL_C}
1391.143Syamt
1401.143Syamtnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1411.143Syamt	sh $S/conf/newvers.sh
1421.143Syamt	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1431.143Syamt
1441.143Syamt
1451.143Syamt__CLEANKERNEL: .USE
1461.382Sriastrad	@echo "${.TARGET}ing the kernel objects"
1471.382Sriastrad	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1481.382Sriastrad	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1491.382Sriastrad
1501.382Sriastrad__CLEANDEPEND: .USE
1511.382Sriastrad	rm -f .depend
1521.382Sriastrad
1531.26Scgdclean: __CLEANKERNEL
1541.26Scgd
1551.26Scgdcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1561.26Scgd
1571.26Scgdlint:
1581.328Sdyoung	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1591.328Sdyoung	    ${I386}/i386/Locore.c ${CFILES} \
1601.328Sdyoung	    ioconf.c param.c | \
1611.98Skleink	    grep -v 'static function .* unused'
1621.26Scgd
1631.26Scgdtags:
1641.26Scgd	@echo "see $S/kern/Makefile for tags"
1651.26Scgd
1661.26Scgdlinks:
1671.26Scgd	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1681.26Scgd	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1691.26Scgd	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1701.26Scgd	  sort -u | comm -23 - dontlink | \
1711.26Scgd	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1721.26Scgd	sh makelinks && rm -f dontlink
1731.26Scgd
1741.26ScgdSRCS=	${I386}/i386/locore.s \
1751.26Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1761.26Scgddepend: .depend
1771.111Skleink.depend: ${SRCS} assym.h param.c
1781.26Scgd	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
1791.26Scgd	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1801.26Scgd	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
1811.26Scgd	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1821.26Scgd	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
1831.26Scgd	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1841.26Scgd	@rm -f assym.dep
1851.26Scgd
1861.26Scgddependall: depend all
1871.26Scgd
1881.27Schristos
1891.27Schristos# depend on root or device configuration
1901.27Schristosautoconf.o conf.o: Makefile
1911.27Schristos
1921.27Schristos# depend on network or filesystem configuration
1931.27Schristosuipc_proto.o vfs_conf.o: Makefile
1941.233Smrg
1951.233Smrg# depend on maxusers
1961.278Stsutsuimachdep.o: Makefile
1971.278Stsutsui
1981.278Stsutsui# depend on CPU configuration
1991.278Stsutsuilocore.o machdep.o: Makefile
2001.278Stsutsui
2011.278Stsutsui
2021.278Stsutsuilocore.o: ${I386}/i386/locore.s assym.h
2031.278Stsutsui	${NORMAL_S}
2041.278Stsutsui
2051.294Srmind# The install target can be redefined by putting a
2061.294Srmind# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2071.294SrmindMACHINE_NAME!=  uname -n
2081.276Sjdcinstall: install-kernel-${MACHINE_NAME}
2091.276Sjdc.if !target(install-kernel-${MACHINE_NAME}})
2101.276Sjdcinstall-kernel-${MACHINE_NAME}:
2111.276Sjdc	rm -f /onetbsd
2121.276Sjdc	ln /netbsd /onetbsd
2131.279Sad	cp netbsd /nnetbsd
2141.279Sad	mv /nnetbsd /netbsd
2151.84Sgmcgarry.endif
2161.84Sgmcgarry
2171.84Sgmcgarry%RULES
2181.84Sgmcgarry