Makefile revision 1.171
11.171Sskrll#	$NetBSD: Makefile,v 1.171 2014/02/24 07:23:44 skrll Exp $
21.1Stv
31.3Stv.include <bsd.own.mk>
41.167Smatt.include <bsd.endian.mk>
51.3Stv
61.159Sjoerg# Make sure that the ordered build/install processing applies when using
71.159Sjoerg# plain make.
81.159Sjoerg.MAIN: build_install
91.159Sjoerg
101.164Sapb# TOOLDIR must be valid, unless MKTOOLS=no
111.164Sapb.if ${MKTOOLS:Uyes} != "no"
121.164Sapb.if "${TOOLDIR}" == ""
131.164Sapb.error "TOOLDIR is undefined or empty"
141.164Sapb.elif "${TOOLDIR:tW:M/*}" == ""
151.164Sapb.error "TOOLDIR is not an absolute path: ${TOOLDIR}"
161.164Sapb#.elif !exists(TOOLDIR) # XXX .exists fails for directories
171.164Sapb#.error "TOOLDIR does not exist: ${TOOLDIR}"
181.164Sapb.endif
191.164Sapb.endif # MKTOOLS != no
201.164Sapb
211.166Spooka# TOOLS_BUILDRUMP == yes builds only the subset of the tools required
221.166Spooka# for building rump kernels and the hypervisor.  It is typically used
231.166Spooka# when building rump kernels targeted for non-NetBSD systems (via
241.166Spooka# buildrump.sh), and should not be set for a regular "make build".
251.166SpookaTOOLS_BUILDRUMP?=no
261.166Spooka
271.160Spooka.if ${TOOLCHAIN_MISSING} == "no"
281.160Spooka.if defined(HAVE_GCC)
291.94SjmcTOOLCHAIN_BITS= gmake .WAIT
301.156Sjoerg.endif
311.156Sjoerg
321.156Sjoerg.if defined(HAVE_GCC)
331.146Smrg.if ${HAVE_GCC} >= 45
341.146SmrgTOOLCHAIN_BITS+= gmp .WAIT
351.146SmrgTOOLCHAIN_BITS+= mpfr .WAIT
361.146SmrgTOOLCHAIN_BITS+= mpc .WAIT
371.94Sjmc.endif
381.156Sjoerg.endif
391.156Sjoerg.endif
401.156Sjoerg
411.156Sjoerg.if ${TOOLCHAIN_MISSING} == "no"
421.94SjmcTOOLCHAIN_BITS+= binutils .WAIT
431.156Sjoerg.endif
441.156Sjoerg
451.156Sjoerg.if defined(HAVE_GCC)
461.156Sjoerg.if ${TOOLCHAIN_MISSING} == "no"
471.77SmrgTOOLCHAIN_BITS+= gcc
481.169Smatt.  if ${MKCROSSGDB:Uno} != "no" || make(obj)
491.74SclTOOLCHAIN_BITS+= gdb
501.70Smrg.  endif
511.156SjoergTOOLCHAIN_BITS+= .WAIT
521.31Stv.endif
531.118Sgmcgarry.endif
541.118Sgmcgarry
551.118Sgmcgarry.if defined(HAVE_PCC)
561.118Sgmcgarry.if ${TOOLCHAIN_MISSING} == "no"
571.118SgmcgarryTOOLCHAIN_BITS+= pcc
581.118Sgmcgarry.endif
591.118Sgmcgarry.endif
601.31Stv
611.157Spooka.if ${TOOLCHAIN_MISSING} == "no"
621.157Spooka# XXX Eventually, we want to be able to build dbsym and mdsetimage
631.157Spooka# XXX if EXTERNAL_TOOLCHAIN is set.
641.156SjoergTOOLCHAIN_BITS+= dbsym mdsetimage
651.157Spooka.endif
661.156Sjoerg
671.137SdarranDTRACE_BITS=
681.137Sdarran.if ${MKDTRACE} != "no"
691.137SdarranDTRACE_BITS+= .WAIT libelf
701.137SdarranDTRACE_BITS+= .WAIT libdwarf
711.162SapbDTRACE_BITS+= .WAIT libctf
721.137SdarranDTRACE_BITS+= .WAIT ctfconvert ctfmerge
731.137Sdarran.endif
741.137Sdarran
751.99SmrgLINT_BITS=
761.99Smrg.if ${MKLINT} != "no"
771.99SmrgLINT_BITS= lint lint2
781.99Smrg.endif
791.99Smrg
801.165Sapb# All of host-mkdep, compat, and binstall are needed before anything
811.165Sapb# else.  Within this group, they must be built in a specific order, and
821.165Sapb# all of them must be built before any of them is installed.  They may
831.165Sapb# be installed in any order.  This can't be expressed using the .WAIT
841.165Sapb# notation inside the SUBDIR list.
851.165Sapb#
861.165Sapb# XXX .ORDER does not work when multiple targets are passed on the
871.165Sapb# make command line without "-j", so use dependencies in addition to .ORDER.
881.165Sapb#
891.165Sapb.ORDER: dependall-host-mkdep dependall-compat dependall-binstall
901.165Sapb.if make(dependall-host-mkdep) && make(dependall-compat)
911.165Sapbdependall-compat: dependall-host-mkdep
921.165Sapb.endif
931.165Sapb.if make(dependall-compat) && make(dependall-binstall)
941.165Sapbdependall-binstall: dependall-compat
951.165Sapb.endif
961.165Sapb
971.16Stv# Dependencies in SUBDIR below ordered to maximize parallel ability.
981.165Sapb# See above for special treatment for host-mkdep, compat, and binstall.
991.165Sapb#
1001.165SapbSUBDIR=	host-mkdep compat binstall \
1011.166Spooka	.WAIT mktemp .WAIT sed .WAIT
1021.166Spooka.if ${TOOLS_BUILDRUMP} == "no"
1031.166SpookaSUBDIR+= cap_mkdb crunchgen ctags genassym gencat hexdump \
1041.99Smrg		${LINT_BITS} \
1051.166Spooka		makewhatis mtree nbperf .WAIT rpcgen uudecode
1061.166Spooka.endif
1071.166Spooka
1081.166SpookaSUBDIR+= join lorder m4 mkdep tsort .WAIT yacc .WAIT awk .WAIT lex
1091.166Spooka
1101.166Spooka.if ${TOOLS_BUILDRUMP} == "no"
1111.166SpookaSUBDIR += .WAIT texinfo \
1121.153Schristos	.WAIT tic \
1131.132Smrg	.WAIT pax \
1141.132Smrg	.WAIT ${TOOLCHAIN_BITS} \
1151.137Sdarran	${DTRACE_BITS} \
1161.166Spooka		asn1_compile cat cksum compile_et db \
1171.145Selric		file lint1 slc \
1181.144Sriz		makefs .WAIT menuc mkcsmapper mkesdb mklocale mknod msgc \
1191.132Smrg		.WAIT disklabel \
1201.132Smrg		.WAIT paxctl \
1211.132Smrg		.WAIT fdisk \
1221.132Smrg		.WAIT installboot \
1231.154Snjoly		pwd_mkdb stat strfile sunlabel zic
1241.166Spooka.endif
1251.166SpookaSUBDIR+= .WAIT config
1261.39Stv
1271.142Sjoerg.if ${MKLLVM} != "no"
1281.142SjoergSUBDIR+= \
1291.142Sjoerg	llvm .WAIT \
1301.149Sjoerg	llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \
1311.159Sjoerg	llvm-tblgen llvm-clang-tblgen .WAIT \
1321.142Sjoerg	llvm-include .WAIT \
1331.142Sjoerg	llvm-lib .WAIT \
1341.142Sjoerg	llvm-clang
1351.170Sjoerg.if ${MKLLD} != "no"
1361.170SjoergSUBDIR+=	llvm-lld
1371.170Sjoerg.endif
1381.168Sjoerg.if ${MKMCLINKER} != "no"
1391.168SjoergSUBDIR+=	llvm-mcld
1401.168Sjoerg.endif
1411.142Sjoerg.endif
1421.142Sjoerg
1431.121Sdyoung.if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
1441.136Sjoerg.  if ${MKGROFF} != "no"
1451.39StvSUBDIR+=	groff
1461.136Sjoerg.  endif
1471.128SjoergSUBDIR+=	mandoc
1481.39Stv.endif
1491.22Stv
1501.166Spooka.if ${TOOLS_BUILDRUMP} == "no"
1511.166Spooka
1521.22Stv.if ${MKMAINTAINERTOOLS:Uno} != "no"
1531.103SlukemSUBDIR+=	autoconf .WAIT gettext
1541.72Smatt.endif
1551.72Smatt
1561.140Smrg.if ${USE_PIGZGZIP} != "no"
1571.140SmrgSUBDIR+=	pigz
1581.140Smrg.endif
1591.140Smrg
1601.171Sskrll.if ${MACHINE} == "hppa"
1611.171SskrllSUBDIR+=	hppa-mkboot
1621.83Sskrll.endif
1631.83Sskrll
1641.86Sjmc.if ${MACHINE} == "ibmnws"
1651.72SmattSUBDIR+=	ibmnws-ncdcs
1661.79Smatt.endif
1671.79Smatt
1681.86Sjmc.if ${MACHINE} == "macppc"
1691.79SmattSUBDIR+=	macppc-fixcoff
1701.48Skleink.endif
1711.48Skleink
1721.116Sgarbled.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
1731.115SgarbledSUBDIR+=	powerpc-mkbootimage
1741.22Stv.endif
1751.37Sgmcgarry
1761.148Stsutsui.if ${MACHINE_ARCH} == "m68k"
1771.148StsutsuiSUBDIR+=	m68k-elf2aout
1781.148Stsutsui.endif
1791.148Stsutsui
1801.147Smrg.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
1811.147Smrg     ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb")
1821.37SgmcgarrySUBDIR+=	mips-elf2ecoff
1831.76Ssekiya.endif
1841.76Ssekiya
1851.76Ssekiya.if (${MACHINE} == "sgimips")
1861.76SsekiyaSUBDIR+=	sgivol
1871.51Sbjh21.endif
1881.51Sbjh21
1891.82Sabs.if ${MACHINE} == "acorn32"
1901.82SabsSUBDIR+=	sparkcrc
1911.82Sabs.endif
1921.82Sabs
1931.125Sabs.if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64")
1941.51Sbjh21SUBDIR+=	fgen
1951.37Sgmcgarry.endif
1961.37Sgmcgarry
1971.85Sjmc.if ${MACHINE} == "amiga"
1981.85SjmcSUBDIR+=	amiga-elf2bb
1991.85SjmcSUBDIR+=	amiga-txlt
2001.85Sjmc.endif
2011.85Sjmc
2021.86Sjmc.if ${MACHINE} == "hp300"
2031.86SjmcSUBDIR+=	hp300-mkboot
2041.86Sjmc.endif
2051.86Sjmc
2061.167Smatt.if ${MACHINE} == "evbarm" \
2071.167Smatt    && ${MACHINE_CPU} == "arm" \
2081.167Smatt    && ${TARGET_ENDIANNESS} == "1234"
2091.158SjkunzSUBDIR+=	elftosb
2101.158Sjkunz.endif
2111.158Sjkunz
2121.143Sphx.if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
2131.143Sphx    ${MACHINE} == "evbppc" || ${MACHINE} == "sandpoint"
2141.139SjmcneillSUBDIR+=	mkubootimage
2151.139Sjmcneill.endif
2161.139Sjmcneill
2171.166Spooka.endif # TOOLCHAIN_BUILDRUMP
2181.166Spooka
2191.66Slukemcheck_MKTOOLS: .PHONY .NOTMAIN
2201.19Sjmc.if ${MKTOOLS:Uyes} == "no"
2211.17Stv	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
2221.17Stv	@echo '*** updating your host toolchain.  This should be used only as a'
2231.17Stv	@echo '*** temporary workaround for toolchain problems, as it will result'
2241.23Swiz	@echo '*** in version skew and build errors over time!'
2251.18Sjmc.endif
2261.17Stv
2271.66Slukem.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
2281.163SapbSUBDIR= # empty
2291.67Slukemrealall realdepend install: check_MKTOOLS
2301.66Slukem.endif							# }
2311.1Stv
2321.1Stv.include <bsd.subdir.mk>
2331.159Sjoerg.include <bsd.buildinstall.mk>
2341.11Stv.include <bsd.obj.mk>
2351.16Stv
2361.102Stron.if !defined(PREVIOUSTOOLDIR)
2371.102Stron.  if exists(PREVIOUSTOOLDIR)
2381.66SlukemPREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
2391.102Stron.  else
2401.162SapbPREVIOUSTOOLDIR=
2411.102Stron.  endif
2421.66Slukem.endif
2431.66Slukem
2441.66SlukemCLEANFILES+=	PREVIOUSTOOLDIR
2451.66Slukem
2461.101Stronrealall realdepend: .MAKE
2471.107Sapb.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
2481.66Slukem	@echo "*** WARNING: TOOLDIR has moved?"
2491.66Slukem	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
2501.66Slukem	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
2511.66Slukem	@echo "*** Cleaning mis-matched tools"
2521.66Slukem	rm -f PREVIOUSTOOLDIR
2531.106Sfreza	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
2541.66Slukem.endif
2551.102Stron	echo ${TOOLDIR} >PREVIOUSTOOLDIR
2561.66Slukem
2571.69Stroncleandir:
2581.69Stron	rm -f ${CLEANFILES}
259