Makefile revision 1.83
11.83Sskrll#	$NetBSD: Makefile,v 1.83 2004/07/28 09:17:31 skrll 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.62Sthorpej		cap_mkdb crunchgen ctags gencat hexdump lint lint2 lorder \
261.32Stv		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.83Sskrll.if ${MACHINE} == hp700
441.83SskrllSUBDIR+=	hp700-mkboot
451.83Sskrll.endif
461.83Sskrll
471.72Smatt.if ${MACHINE} == ibmnws
481.72SmattSUBDIR+=	ibmnws-ncdcs
491.79Smatt.endif
501.79Smatt
511.80Smatt.if ${MACHINE} == macppc
521.79SmattSUBDIR+=	macppc-fixcoff
531.48Skleink.endif
541.48Skleink
551.48Skleink.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.50Slukem.endif	# ! NOSUBDIR					# }
761.17Stv
771.66Slukemcheck_MKTOOLS: .PHONY .NOTMAIN
781.19Sjmc.if ${MKTOOLS:Uyes} == "no"
791.17Stv	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
801.17Stv	@echo '*** updating your host toolchain.  This should be used only as a'
811.17Stv	@echo '*** temporary workaround for toolchain problems, as it will result'
821.23Swiz	@echo '*** in version skew and build errors over time!'
831.18Sjmc.endif
841.17Stv
851.66Slukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
861.67Slukemrealall realdepend install: check_MKTOOLS
871.66Slukem
881.17Stv.for dir in ${SUBDIR:N.WAIT}
891.17Stvall-${dir} depend-${dir} dependall-${dir} install-${dir}:
901.17Stv	@true
911.17Stv.endfor
921.66Slukem.endif							# }
931.1Stv
941.1Stv.include <bsd.subdir.mk>
951.11Stv.include <bsd.obj.mk>
961.16Stv
971.66Slukem.if exists(PREVIOUSTOOLDIR)
981.66SlukemPREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
991.66Slukem.else
1001.66SlukemPREVIOUSTOOLDIR=	
1011.66Slukem.endif
1021.66Slukem
1031.66SlukemCLEANFILES+=	PREVIOUSTOOLDIR
1041.66Slukem
1051.67Slukemrealall realdepend:
1061.66Slukem.if (${PREVIOUSTOOLDIR} != ${TOOLDIR})
1071.66Slukem	@echo "*** WARNING: TOOLDIR has moved?"
1081.66Slukem	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
1091.66Slukem	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
1101.66Slukem	@echo "*** Cleaning mis-matched tools"
1111.66Slukem	rm -f PREVIOUSTOOLDIR
1121.78Slukem	(cd ${.CURDIR} && ${MAKE} cleandir)
1131.66Slukem.endif
1141.66Slukem	echo ${TOOLDIR} > PREVIOUSTOOLDIR
1151.66Slukem
1161.40Stv# For each .WAIT point, make sure the immediately preceding target is
1171.40Stv# installed before building anything after that point.
1181.36Spk#
1191.36Spk# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
1201.36Spk# to achieve this. These targets look like:
1211.36Spk#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
1221.36Spk#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
1231.36Spk# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
1241.36Spk# places corresponding to the .WAITs in our $SUBDIR variable.
1251.36Spk#
1261.36Spk# Also, since we're now mixing `install' with `all' and `depend' targets
1271.36Spk# an order relationship between those in each individual subdirectory
1281.36Spk# must be established.
1291.36Spk#
1301.40Stv_deps:=
1311.40Stv_prev:=
1321.40Stv
1331.16Stv.for d in ${SUBDIR}
1341.16Stv_this:=		${d}
1351.40Stv
1361.16Stv.if ${_this} == ".WAIT"
1371.36Spk
1381.36Spk# setup dependency to apply to all/depend targets in the next group
1391.40Stv_deps:=		${_deps} ${_prev:S/^/install-/}
1401.40Stv
1411.40Stv# if we're building *only* individual targets (i.e. "dependall-yacc"),
1421.40Stv# make sure prerequisite tools build before installing
1431.40Stv.if !make(all) && !make(dependall)
1441.40Stvinstall-${_prev}: dependall-${_prev}
1451.40Stv.endif
1461.36Spk
1471.16Stv.else
1481.36Spk
1491.36Spk# order depend/all/install targets for ${d} subdir.  Note the additional
1501.36Spk# .WAIT to achieve "closure" of the predecessor/successor relationships.
1511.36Spk.ORDER: depend-${d} all-${d} dependall-${d} .WAIT install-${d}
1521.40Stv
1531.40Stv# make all/depend-${d} dependent on list of install targets
1541.40Stvdepend-${d} all-${d} dependall-${d}: ${_deps}
1551.36Spk
1561.16Stv.endif
1571.40Stv
1581.40Stv# stash current name in case the next entry is .WAIT
1591.40Stv_prev:=		${d}
1601.16Stv.endfor
1611.69Stron
1621.69Stroncleandir:
1631.69Stron	rm -f ${CLEANFILES}
164