You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by yu...@apache.org on 2024/01/10 02:28:32 UTC

(incubator-teaclave-trustzone-sdk) 02/04: Makefile: examples: Enable mixed build configurations

This is an automated email from the ASF dual-hosted git repository.

yuanz pushed a commit to branch no-std
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git

commit 558eceb001e2cf7041d1a3c14679980a3d4082f6
Author: Sumit Garg <su...@linaro.org>
AuthorDate: Mon Jan 8 16:21:13 2024 +0530

    Makefile: examples: Enable mixed build configurations
    
    Extend Makefile infrastructure to support different combinations for
    host and TA rust targets. Following environment variables are added:
    - TARGET_HOST
    - TARGET_TA
    - CROSS_COMPILE_HOST
    - CROSS_COMPILE_TA
    
    Signed-off-by: Sumit Garg <su...@linaro.org>
---
 Makefile                                         | 30 ++++++++++++++----------
 examples/acipher-rs/Makefile                     | 20 ++++++++++++----
 examples/acipher-rs/host/Makefile                | 12 +++-------
 examples/acipher-rs/ta/Makefile                  | 15 ++++--------
 examples/aes-rs/Makefile                         | 20 ++++++++++++----
 examples/aes-rs/host/Makefile                    | 12 +++-------
 examples/aes-rs/ta/Makefile                      | 15 ++++--------
 examples/authentication-rs/Makefile              | 20 ++++++++++++----
 examples/authentication-rs/host/Makefile         | 12 +++-------
 examples/authentication-rs/ta/Makefile           | 15 ++++--------
 examples/big_int-rs/Makefile                     | 20 ++++++++++++----
 examples/big_int-rs/host/Makefile                | 12 +++-------
 examples/big_int-rs/ta/Makefile                  | 15 ++++--------
 examples/diffie_hellman-rs/Makefile              | 20 ++++++++++++----
 examples/diffie_hellman-rs/host/Makefile         | 12 +++-------
 examples/diffie_hellman-rs/ta/Makefile           | 15 ++++--------
 examples/digest-rs/Makefile                      | 20 ++++++++++++----
 examples/digest-rs/host/Makefile                 | 12 +++-------
 examples/digest-rs/ta/Makefile                   | 15 ++++--------
 examples/hello_world-rs/Makefile                 | 20 ++++++++++++----
 examples/hello_world-rs/host/Makefile            | 12 +++-------
 examples/hello_world-rs/ta/Makefile              | 15 ++++--------
 examples/hotp-rs/Makefile                        | 20 ++++++++++++----
 examples/hotp-rs/host/Makefile                   | 12 +++-------
 examples/hotp-rs/ta/Makefile                     | 15 ++++--------
 examples/random-rs/Makefile                      | 20 ++++++++++++----
 examples/random-rs/host/Makefile                 | 12 +++-------
 examples/random-rs/ta/Makefile                   | 15 ++++--------
 examples/secure_storage-rs/Makefile              | 20 ++++++++++++----
 examples/secure_storage-rs/host/Makefile         | 12 +++-------
 examples/secure_storage-rs/ta/Makefile           | 15 ++++--------
 examples/signature_verification-rs/Makefile      | 20 ++++++++++++----
 examples/signature_verification-rs/host/Makefile | 12 +++-------
 examples/signature_verification-rs/ta/Makefile   | 15 ++++--------
 examples/supp_plugin-rs/Makefile                 | 25 +++++++++++++++-----
 examples/supp_plugin-rs/host/Makefile            | 12 +++-------
 examples/supp_plugin-rs/plugin/Makefile          | 12 +++-------
 examples/supp_plugin-rs/ta/Makefile              | 15 ++++--------
 examples/time-rs/Makefile                        | 20 ++++++++++++----
 examples/time-rs/host/Makefile                   | 12 +++-------
 examples/time-rs/ta/Makefile                     | 15 ++++--------
 41 files changed, 323 insertions(+), 335 deletions(-)

diff --git a/Makefile b/Makefile
index 8524854..3654165 100644
--- a/Makefile
+++ b/Makefile
@@ -22,20 +22,22 @@ else
 	q :=
 	echo := @:
 endif
+# export 'q', used by sub-makefiles.
+export q
 
 EXAMPLES = $(wildcard examples/*)
 EXAMPLES_INSTALL = $(EXAMPLES:%=%-install)
 EXAMPLES_CLEAN  = $(EXAMPLES:%=%-clean)
 
-ifneq ($(ARCH), arm)
-	CROSS_COMPILE ?= aarch64-linux-gnu-
-	TARGET := aarch64-unknown-linux-gnu
-else
-	CROSS_COMPILE ?= arm-linux-gnueabihf-
-	TARGET := arm-unknown-linux-gnueabihf
-endif
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 
-export ARCH
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
 
 .PHONY: all
 ifneq ($(wildcard $(TA_DEV_KIT_DIR)/host_include/conf.mk),)
@@ -47,15 +49,19 @@ endif
 
 examples: $(EXAMPLES)
 $(EXAMPLES):
-	$(q)make -C $@ CROSS_COMPILE=$(CROSS_COMPILE) TA_DEV_KIT_DIR=$(TA_DEV_KIT_DIR) \
+	$(q)make -C $@ TARGET_HOST=$(TARGET_HOST) \
+		TARGET_TA=$(TARGET_TA) \
+		CROSS_COMPILE_HOST=$(CROSS_COMPILE_HOST) \
+		CROSS_COMPILE_TA=$(CROSS_COMPILE_TA) \
+		TA_DEV_KIT_DIR=$(TA_DEV_KIT_DIR) \
 		OPTEE_CLIENT_EXPORT=$(OPTEE_CLIENT_EXPORT)
 
 examples-install: $(EXAMPLES_INSTALL)
 $(EXAMPLES_INSTALL): examples
-	install -D $(@:%-install=%)/host/target/$(TARGET)/release/$(@:examples/%-install=%) -t out/host/
-	install -D $(@:%-install=%)/ta/target/$(TARGET)/release/*.ta -t out/ta/
+	install -D $(@:%-install=%)/host/target/$(TARGET_HOST)/release/$(@:examples/%-install=%) -t out/host/
+	install -D $(@:%-install=%)/ta/target/$(TARGET_TA)/release/*.ta -t out/ta/
 	$(q)if [ -d "$(@:%-install=%)/plugin/target/" ]; then \
-		install -D $(@:%-install=%)/plugin/target/$(TARGET)/release/*.plugin.so -t out/plugin/; \
+		install -D $(@:%-install=%)/plugin/target/$(TARGET_HOST)/release/*.plugin.so -t out/plugin/; \
 	fi
 
 examples-clean: $(EXAMPLES_CLEAN) out-clean
diff --git a/examples/acipher-rs/Makefile b/examples/acipher-rs/Makefile
index 09679cd..db4e5bb 100644
--- a/examples/acipher-rs/Makefile
+++ b/examples/acipher-rs/Makefile
@@ -15,10 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
+	$(q)make -C host clean
+	$(q)make -C ta clean
diff --git a/examples/acipher-rs/host/Makefile b/examples/acipher-rs/host/Makefile
index 836eb5f..5b50c28 100644
--- a/examples/acipher-rs/host/Makefile
+++ b/examples/acipher-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := acipher-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/acipher-rs/ta/Makefile b/examples/acipher-rs/ta/Makefile
index a06cd97..ad35909 100644
--- a/examples/acipher-rs/ta/Makefile
+++ b/examples/acipher-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign
diff --git a/examples/aes-rs/Makefile b/examples/aes-rs/Makefile
index 09679cd..db4e5bb 100644
--- a/examples/aes-rs/Makefile
+++ b/examples/aes-rs/Makefile
@@ -15,10 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
+	$(q)make -C host clean
+	$(q)make -C ta clean
diff --git a/examples/aes-rs/host/Makefile b/examples/aes-rs/host/Makefile
index 4a62581..406e984 100644
--- a/examples/aes-rs/host/Makefile
+++ b/examples/aes-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := aes-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/aes-rs/ta/Makefile b/examples/aes-rs/ta/Makefile
index a06cd97..ad35909 100644
--- a/examples/aes-rs/ta/Makefile
+++ b/examples/aes-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign
diff --git a/examples/authentication-rs/Makefile b/examples/authentication-rs/Makefile
index 09679cd..db4e5bb 100644
--- a/examples/authentication-rs/Makefile
+++ b/examples/authentication-rs/Makefile
@@ -15,10 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
+	$(q)make -C host clean
+	$(q)make -C ta clean
diff --git a/examples/authentication-rs/host/Makefile b/examples/authentication-rs/host/Makefile
index 711ef5b..5a9d0f0 100644
--- a/examples/authentication-rs/host/Makefile
+++ b/examples/authentication-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := authentication-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/authentication-rs/ta/Makefile b/examples/authentication-rs/ta/Makefile
index a06cd97..ad35909 100644
--- a/examples/authentication-rs/ta/Makefile
+++ b/examples/authentication-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign
diff --git a/examples/big_int-rs/Makefile b/examples/big_int-rs/Makefile
index 09679cd..db4e5bb 100644
--- a/examples/big_int-rs/Makefile
+++ b/examples/big_int-rs/Makefile
@@ -15,10 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
+	$(q)make -C host clean
+	$(q)make -C ta clean
diff --git a/examples/big_int-rs/host/Makefile b/examples/big_int-rs/host/Makefile
index cd11317..4b11792 100644
--- a/examples/big_int-rs/host/Makefile
+++ b/examples/big_int-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := big_int-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/big_int-rs/ta/Makefile b/examples/big_int-rs/ta/Makefile
index a06cd97..ad35909 100644
--- a/examples/big_int-rs/ta/Makefile
+++ b/examples/big_int-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign
diff --git a/examples/diffie_hellman-rs/Makefile b/examples/diffie_hellman-rs/Makefile
index 09679cd..db4e5bb 100644
--- a/examples/diffie_hellman-rs/Makefile
+++ b/examples/diffie_hellman-rs/Makefile
@@ -15,10 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
+	$(q)make -C host clean
+	$(q)make -C ta clean
diff --git a/examples/diffie_hellman-rs/host/Makefile b/examples/diffie_hellman-rs/host/Makefile
index cc0fffd..111bf10 100644
--- a/examples/diffie_hellman-rs/host/Makefile
+++ b/examples/diffie_hellman-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := diffie_hellman-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/diffie_hellman-rs/ta/Makefile b/examples/diffie_hellman-rs/ta/Makefile
index a06cd97..ad35909 100644
--- a/examples/diffie_hellman-rs/ta/Makefile
+++ b/examples/diffie_hellman-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign
diff --git a/examples/digest-rs/Makefile b/examples/digest-rs/Makefile
index 09679cd..db4e5bb 100644
--- a/examples/digest-rs/Makefile
+++ b/examples/digest-rs/Makefile
@@ -15,10 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
+	$(q)make -C host clean
+	$(q)make -C ta clean
diff --git a/examples/digest-rs/host/Makefile b/examples/digest-rs/host/Makefile
index ae76fda..78fb58d 100644
--- a/examples/digest-rs/host/Makefile
+++ b/examples/digest-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := digest-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/digest-rs/ta/Makefile b/examples/digest-rs/ta/Makefile
index a06cd97..ad35909 100644
--- a/examples/digest-rs/ta/Makefile
+++ b/examples/digest-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign
diff --git a/examples/hello_world-rs/Makefile b/examples/hello_world-rs/Makefile
index 09679cd..db4e5bb 100644
--- a/examples/hello_world-rs/Makefile
+++ b/examples/hello_world-rs/Makefile
@@ -15,10 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
+	$(q)make -C host clean
+	$(q)make -C ta clean
diff --git a/examples/hello_world-rs/host/Makefile b/examples/hello_world-rs/host/Makefile
index f93bdab..ea63eeb 100644
--- a/examples/hello_world-rs/host/Makefile
+++ b/examples/hello_world-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := hello_world-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/hello_world-rs/ta/Makefile b/examples/hello_world-rs/ta/Makefile
index a06cd97..ad35909 100644
--- a/examples/hello_world-rs/ta/Makefile
+++ b/examples/hello_world-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign
diff --git a/examples/hotp-rs/Makefile b/examples/hotp-rs/Makefile
index 09679cd..db4e5bb 100644
--- a/examples/hotp-rs/Makefile
+++ b/examples/hotp-rs/Makefile
@@ -15,10 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
+	$(q)make -C host clean
+	$(q)make -C ta clean
diff --git a/examples/hotp-rs/host/Makefile b/examples/hotp-rs/host/Makefile
index 6ebed56..a537efb 100644
--- a/examples/hotp-rs/host/Makefile
+++ b/examples/hotp-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := hotp-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/hotp-rs/ta/Makefile b/examples/hotp-rs/ta/Makefile
index a06cd97..ad35909 100644
--- a/examples/hotp-rs/ta/Makefile
+++ b/examples/hotp-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign
diff --git a/examples/random-rs/Makefile b/examples/random-rs/Makefile
index 09679cd..db4e5bb 100644
--- a/examples/random-rs/Makefile
+++ b/examples/random-rs/Makefile
@@ -15,10 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
+	$(q)make -C host clean
+	$(q)make -C ta clean
diff --git a/examples/random-rs/host/Makefile b/examples/random-rs/host/Makefile
index 98f6b5f..593b5a6 100644
--- a/examples/random-rs/host/Makefile
+++ b/examples/random-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := random-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/random-rs/ta/Makefile b/examples/random-rs/ta/Makefile
index a06cd97..ad35909 100644
--- a/examples/random-rs/ta/Makefile
+++ b/examples/random-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign
diff --git a/examples/secure_storage-rs/Makefile b/examples/secure_storage-rs/Makefile
index 09679cd..db4e5bb 100644
--- a/examples/secure_storage-rs/Makefile
+++ b/examples/secure_storage-rs/Makefile
@@ -15,10 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
+	$(q)make -C host clean
+	$(q)make -C ta clean
diff --git a/examples/secure_storage-rs/host/Makefile b/examples/secure_storage-rs/host/Makefile
index 95d1664..cd7fdd7 100644
--- a/examples/secure_storage-rs/host/Makefile
+++ b/examples/secure_storage-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := secure_storage-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/secure_storage-rs/ta/Makefile b/examples/secure_storage-rs/ta/Makefile
index a06cd97..ad35909 100644
--- a/examples/secure_storage-rs/ta/Makefile
+++ b/examples/secure_storage-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign
diff --git a/examples/signature_verification-rs/Makefile b/examples/signature_verification-rs/Makefile
index 09679cd..db4e5bb 100644
--- a/examples/signature_verification-rs/Makefile
+++ b/examples/signature_verification-rs/Makefile
@@ -15,10 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
+	$(q)make -C host clean
+	$(q)make -C ta clean
diff --git a/examples/signature_verification-rs/host/Makefile b/examples/signature_verification-rs/host/Makefile
index c87d3d2..bf7c728 100644
--- a/examples/signature_verification-rs/host/Makefile
+++ b/examples/signature_verification-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := signature_verification-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/signature_verification-rs/ta/Makefile b/examples/signature_verification-rs/ta/Makefile
index a06cd97..ad35909 100644
--- a/examples/signature_verification-rs/ta/Makefile
+++ b/examples/signature_verification-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign
diff --git a/examples/supp_plugin-rs/Makefile b/examples/supp_plugin-rs/Makefile
index b0b5308..7ba788c 100644
--- a/examples/supp_plugin-rs/Makefile
+++ b/examples/supp_plugin-rs/Makefile
@@ -15,12 +15,25 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
-	@make -s -C plugin
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C plugin TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
-	@make -s -C plugin clean
+	$(q)make -C host clean
+	$(q)make -C plugin clean
+	$(q)make -C ta clean
diff --git a/examples/supp_plugin-rs/host/Makefile b/examples/supp_plugin-rs/host/Makefile
index 3986c93..79cc01a 100644
--- a/examples/supp_plugin-rs/host/Makefile
+++ b/examples/supp_plugin-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := supp_plugin-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/supp_plugin-rs/plugin/Makefile b/examples/supp_plugin-rs/plugin/Makefile
index 6f33775..c4d5b96 100644
--- a/examples/supp_plugin-rs/plugin/Makefile
+++ b/examples/supp_plugin-rs/plugin/Makefile
@@ -16,18 +16,12 @@
 # under the License.
 
 NAME := syslog_plugin
-ARCH ?= aarch64
 PLUGIN_UUID := `cat ../plugin_uuid.txt`
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/supp_plugin-rs/ta/Makefile b/examples/supp_plugin-rs/ta/Makefile
index f185c5a..b8226d6 100644
--- a/examples/supp_plugin-rs/ta/Makefile
+++ b/examples/supp_plugin-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../ta_uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign
diff --git a/examples/time-rs/Makefile b/examples/time-rs/Makefile
index 09679cd..db4e5bb 100644
--- a/examples/time-rs/Makefile
+++ b/examples/time-rs/Makefile
@@ -15,10 +15,22 @@
 # specific language governing permissions and limitations
 # under the License.
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
+
+# If _HOST or _TA specific compiler/target are not specified, then use common
+# compiler/target for both
+CROSS_COMPILE_HOST ?= $(CROSS_COMPILE)
+CROSS_COMPILE_TA ?= $(CROSS_COMPILE)
+TARGET_HOST ?= $(TARGET)
+TARGET_TA ?= $(TARGET)
+
 all:
-	@make -s -C host
-	@make -s -C ta
+	$(q)make -C host TARGET=$(TARGET_HOST) \
+		CROSS_COMPILE=$(CROSS_COMPILE_HOST)
+	$(q)make -C ta TARGET=$(TARGET_TA) \
+		CROSS_COMPILE=$(CROSS_COMPILE_TA)
 
 clean:
-	@make -s -C host clean
-	@make -s -C ta clean
+	$(q)make -C host clean
+	$(q)make -C ta clean
diff --git a/examples/time-rs/host/Makefile b/examples/time-rs/host/Makefile
index 98c26b6..3d9597a 100644
--- a/examples/time-rs/host/Makefile
+++ b/examples/time-rs/host/Makefile
@@ -16,17 +16,11 @@
 # under the License.
 
 NAME := time-rs
-ARCH ?= aarch64
 
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\"
-endif
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
 
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
diff --git a/examples/time-rs/ta/Makefile b/examples/time-rs/ta/Makefile
index a06cd97..ad35909 100644
--- a/examples/time-rs/ta/Makefile
+++ b/examples/time-rs/ta/Makefile
@@ -17,20 +17,13 @@
 
 UUID ?= $(shell cat "../uuid.txt")
 
-ARCH ?= aarch64
-
+TARGET ?= aarch64-unknown-linux-gnu
+CROSS_COMPILE ?= aarch64-linux-gnu-
 OBJCOPY := $(CROSS_COMPILE)objcopy
+LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\"
+
 TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
 SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
-
-ifeq ($(ARCH), arm)
-	TARGET := arm-unknown-linux-gnueabihf
-	LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\"
-else
-	TARGET := aarch64-unknown-linux-gnu
-	LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\"
-endif
-
 OUT_DIR := $(CURDIR)/target/$(TARGET)/release
 
 all: ta strip sign


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org