Makefile revision 1.67
11.67Slukem#	$NetBSD: Makefile,v 1.67 2003/07/16 13:13:42 lukem Exp $
21.1Stv
31.3Stv.include <bsd.own.mk>
41.3Stv
51.60Sthorpej.if ${TOOLCHAIN_MISSING} != "yes"
61.45SthorpejTOOLCHAIN_BITS= toolchain .WAIT dbsym mdsetimage
71.58Sthorpej# XXX Eventually, we want to be able to build dbsym and mdsetimage
81.58Sthorpej# XXX if EXTERNAL_TOOLCHAIN is set.
91.31Stv.endif
101.31Stv
111.16Stv# Dependencies in SUBDIR below ordered to maximize parallel ability.
121.50Slukem.if !defined(NOSUBDIR)					# {
131.50Slukem
141.29StvSUBDIR=	host-mkdep .WAIT compat .WAIT \
151.57Schris	binstall .WAIT mktemp .WAIT \
161.62Sthorpej		cap_mkdb crunchgen ctags gencat hexdump lint lint2 lorder \
171.32Stv		m4 makewhatis mkdep mtree rpcgen tsort uudecode \
181.32Stv	texinfo .WAIT \
191.16Stv	yacc .WAIT \
201.16Stv	lex .WAIT \
211.32Stv	${TOOLCHAIN_BITS} \
221.64Slukem		asn1_compile cat cksum compile_et config db file installboot \
231.65Stshiozak		lint1 makefs menuc mklocale mkcsmapper mkesdb msgc pax \
241.65Stshiozak		pwd_mkdb sunlabel zic
251.39Stv
261.39Stv.if ${MKMAN} != "no"
271.39StvSUBDIR+=	groff
281.39Stv.endif
291.22Stv
301.22Stv.if ${MKMAINTAINERTOOLS:Uno} != "no"
311.38StvSUBDIR+=	autoconf gettext
321.48Skleink.endif
331.48Skleink
341.48Skleink.if ${MACHINE} == prep
351.48SkleinkSUBDIR+=	prep-mkbootimage
361.22Stv.endif
371.37Sgmcgarry
381.37Sgmcgarry.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb")
391.37SgmcgarrySUBDIR+=	mips-elf2ecoff
401.51Sbjh21.endif
411.51Sbjh21
421.51Sbjh21.if (${MACHINE} == "sparc" || ${MACHINE} == "sparc64")
431.51Sbjh21SUBDIR+=	fgen
441.37Sgmcgarry.endif
451.37Sgmcgarry
461.50Slukem.endif	# ! NOSUBDIR					# }
471.17Stv
481.66Slukemcheck_MKTOOLS: .PHONY .NOTMAIN
491.19Sjmc.if ${MKTOOLS:Uyes} == "no"
501.17Stv	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
511.17Stv	@echo '*** updating your host toolchain.  This should be used only as a'
521.17Stv	@echo '*** temporary workaround for toolchain problems, as it will result'
531.23Swiz	@echo '*** in version skew and build errors over time!'
541.18Sjmc.endif
551.17Stv
561.66Slukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
571.67Slukemrealall realdepend install: check_MKTOOLS
581.66Slukem
591.17Stv.for dir in ${SUBDIR:N.WAIT}
601.17Stvall-${dir} depend-${dir} dependall-${dir} install-${dir}:
611.17Stv	@true
621.17Stv.endfor
631.66Slukem.endif							# }
641.1Stv
651.1Stv.include <bsd.subdir.mk>
661.11Stv.include <bsd.obj.mk>
671.16Stv
681.66Slukem.if exists(PREVIOUSTOOLDIR)
691.66SlukemPREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
701.66Slukem.else
711.66SlukemPREVIOUSTOOLDIR=	
721.66Slukem.endif
731.66Slukem
741.66SlukemCLEANFILES+=	PREVIOUSTOOLDIR
751.66Slukem
761.67Slukemrealall realdepend:
771.66Slukem.if (${PREVIOUSTOOLDIR} != ${TOOLDIR})
781.66Slukem	@echo "*** WARNING: TOOLDIR has moved?"
791.66Slukem	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
801.66Slukem	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
811.66Slukem	@echo "*** Cleaning mis-matched tools"
821.66Slukem	rm -f PREVIOUSTOOLDIR
831.66Slukem	${MAKE} cleandir
841.66Slukem.endif
851.66Slukem	echo ${TOOLDIR} > PREVIOUSTOOLDIR
861.66Slukem
871.40Stv# For each .WAIT point, make sure the immediately preceding target is
881.40Stv# installed before building anything after that point.
891.36Spk#
901.36Spk# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
911.36Spk# to achieve this. These targets look like:
921.36Spk#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
931.36Spk#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
941.36Spk# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
951.36Spk# places corresponding to the .WAITs in our $SUBDIR variable.
961.36Spk#
971.36Spk# Also, since we're now mixing `install' with `all' and `depend' targets
981.36Spk# an order relationship between those in each individual subdirectory
991.36Spk# must be established.
1001.36Spk#
1011.40Stv_deps:=
1021.40Stv_prev:=
1031.40Stv
1041.16Stv.for d in ${SUBDIR}
1051.16Stv_this:=		${d}
1061.40Stv
1071.16Stv.if ${_this} == ".WAIT"
1081.36Spk
1091.36Spk# setup dependency to apply to all/depend targets in the next group
1101.40Stv_deps:=		${_deps} ${_prev:S/^/install-/}
1111.40Stv
1121.40Stv# if we're building *only* individual targets (i.e. "dependall-yacc"),
1131.40Stv# make sure prerequisite tools build before installing
1141.40Stv.if !make(all) && !make(dependall)
1151.40Stvinstall-${_prev}: dependall-${_prev}
1161.40Stv.endif
1171.36Spk
1181.16Stv.else
1191.36Spk
1201.36Spk# order depend/all/install targets for ${d} subdir.  Note the additional
1211.36Spk# .WAIT to achieve "closure" of the predecessor/successor relationships.
1221.36Spk.ORDER: depend-${d} all-${d} dependall-${d} .WAIT install-${d}
1231.40Stv
1241.40Stv# make all/depend-${d} dependent on list of install targets
1251.40Stvdepend-${d} all-${d} dependall-${d}: ${_deps}
1261.36Spk
1271.16Stv.endif
1281.40Stv
1291.40Stv# stash current name in case the next entry is .WAIT
1301.40Stv_prev:=		${d}
1311.16Stv.endfor
132