Makefile revision 1.78
11.78Slukem#	$NetBSD: Makefile,v 1.78 2003/12/10 05:19:41 lukem Exp $
21.1Stv
31.3Stv.include <bsd.own.mk>
41.3Stv
51.60Sthorpej.if ${TOOLCHAIN_MISSING} != "yes"
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.72Smatt.if ${MACHINE} == ibmnws
441.72SmattSUBDIR+=	ibmnws-ncdcs
451.48Skleink.endif
461.48Skleink
471.48Skleink.if ${MACHINE} == prep
481.48SkleinkSUBDIR+=	prep-mkbootimage
491.22Stv.endif
501.37Sgmcgarry
511.37Sgmcgarry.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb")
521.37SgmcgarrySUBDIR+=	mips-elf2ecoff
531.76Ssekiya.endif
541.76Ssekiya
551.76Ssekiya.if (${MACHINE} == "sgimips")
561.76SsekiyaSUBDIR+=	sgivol
571.51Sbjh21.endif
581.51Sbjh21
591.51Sbjh21.if (${MACHINE} == "sparc" || ${MACHINE} == "sparc64")
601.51Sbjh21SUBDIR+=	fgen
611.37Sgmcgarry.endif
621.37Sgmcgarry
631.50Slukem.endif	# ! NOSUBDIR					# }
641.17Stv
651.66Slukemcheck_MKTOOLS: .PHONY .NOTMAIN
661.19Sjmc.if ${MKTOOLS:Uyes} == "no"
671.17Stv	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
681.17Stv	@echo '*** updating your host toolchain.  This should be used only as a'
691.17Stv	@echo '*** temporary workaround for toolchain problems, as it will result'
701.23Swiz	@echo '*** in version skew and build errors over time!'
711.18Sjmc.endif
721.17Stv
731.66Slukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
741.67Slukemrealall realdepend install: check_MKTOOLS
751.66Slukem
761.17Stv.for dir in ${SUBDIR:N.WAIT}
771.17Stvall-${dir} depend-${dir} dependall-${dir} install-${dir}:
781.17Stv	@true
791.17Stv.endfor
801.66Slukem.endif							# }
811.1Stv
821.1Stv.include <bsd.subdir.mk>
831.11Stv.include <bsd.obj.mk>
841.16Stv
851.66Slukem.if exists(PREVIOUSTOOLDIR)
861.66SlukemPREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
871.66Slukem.else
881.66SlukemPREVIOUSTOOLDIR=	
891.66Slukem.endif
901.66Slukem
911.66SlukemCLEANFILES+=	PREVIOUSTOOLDIR
921.66Slukem
931.67Slukemrealall realdepend:
941.66Slukem.if (${PREVIOUSTOOLDIR} != ${TOOLDIR})
951.66Slukem	@echo "*** WARNING: TOOLDIR has moved?"
961.66Slukem	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
971.66Slukem	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
981.66Slukem	@echo "*** Cleaning mis-matched tools"
991.66Slukem	rm -f PREVIOUSTOOLDIR
1001.78Slukem	(cd ${.CURDIR} && ${MAKE} cleandir)
1011.66Slukem.endif
1021.66Slukem	echo ${TOOLDIR} > PREVIOUSTOOLDIR
1031.66Slukem
1041.40Stv# For each .WAIT point, make sure the immediately preceding target is
1051.40Stv# installed before building anything after that point.
1061.36Spk#
1071.36Spk# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
1081.36Spk# to achieve this. These targets look like:
1091.36Spk#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
1101.36Spk#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
1111.36Spk# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
1121.36Spk# places corresponding to the .WAITs in our $SUBDIR variable.
1131.36Spk#
1141.36Spk# Also, since we're now mixing `install' with `all' and `depend' targets
1151.36Spk# an order relationship between those in each individual subdirectory
1161.36Spk# must be established.
1171.36Spk#
1181.40Stv_deps:=
1191.40Stv_prev:=
1201.40Stv
1211.16Stv.for d in ${SUBDIR}
1221.16Stv_this:=		${d}
1231.40Stv
1241.16Stv.if ${_this} == ".WAIT"
1251.36Spk
1261.36Spk# setup dependency to apply to all/depend targets in the next group
1271.40Stv_deps:=		${_deps} ${_prev:S/^/install-/}
1281.40Stv
1291.40Stv# if we're building *only* individual targets (i.e. "dependall-yacc"),
1301.40Stv# make sure prerequisite tools build before installing
1311.40Stv.if !make(all) && !make(dependall)
1321.40Stvinstall-${_prev}: dependall-${_prev}
1331.40Stv.endif
1341.36Spk
1351.16Stv.else
1361.36Spk
1371.36Spk# order depend/all/install targets for ${d} subdir.  Note the additional
1381.36Spk# .WAIT to achieve "closure" of the predecessor/successor relationships.
1391.36Spk.ORDER: depend-${d} all-${d} dependall-${d} .WAIT install-${d}
1401.40Stv
1411.40Stv# make all/depend-${d} dependent on list of install targets
1421.40Stvdepend-${d} all-${d} dependall-${d}: ${_deps}
1431.36Spk
1441.16Stv.endif
1451.40Stv
1461.40Stv# stash current name in case the next entry is .WAIT
1471.40Stv_prev:=		${d}
1481.16Stv.endfor
1491.69Stron
1501.69Stroncleandir:
1511.69Stron	rm -f ${CLEANFILES}
152