Index: native_client_sdk/src/tools/common.mk |
diff --git a/native_client_sdk/src/tools/common.mk b/native_client_sdk/src/tools/common.mk |
index 387aad8820cf51ecaf2fef0a5406a6128710e2e3..c3458f6592b219927edd181eda754cdcbf6e0c11 100644 |
--- a/native_client_sdk/src/tools/common.mk |
+++ b/native_client_sdk/src/tools/common.mk |
@@ -7,7 +7,6 @@ |
# http://www.gnu.org/software/make/manual/make.html |
# |
- |
# |
# Toolchain |
# |
@@ -33,6 +32,48 @@ OSNAME:=$(shell $(GETOS)) |
# |
+# TOOLCHAIN=all recursively calls this Makefile for all VALID_TOOLCHAINS. |
+# |
+ifeq ($(TOOLCHAIN),all) |
+ |
+# Define the default target |
+all: |
+ |
+# |
+# Generate a new MAKE command for each TOOLCHAIN. |
+# |
+# Note: We use targets for each toolchain (instead of an explicit recipe) so |
+# each toolchain can be built in parallel. |
+# |
+# $1 = Toolchain Name |
+# |
+define TOOLCHAIN_RULE |
+TOOLCHAIN_TARGETS += $(1)_TARGET |
+.PHONY: $(1)_TARGET |
+$(1)_TARGET: |
+ +$(MAKE) TOOLCHAIN=$(1) $(MAKECMDGOALS) |
+endef |
+ |
+# |
+# The target for all versions |
+# |
+USABLE_TOOLCHAINS=$(filter $(OSNAME) newlib glibc pnacl,$(VALID_TOOLCHAINS)) |
+ |
+ifeq ($(NO_HOST_BUILDS),1) |
+USABLE_TOOLCHAINS:=$(filter-out $(OSNAME),$(USABLE_TOOLCHAINS)) |
+endif |
+ |
+# Define the toolchain targets for all usable toolchains via the macro. |
+$(foreach tool,$(USABLE_TOOLCHAINS),$(eval $(call TOOLCHAIN_RULE,$(tool)))) |
+ |
+.PHONY: all clean install |
+all: $(TOOLCHAIN_TARGETS) |
+clean: $(TOOLCHAIN_TARGETS) |
+install: $(TOOLCHAIN_TARGETS) |
+ |
+else # TOOLCHAIN=all |
+ |
+# |
# Verify we selected a valid toolchain for this example |
# |
ifeq (,$(findstring $(TOOLCHAIN),$(VALID_TOOLCHAINS))) |
@@ -156,34 +197,6 @@ install: |
.PHONY: install |
-# |
-# Target a toolchain |
-# |
-# $1 = Toolchain Name |
-# |
-define TOOLCHAIN_RULE |
-.PHONY: all_$(1) |
-all_$(1): |
- +$(MAKE) TOOLCHAIN=$(1) |
-TOOLCHAIN_LIST+=all_$(1) |
-endef |
- |
- |
-# |
-# The target for all versions |
-# |
-USABLE_TOOLCHAINS=$(filter $(OSNAME) newlib glibc pnacl,$(VALID_TOOLCHAINS)) |
- |
-ifeq ($(NO_HOST_BUILDS),1) |
-USABLE_TOOLCHAINS:=$(filter-out $(OSNAME),$(USABLE_TOOLCHAINS)) |
-endif |
- |
-$(foreach tool,$(USABLE_TOOLCHAINS),$(eval $(call TOOLCHAIN_RULE,$(tool),$(dep)))) |
- |
-.PHONY: all_versions |
-all_versions: $(TOOLCHAIN_LIST) |
- |
- |
OUTBASE?=. |
OUTDIR:=$(OUTBASE)/$(TOOLCHAIN)/$(CONFIG) |
STAMPDIR?=$(OUTDIR) |
@@ -427,3 +440,5 @@ CHECK_FOR_CHROME: check_for_chrome |
DEBUG: debug |
LAUNCH: run |
RUN: run |
+ |
+endif # TOOLCHAIN=all |