Makefile revision 1.89
11.89Sthorpej#	$NetBSD: Makefile,v 1.89 2005/05/30 15:51:36 thorpej Exp $
21.1Stv
31.3Stv.include <bsd.own.mk>
41.3Stv
51.81Slukem.if ${TOOLCHAIN_MISSING} == "no"
61.77SmrgTOOLCHAIN_BITS= binutils .WAIT
71.70Smrg.  if ${USE_TOOLS_TOOLCHAIN} != "yes"
81.77SmrgTOOLCHAIN_BITS+= gcc
91.74Scl.    if ${MKCROSSGDB:Uno} != "no"
101.74SclTOOLCHAIN_BITS+= gdb
111.74Scl.    endif
121.70Smrg.  else
131.77SmrgTOOLCHAIN_BITS+= toolchain
141.70Smrg.  endif
151.70SmrgTOOLCHAIN_BITS+= .WAIT dbsym mdsetimage
161.58Sthorpej# XXX Eventually, we want to be able to build dbsym and mdsetimage
171.58Sthorpej# XXX if EXTERNAL_TOOLCHAIN is set.
181.31Stv.endif
191.31Stv
201.16Stv# Dependencies in SUBDIR below ordered to maximize parallel ability.
211.50Slukem.if !defined(NOSUBDIR)					# {
221.50Slukem
231.29StvSUBDIR=	host-mkdep .WAIT compat .WAIT \
241.57Schris	binstall .WAIT mktemp .WAIT \
251.89Sthorpej		cap_mkdb crunchgen ctags genassym gencat hexdump lint lint2 \
261.89Sthorpej		lorder m4 makewhatis mkdep mtree rpcgen tsort uudecode \
271.32Stv	texinfo .WAIT \
281.16Stv	yacc .WAIT \
291.16Stv	lex .WAIT \
301.32Stv	${TOOLCHAIN_BITS} \
311.64Slukem		asn1_compile cat cksum compile_et config db file installboot \
321.75Slukem		lint1 makefs menuc mkcsmapper mkesdb mklocale mknod msgc pax \
331.68Slukem		pwd_mkdb stat sunlabel zic
341.39Stv
351.39Stv.if ${MKMAN} != "no"
361.39StvSUBDIR+=	groff
371.39Stv.endif
381.22Stv
391.22Stv.if ${MKMAINTAINERTOOLS:Uno} != "no"
401.38StvSUBDIR+=	autoconf gettext
411.72Smatt.endif
421.72Smatt
431.86Sjmc.if ${MACHINE} == "hp700"
441.83SskrllSUBDIR+=	hp700-mkboot
451.83Sskrll.endif
461.83Sskrll
471.86Sjmc.if ${MACHINE} == "ibmnws"
481.72SmattSUBDIR+=	ibmnws-ncdcs
491.79Smatt.endif
501.79Smatt
511.86Sjmc.if ${MACHINE} == "macppc"
521.79SmattSUBDIR+=	macppc-fixcoff
531.48Skleink.endif
541.48Skleink
551.86Sjmc.if ${MACHINE} == "prep"
561.48SkleinkSUBDIR+=	prep-mkbootimage
571.22Stv.endif
581.37Sgmcgarry
591.37Sgmcgarry.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb")
601.37SgmcgarrySUBDIR+=	mips-elf2ecoff
611.76Ssekiya.endif
621.76Ssekiya
631.76Ssekiya.if (${MACHINE} == "sgimips")
641.76SsekiyaSUBDIR+=	sgivol
651.51Sbjh21.endif
661.51Sbjh21
671.82Sabs.if ${MACHINE} == "acorn32"
681.82SabsSUBDIR+=	sparkcrc
691.82Sabs.endif
701.82Sabs
711.51Sbjh21.if (${MACHINE} == "sparc" || ${MACHINE} == "sparc64")
721.51Sbjh21SUBDIR+=	fgen
731.37Sgmcgarry.endif
741.37Sgmcgarry
751.84Sjmc.if ${MACHINE} == "bebox"
761.84SjmcSUBDIR+=	bebox-elf2pef
771.84SjmcSUBDIR+=	bebox-mkbootimage
781.84Sjmc.endif
791.84Sjmc
801.85Sjmc.if ${MACHINE} == "amiga"
811.85SjmcSUBDIR+=	amiga-elf2bb
821.85SjmcSUBDIR+=	amiga-txlt
831.85Sjmc.endif
841.85Sjmc
851.86Sjmc.if ${MACHINE} == "hp300"
861.86SjmcSUBDIR+=	hp300-mkboot
871.86Sjmc.endif
881.86Sjmc
891.50Slukem.endif	# ! NOSUBDIR					# }
901.17Stv
911.66Slukemcheck_MKTOOLS: .PHONY .NOTMAIN
921.19Sjmc.if ${MKTOOLS:Uyes} == "no"
931.17Stv	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
941.17Stv	@echo '*** updating your host toolchain.  This should be used only as a'
951.17Stv	@echo '*** temporary workaround for toolchain problems, as it will result'
961.23Swiz	@echo '*** in version skew and build errors over time!'
971.18Sjmc.endif
981.17Stv
991.66Slukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
1001.67Slukemrealall realdepend install: check_MKTOOLS
1011.66Slukem
1021.17Stv.for dir in ${SUBDIR:N.WAIT}
1031.17Stvall-${dir} depend-${dir} dependall-${dir} install-${dir}:
1041.17Stv	@true
1051.17Stv.endfor
1061.66Slukem.endif							# }
1071.1Stv
1081.1Stv.include <bsd.subdir.mk>
1091.11Stv.include <bsd.obj.mk>
1101.16Stv
1111.66Slukem.if exists(PREVIOUSTOOLDIR)
1121.66SlukemPREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
1131.66Slukem.else
1141.66SlukemPREVIOUSTOOLDIR=	
1151.66Slukem.endif
1161.66Slukem
1171.66SlukemCLEANFILES+=	PREVIOUSTOOLDIR
1181.66Slukem
1191.67Slukemrealall realdepend:
1201.87Smycroft.if "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
1211.66Slukem	@echo "*** WARNING: TOOLDIR has moved?"
1221.66Slukem	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
1231.66Slukem	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
1241.66Slukem	@echo "*** Cleaning mis-matched tools"
1251.66Slukem	rm -f PREVIOUSTOOLDIR
1261.78Slukem	(cd ${.CURDIR} && ${MAKE} cleandir)
1271.66Slukem.endif
1281.66Slukem	echo ${TOOLDIR} > PREVIOUSTOOLDIR
1291.66Slukem
1301.40Stv# For each .WAIT point, make sure the immediately preceding target is
1311.40Stv# installed before building anything after that point.
1321.36Spk#
1331.36Spk# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
1341.36Spk# to achieve this. These targets look like:
1351.36Spk#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
1361.36Spk#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
1371.36Spk# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
1381.36Spk# places corresponding to the .WAITs in our $SUBDIR variable.
1391.36Spk#
1401.36Spk# Also, since we're now mixing `install' with `all' and `depend' targets
1411.36Spk# an order relationship between those in each individual subdirectory
1421.36Spk# must be established.
1431.36Spk#
1441.40Stv_deps:=
1451.40Stv_prev:=
1461.40Stv
1471.16Stv.for d in ${SUBDIR}
1481.16Stv_this:=		${d}
1491.40Stv
1501.16Stv.if ${_this} == ".WAIT"
1511.36Spk
1521.36Spk# setup dependency to apply to all/depend targets in the next group
1531.40Stv_deps:=		${_deps} ${_prev:S/^/install-/}
1541.40Stv
1551.40Stv# if we're building *only* individual targets (i.e. "dependall-yacc"),
1561.40Stv# make sure prerequisite tools build before installing
1571.40Stv.if !make(all) && !make(dependall)
1581.40Stvinstall-${_prev}: dependall-${_prev}
1591.40Stv.endif
1601.36Spk
1611.16Stv.else
1621.36Spk
1631.36Spk# order depend/all/install targets for ${d} subdir.  Note the additional
1641.36Spk# .WAIT to achieve "closure" of the predecessor/successor relationships.
1651.36Spk.ORDER: depend-${d} all-${d} dependall-${d} .WAIT install-${d}
1661.40Stv
1671.40Stv# make all/depend-${d} dependent on list of install targets
1681.40Stvdepend-${d} all-${d} dependall-${d}: ${_deps}
1691.36Spk
1701.16Stv.endif
1711.40Stv
1721.40Stv# stash current name in case the next entry is .WAIT
1731.40Stv_prev:=		${d}
1741.16Stv.endfor
1751.69Stron
1761.69Stroncleandir:
1771.69Stron	rm -f ${CLEANFILES}
178