Makefile revision 1.122
11.122Sapb#	$NetBSD: Makefile,v 1.122 2008/10/19 19:40:19 apb 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.120Sapb		lorder m4 makewhatis mkdep mtree rpcgen tsort uudecode \
431.120Sapb	sed .WAIT \
441.32Stv	texinfo .WAIT \
451.16Stv	yacc .WAIT \
461.122Sapb	awk .WAIT \
471.16Stv	lex .WAIT \
481.32Stv	${TOOLCHAIN_BITS} \
491.114Sjmmv		asn1_compile atf-compile cat cksum compile_et config db \
501.91Sdyoung		file lint1 \
511.90Sdyoung		makefs menuc mkcsmapper mkesdb mklocale mknod msgc \
521.90Sdyoung		pax .WAIT \
531.92Sjmc		disklabel .WAIT \
541.110Sriz		paxctl .WAIT \
551.92Sjmc		fdisk .WAIT \
561.92Sjmc		installboot .WAIT \
571.119Sapb		pwd_mkdb stat strfile sunlabel zic
581.39Stv
591.121Sdyoung.if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
601.39StvSUBDIR+=	groff
611.39Stv.endif
621.22Stv
631.22Stv.if ${MKMAINTAINERTOOLS:Uno} != "no"
641.103SlukemSUBDIR+=	autoconf .WAIT gettext
651.72Smatt.endif
661.72Smatt
671.86Sjmc.if ${MACHINE} == "hp700"
681.83SskrllSUBDIR+=	hp700-mkboot
691.83Sskrll.endif
701.83Sskrll
711.86Sjmc.if ${MACHINE} == "ibmnws"
721.72SmattSUBDIR+=	ibmnws-ncdcs
731.79Smatt.endif
741.79Smatt
751.86Sjmc.if ${MACHINE} == "macppc"
761.79SmattSUBDIR+=	macppc-fixcoff
771.48Skleink.endif
781.48Skleink
791.116Sgarbled.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
801.115SgarbledSUBDIR+=	powerpc-mkbootimage
811.22Stv.endif
821.37Sgmcgarry
831.37Sgmcgarry.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb")
841.37SgmcgarrySUBDIR+=	mips-elf2ecoff
851.76Ssekiya.endif
861.76Ssekiya
871.76Ssekiya.if (${MACHINE} == "sgimips")
881.76SsekiyaSUBDIR+=	sgivol
891.51Sbjh21.endif
901.51Sbjh21
911.82Sabs.if ${MACHINE} == "acorn32"
921.82SabsSUBDIR+=	sparkcrc
931.82Sabs.endif
941.82Sabs
951.51Sbjh21.if (${MACHINE} == "sparc" || ${MACHINE} == "sparc64")
961.51Sbjh21SUBDIR+=	fgen
971.37Sgmcgarry.endif
981.37Sgmcgarry
991.85Sjmc.if ${MACHINE} == "amiga"
1001.85SjmcSUBDIR+=	amiga-elf2bb
1011.85SjmcSUBDIR+=	amiga-txlt
1021.85Sjmc.endif
1031.85Sjmc
1041.86Sjmc.if ${MACHINE} == "hp300"
1051.86SjmcSUBDIR+=	hp300-mkboot
1061.86Sjmc.endif
1071.86Sjmc
1081.50Slukem.endif	# ! NOSUBDIR					# }
1091.17Stv
1101.66Slukemcheck_MKTOOLS: .PHONY .NOTMAIN
1111.19Sjmc.if ${MKTOOLS:Uyes} == "no"
1121.17Stv	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
1131.17Stv	@echo '*** updating your host toolchain.  This should be used only as a'
1141.17Stv	@echo '*** temporary workaround for toolchain problems, as it will result'
1151.23Swiz	@echo '*** in version skew and build errors over time!'
1161.18Sjmc.endif
1171.17Stv
1181.66Slukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
1191.67Slukemrealall realdepend install: check_MKTOOLS
1201.66Slukem
1211.17Stv.for dir in ${SUBDIR:N.WAIT}
1221.17Stvall-${dir} depend-${dir} dependall-${dir} install-${dir}:
1231.17Stv	@true
1241.17Stv.endfor
1251.66Slukem.endif							# }
1261.1Stv
1271.1Stv.include <bsd.subdir.mk>
1281.11Stv.include <bsd.obj.mk>
1291.16Stv
1301.102Stron.if !defined(PREVIOUSTOOLDIR)
1311.102Stron.  if exists(PREVIOUSTOOLDIR)
1321.66SlukemPREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
1331.102Stron.  else
1341.66SlukemPREVIOUSTOOLDIR=	
1351.102Stron.  endif
1361.66Slukem.endif
1371.66Slukem
1381.66SlukemCLEANFILES+=	PREVIOUSTOOLDIR
1391.66Slukem
1401.101Stronrealall realdepend: .MAKE
1411.107Sapb.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
1421.66Slukem	@echo "*** WARNING: TOOLDIR has moved?"
1431.66Slukem	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
1441.66Slukem	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
1451.66Slukem	@echo "*** Cleaning mis-matched tools"
1461.66Slukem	rm -f PREVIOUSTOOLDIR
1471.106Sfreza	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
1481.66Slukem.endif
1491.102Stron	echo ${TOOLDIR} >PREVIOUSTOOLDIR
1501.66Slukem
1511.40Stv# For each .WAIT point, make sure the immediately preceding target is
1521.40Stv# installed before building anything after that point.
1531.109Sdsl# (dsl: which means that with: 'a b .WAIT c' the build of 'c' waits for the
1541.109Sdsl# install of 'b', but not the install of 'a'.)
1551.36Spk#
1561.36Spk# We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
1571.36Spk# to achieve this. These targets look like:
1581.36Spk#	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
1591.36Spk#	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
1601.36Spk# and so on for each element in ${TARGETS}, with .WAIT sources inserted at
1611.36Spk# places corresponding to the .WAITs in our $SUBDIR variable.
1621.36Spk#
1631.36Spk# Also, since we're now mixing `install' with `all' and `depend' targets
1641.36Spk# an order relationship between those in each individual subdirectory
1651.36Spk# must be established.
1661.36Spk#
1671.40Stv_deps:=
1681.40Stv_prev:=
1691.40Stv
1701.16Stv.for d in ${SUBDIR}
1711.16Stv_this:=		${d}
1721.40Stv
1731.16Stv.if ${_this} == ".WAIT"
1741.36Spk
1751.36Spk# setup dependency to apply to all/depend targets in the next group
1761.40Stv_deps:=		${_deps} ${_prev:S/^/install-/}
1771.40Stv
1781.40Stv# if we're building *only* individual targets (i.e. "dependall-yacc"),
1791.40Stv# make sure prerequisite tools build before installing
1801.109Sdsl# XXX: dsl: this is likely to generate a dependency loop since there is
1811.109Sdsl# a .ORDER releation between the nodes as well.
1821.109Sdsl.if !make(all) && !make(dependall) && !make(install)
1831.40Stvinstall-${_prev}: dependall-${_prev}
1841.40Stv.endif
1851.36Spk
1861.16Stv.else
1871.36Spk
1881.109Sdsl# order depend/all/install targets for ${d} subdir.
1891.109Sdsl.ORDER: depend-${d} all-${d} dependall-${d} install-${d}
1901.40Stv
1911.106Sfreza# prevent cleandir in real{all,depend} from interfering with subdir makes
1921.106Sfreza.ORDER: realdepend dependall-${d}
1931.106Sfreza.ORDER: realdepend depend-${d}
1941.106Sfreza.ORDER: realall all-${d}
1951.106Sfreza
1961.40Stv# make all/depend-${d} dependent on list of install targets
1971.40Stvdepend-${d} all-${d} dependall-${d}: ${_deps}
1981.36Spk
1991.16Stv.endif
2001.40Stv
2011.40Stv# stash current name in case the next entry is .WAIT
2021.40Stv_prev:=		${d}
2031.16Stv.endfor
2041.69Stron
2051.69Stroncleandir:
2061.69Stron	rm -f ${CLEANFILES}
207