Makefile revision 1.70
11.70Smrg#	$NetBSD: Makefile,v 1.70 2003/07/25 16:26:51 mrg Exp $
21.1Stv
31.3Stv.include <bsd.own.mk>
41.3Stv
51.60Sthorpej.if ${TOOLCHAIN_MISSING} != "yes"
61.70Smrg.  if ${USE_TOOLS_TOOLCHAIN} != "yes"
71.70SmrgTOOLCHAIN_BITS= binutils .WAIT gcc
81.70Smrg.  else
91.70SmrgTOOLCHAIN_BITS= toolchain
101.70Smrg.  endif
111.70SmrgTOOLCHAIN_BITS+= .WAIT dbsym mdsetimage
121.58Sthorpej# XXX Eventually, we want to be able to build dbsym and mdsetimage
131.58Sthorpej# XXX if EXTERNAL_TOOLCHAIN is set.
141.31Stv.endif
151.31Stv
161.16Stv# Dependencies in SUBDIR below ordered to maximize parallel ability.
171.50Slukem.if !defined(NOSUBDIR)					# {
181.50Slukem
191.29StvSUBDIR=	host-mkdep .WAIT compat .WAIT \
201.57Schris	binstall .WAIT mktemp .WAIT \
211.62Sthorpej		cap_mkdb crunchgen ctags gencat hexdump lint lint2 lorder \
221.32Stv		m4 makewhatis mkdep mtree rpcgen tsort uudecode \
231.32Stv	texinfo .WAIT \
241.16Stv	yacc .WAIT \
251.16Stv	lex .WAIT \
261.32Stv	${TOOLCHAIN_BITS} \
271.64Slukem		asn1_compile cat cksum compile_et config db file installboot \
281.65Stshiozak		lint1 makefs menuc mklocale mkcsmapper mkesdb msgc pax \
291.68Slukem		pwd_mkdb stat sunlabel zic
301.39Stv
311.39Stv.if ${MKMAN} != "no"
321.39StvSUBDIR+=	groff
331.39Stv.endif
341.22Stv
351.22Stv.if ${MKMAINTAINERTOOLS:Uno} != "no"
361.38StvSUBDIR+=	autoconf gettext
371.48Skleink.endif
381.48Skleink
391.48Skleink.if ${MACHINE} == prep
401.48SkleinkSUBDIR+=	prep-mkbootimage
411.22Stv.endif
421.37Sgmcgarry
431.37Sgmcgarry.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb")
441.37SgmcgarrySUBDIR+=	mips-elf2ecoff
451.51Sbjh21.endif
461.51Sbjh21
471.51Sbjh21.if (${MACHINE} == "sparc" || ${MACHINE} == "sparc64")
481.51Sbjh21SUBDIR+=	fgen
491.37Sgmcgarry.endif
501.37Sgmcgarry
511.50Slukem.endif	# ! NOSUBDIR					# }
521.17Stv
531.66Slukemcheck_MKTOOLS: .PHONY .NOTMAIN
541.19Sjmc.if ${MKTOOLS:Uyes} == "no"
551.17Stv	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
561.17Stv	@echo '*** updating your host toolchain.  This should be used only as a'
571.17Stv	@echo '*** temporary workaround for toolchain problems, as it will result'
581.23Swiz	@echo '*** in version skew and build errors over time!'
591.18Sjmc.endif
601.17Stv
611.66Slukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
621.67Slukemrealall realdepend install: check_MKTOOLS
631.66Slukem
641.17Stv.for dir in ${SUBDIR:N.WAIT}
651.17Stvall-${dir} depend-${dir} dependall-${dir} install-${dir}:
661.17Stv	@true
671.17Stv.endfor
681.66Slukem.endif							# }
691.1Stv
701.1Stv.include <bsd.subdir.mk>
711.11Stv.include <bsd.obj.mk>
721.16Stv
731.66Slukem.if exists(PREVIOUSTOOLDIR)
741.66SlukemPREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
751.66Slukem.else
761.66SlukemPREVIOUSTOOLDIR=	
771.66Slukem.endif
781.66Slukem
791.66SlukemCLEANFILES+=	PREVIOUSTOOLDIR
801.66Slukem
811.67Slukemrealall realdepend:
821.66Slukem.if (${PREVIOUSTOOLDIR} != ${TOOLDIR})
831.66Slukem	@echo "*** WARNING: TOOLDIR has moved?"
841.66Slukem	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
851.66Slukem	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
861.66Slukem	@echo "*** Cleaning mis-matched tools"
871.66Slukem	rm -f PREVIOUSTOOLDIR
881.66Slukem	${MAKE} cleandir
891.66Slukem.endif
901.66Slukem	echo ${TOOLDIR} > PREVIOUSTOOLDIR
911.66Slukem
921.40Stv# For each .WAIT point, make sure the immediately preceding target is
931.40Stv# installed before building anything after that point.
941.36Spk#
951.36Spk# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
961.36Spk# to achieve this. These targets look like:
971.36Spk#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
981.36Spk#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
991.36Spk# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
1001.36Spk# places corresponding to the .WAITs in our $SUBDIR variable.
1011.36Spk#
1021.36Spk# Also, since we're now mixing `install' with `all' and `depend' targets
1031.36Spk# an order relationship between those in each individual subdirectory
1041.36Spk# must be established.
1051.36Spk#
1061.40Stv_deps:=
1071.40Stv_prev:=
1081.40Stv
1091.16Stv.for d in ${SUBDIR}
1101.16Stv_this:=		${d}
1111.40Stv
1121.16Stv.if ${_this} == ".WAIT"
1131.36Spk
1141.36Spk# setup dependency to apply to all/depend targets in the next group
1151.40Stv_deps:=		${_deps} ${_prev:S/^/install-/}
1161.40Stv
1171.40Stv# if we're building *only* individual targets (i.e. "dependall-yacc"),
1181.40Stv# make sure prerequisite tools build before installing
1191.40Stv.if !make(all) && !make(dependall)
1201.40Stvinstall-${_prev}: dependall-${_prev}
1211.40Stv.endif
1221.36Spk
1231.16Stv.else
1241.36Spk
1251.36Spk# order depend/all/install targets for ${d} subdir.  Note the additional
1261.36Spk# .WAIT to achieve "closure" of the predecessor/successor relationships.
1271.36Spk.ORDER: depend-${d} all-${d} dependall-${d} .WAIT install-${d}
1281.40Stv
1291.40Stv# make all/depend-${d} dependent on list of install targets
1301.40Stvdepend-${d} all-${d} dependall-${d}: ${_deps}
1311.36Spk
1321.16Stv.endif
1331.40Stv
1341.40Stv# stash current name in case the next entry is .WAIT
1351.40Stv_prev:=		${d}
1361.16Stv.endfor
1371.69Stron
1381.69Stroncleandir:
1391.69Stron	rm -f ${CLEANFILES}
140