Makefile revision 1.118
11.118Sgmcgarry#	$NetBSD: Makefile,v 1.118 2008/08/24 05:53:36 gmcgarry Exp $
21.1Stv
31.3Stv.include <bsd.own.mk>
41.3Stv
51.118Sgmcgarry.if defined(HAVE_GCC)
61.96Smrg.if ${HAVE_GCC} == "4"
71.94SjmcTOOLCHAIN_BITS= gmake .WAIT
81.94Sjmc.endif
91.81Slukem.if ${TOOLCHAIN_MISSING} == "no"
101.94SjmcTOOLCHAIN_BITS+= binutils .WAIT
111.77SmrgTOOLCHAIN_BITS+= gcc
121.97Smrg.  if ${MKCROSSGDB:Uno} != "no"
131.74SclTOOLCHAIN_BITS+= gdb
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.118Sgmcgarry.endif
201.118Sgmcgarry
211.118Sgmcgarry.if defined(HAVE_PCC)
221.118SgmcgarryTOOLCHAIN_BITS= gmake .WAIT
231.118Sgmcgarry.if ${TOOLCHAIN_MISSING} == "no"
241.118SgmcgarryTOOLCHAIN_BITS+= binutils .WAIT
251.118SgmcgarryTOOLCHAIN_BITS+= pcc
261.118Sgmcgarry.endif
271.118SgmcgarryTOOLCHAIN_BITS+= .WAIT dbsym mdsetimage
281.118Sgmcgarry.endif
291.31Stv
301.99SmrgLINT_BITS=
311.99Smrg.if ${MKLINT} != "no"
321.99SmrgLINT_BITS= lint lint2
331.99Smrg.endif
341.99Smrg
351.16Stv# Dependencies in SUBDIR below ordered to maximize parallel ability.
361.50Slukem.if !defined(NOSUBDIR)					# {
371.50Slukem
381.29StvSUBDIR=	host-mkdep .WAIT compat .WAIT \
391.110Sriz	binstall .WAIT mktemp .WAIT \
401.113Sapb		cap_mkdb crunchgen ctags genassym gencat hexdump join \
411.99Smrg		${LINT_BITS} \
421.98Sgdamore		lorder m4 makewhatis mkdep mtree rpcgen sed tsort uudecode \
431.32Stv	texinfo .WAIT \
441.16Stv	yacc .WAIT \
451.16Stv	lex .WAIT \
461.32Stv	${TOOLCHAIN_BITS} \
471.114Sjmmv		asn1_compile atf-compile cat cksum compile_et config db \
481.91Sdyoung		file lint1 \
491.90Sdyoung		makefs menuc mkcsmapper mkesdb mklocale mknod msgc \
501.90Sdyoung		pax .WAIT \
511.92Sjmc		disklabel .WAIT \
521.110Sriz		paxctl .WAIT \
531.92Sjmc		fdisk .WAIT \
541.92Sjmc		installboot .WAIT \
551.68Slukem		pwd_mkdb stat sunlabel zic
561.39Stv
571.39Stv.if ${MKMAN} != "no"
581.39StvSUBDIR+=	groff
591.39Stv.endif
601.22Stv
611.22Stv.if ${MKMAINTAINERTOOLS:Uno} != "no"
621.103SlukemSUBDIR+=	autoconf .WAIT gettext
631.72Smatt.endif
641.72Smatt
651.86Sjmc.if ${MACHINE} == "hp700"
661.83SskrllSUBDIR+=	hp700-mkboot
671.83Sskrll.endif
681.83Sskrll
691.86Sjmc.if ${MACHINE} == "ibmnws"
701.72SmattSUBDIR+=	ibmnws-ncdcs
711.79Smatt.endif
721.79Smatt
731.86Sjmc.if ${MACHINE} == "macppc"
741.79SmattSUBDIR+=	macppc-fixcoff
751.48Skleink.endif
761.48Skleink
771.116Sgarbled.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
781.115SgarbledSUBDIR+=	powerpc-mkbootimage
791.22Stv.endif
801.37Sgmcgarry
811.37Sgmcgarry.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb")
821.37SgmcgarrySUBDIR+=	mips-elf2ecoff
831.76Ssekiya.endif
841.76Ssekiya
851.76Ssekiya.if (${MACHINE} == "sgimips")
861.76SsekiyaSUBDIR+=	sgivol
871.51Sbjh21.endif
881.51Sbjh21
891.82Sabs.if ${MACHINE} == "acorn32"
901.82SabsSUBDIR+=	sparkcrc
911.82Sabs.endif
921.82Sabs
931.51Sbjh21.if (${MACHINE} == "sparc" || ${MACHINE} == "sparc64")
941.51Sbjh21SUBDIR+=	fgen
951.37Sgmcgarry.endif
961.37Sgmcgarry
971.85Sjmc.if ${MACHINE} == "amiga"
981.85SjmcSUBDIR+=	amiga-elf2bb
991.85SjmcSUBDIR+=	amiga-txlt
1001.85Sjmc.endif
1011.85Sjmc
1021.86Sjmc.if ${MACHINE} == "hp300"
1031.86SjmcSUBDIR+=	hp300-mkboot
1041.86Sjmc.endif
1051.86Sjmc
1061.50Slukem.endif	# ! NOSUBDIR					# }
1071.17Stv
1081.66Slukemcheck_MKTOOLS: .PHONY .NOTMAIN
1091.19Sjmc.if ${MKTOOLS:Uyes} == "no"
1101.17Stv	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
1111.17Stv	@echo '*** updating your host toolchain.  This should be used only as a'
1121.17Stv	@echo '*** temporary workaround for toolchain problems, as it will result'
1131.23Swiz	@echo '*** in version skew and build errors over time!'
1141.18Sjmc.endif
1151.17Stv
1161.66Slukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
1171.67Slukemrealall realdepend install: check_MKTOOLS
1181.66Slukem
1191.17Stv.for dir in ${SUBDIR:N.WAIT}
1201.17Stvall-${dir} depend-${dir} dependall-${dir} install-${dir}:
1211.17Stv	@true
1221.17Stv.endfor
1231.66Slukem.endif							# }
1241.1Stv
1251.1Stv.include <bsd.subdir.mk>
1261.11Stv.include <bsd.obj.mk>
1271.16Stv
1281.102Stron.if !defined(PREVIOUSTOOLDIR)
1291.102Stron.  if exists(PREVIOUSTOOLDIR)
1301.66SlukemPREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
1311.102Stron.  else
1321.66SlukemPREVIOUSTOOLDIR=	
1331.102Stron.  endif
1341.66Slukem.endif
1351.66Slukem
1361.66SlukemCLEANFILES+=	PREVIOUSTOOLDIR
1371.66Slukem
1381.101Stronrealall realdepend: .MAKE
1391.107Sapb.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
1401.66Slukem	@echo "*** WARNING: TOOLDIR has moved?"
1411.66Slukem	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
1421.66Slukem	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
1431.66Slukem	@echo "*** Cleaning mis-matched tools"
1441.66Slukem	rm -f PREVIOUSTOOLDIR
1451.106Sfreza	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
1461.66Slukem.endif
1471.102Stron	echo ${TOOLDIR} >PREVIOUSTOOLDIR
1481.66Slukem
1491.40Stv# For each .WAIT point, make sure the immediately preceding target is
1501.40Stv# installed before building anything after that point.
1511.109Sdsl# (dsl: which means that with: 'a b .WAIT c' the build of 'c' waits for the
1521.109Sdsl# install of 'b', but not the install of 'a'.)
1531.36Spk#
1541.36Spk# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
1551.36Spk# to achieve this. These targets look like:
1561.36Spk#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
1571.36Spk#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
1581.36Spk# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
1591.36Spk# places corresponding to the .WAITs in our $SUBDIR variable.
1601.36Spk#
1611.36Spk# Also, since we're now mixing `install' with `all' and `depend' targets
1621.36Spk# an order relationship between those in each individual subdirectory
1631.36Spk# must be established.
1641.36Spk#
1651.40Stv_deps:=
1661.40Stv_prev:=
1671.40Stv
1681.16Stv.for d in ${SUBDIR}
1691.16Stv_this:=		${d}
1701.40Stv
1711.16Stv.if ${_this} == ".WAIT"
1721.36Spk
1731.36Spk# setup dependency to apply to all/depend targets in the next group
1741.40Stv_deps:=		${_deps} ${_prev:S/^/install-/}
1751.40Stv
1761.40Stv# if we're building *only* individual targets (i.e. "dependall-yacc"),
1771.40Stv# make sure prerequisite tools build before installing
1781.109Sdsl# XXX: dsl: this is likely to generate a dependency loop since there is
1791.109Sdsl# a .ORDER releation between the nodes as well.
1801.109Sdsl.if !make(all) && !make(dependall) && !make(install)
1811.40Stvinstall-${_prev}: dependall-${_prev}
1821.40Stv.endif
1831.36Spk
1841.16Stv.else
1851.36Spk
1861.109Sdsl# order depend/all/install targets for ${d} subdir.
1871.109Sdsl.ORDER: depend-${d} all-${d} dependall-${d} install-${d}
1881.40Stv
1891.106Sfreza# prevent cleandir in real{all,depend} from interfering with subdir makes
1901.106Sfreza.ORDER: realdepend dependall-${d}
1911.106Sfreza.ORDER: realdepend depend-${d}
1921.106Sfreza.ORDER: realall all-${d}
1931.106Sfreza
1941.40Stv# make all/depend-${d} dependent on list of install targets
1951.40Stvdepend-${d} all-${d} dependall-${d}: ${_deps}
1961.36Spk
1971.16Stv.endif
1981.40Stv
1991.40Stv# stash current name in case the next entry is .WAIT
2001.40Stv_prev:=		${d}
2011.16Stv.endfor
2021.69Stron
2031.69Stroncleandir:
2041.69Stron	rm -f ${CLEANFILES}
205