Skip to content

Commit

Permalink
examples: unify Makefile
Browse files Browse the repository at this point in the history
Host and TA read `TARGET` and `CROSS_COMPILE` from the top level
Makefile of the example. That meets the env need of building inner
C libraries such as ring for TA.
Run `make -C examples/xxxx ta` will build TA independently.
  • Loading branch information
DemesneGH committed Oct 18, 2024
1 parent 4a9b369 commit d57ad65
Show file tree
Hide file tree
Showing 60 changed files with 441 additions and 326 deletions.
16 changes: 11 additions & 5 deletions examples/acipher-rs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ CROSS_COMPILE_TA ?= aarch64-linux-gnu-
TARGET_HOST ?= aarch64-unknown-linux-gnu
TARGET_TA ?= aarch64-unknown-linux-gnu

all:
$(q)make -C host TARGET_HOST=$(TARGET_HOST) \
CROSS_COMPILE_HOST=$(CROSS_COMPILE_HOST)
$(q)make -C ta TARGET_TA=$(TARGET_TA) \
CROSS_COMPILE_TA=$(CROSS_COMPILE_TA)
.PHONY: host ta all clean

all: host ta

host:
$(q)make -C host TARGET=$(TARGET_HOST) \
CROSS_COMPILE=$(CROSS_COMPILE_HOST)

ta:
$(q)make -C ta TARGET=$(TARGET_TA) \
CROSS_COMPILE=$(CROSS_COMPILE_TA)

clean:
$(q)make -C host clean
Expand Down
12 changes: 6 additions & 6 deletions examples/acipher-rs/host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@

NAME := acipher-rs

TARGET_HOST ?= aarch64-unknown-linux-gnu
CROSS_COMPILE_HOST ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE_HOST)objcopy
LINKER_CFG := target.$(TARGET_HOST).linker=\"$(CROSS_COMPILE_HOST)gcc\"
TARGET ?= aarch64-unknown-linux-gnu
CROSS_COMPILE ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE)objcopy
LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"

OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release
OUT_DIR := $(CURDIR)/target/$(TARGET)/release


all: host strip

host:
@cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG)
@cargo build --target $(TARGET) --release --config $(LINKER_CFG)

strip: host
@$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME)
Expand Down
12 changes: 6 additions & 6 deletions examples/acipher-rs/ta/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@

UUID ?= $(shell cat "../uuid.txt")

TARGET_TA ?= aarch64-unknown-linux-gnu
CROSS_COMPILE_TA ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE_TA)objcopy
LINKER_CFG := target.$(TARGET_TA).linker=\"$(CROSS_COMPILE_TA)ld.bfd\"
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
OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release
OUT_DIR := $(CURDIR)/target/$(TARGET)/release

BUILDER = $(if $(STD),xargo,cargo)

all: ta strip sign

ta:
@$(BUILDER) build --target $(TARGET_TA) --release --config $(LINKER_CFG)
@$(BUILDER) build --target $(TARGET) --release --config $(LINKER_CFG)

strip: ta
@$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
Expand Down
16 changes: 11 additions & 5 deletions examples/aes-rs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ CROSS_COMPILE_TA ?= aarch64-linux-gnu-
TARGET_HOST ?= aarch64-unknown-linux-gnu
TARGET_TA ?= aarch64-unknown-linux-gnu

all:
$(q)make -C host TARGET_HOST=$(TARGET_HOST) \
CROSS_COMPILE_HOST=$(CROSS_COMPILE_HOST)
$(q)make -C ta TARGET_TA=$(TARGET_TA) \
CROSS_COMPILE_TA=$(CROSS_COMPILE_TA)
.PHONY: host ta all clean

all: host ta

host:
$(q)make -C host TARGET=$(TARGET_HOST) \
CROSS_COMPILE=$(CROSS_COMPILE_HOST)

ta:
$(q)make -C ta TARGET=$(TARGET_TA) \
CROSS_COMPILE=$(CROSS_COMPILE_TA)

clean:
$(q)make -C host clean
Expand Down
10 changes: 5 additions & 5 deletions examples/aes-rs/host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

NAME := aes-rs

TARGET_HOST ?= aarch64-unknown-linux-gnu
CROSS_COMPILE_HOST ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE_HOST)objcopy
LINKER_CFG := target.$(TARGET_HOST).linker=\"$(CROSS_COMPILE_HOST)gcc\"
TARGET ?= aarch64-unknown-linux-gnu
CROSS_COMPILE ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE)objcopy
LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"

OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release
OUT_DIR := $(CURDIR)/target/$(TARGET)/release


all: host strip
Expand Down
13 changes: 6 additions & 7 deletions examples/aes-rs/ta/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@

UUID ?= $(shell cat "../uuid.txt")

CROSS_COMPILE_TA ?= aarch64-linux-gnu-
TARGET_TA ?= aarch64-unknown-linux-gnu
CROSS_COMPILE_TA ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE_TA)objcopy
LINKER_CFG := target.$(TARGET_TA).linker=\"$(CROSS_COMPILE_TA)ld.bfd\"
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
OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release
OUT_DIR := $(CURDIR)/target/$(TARGET)/release

BUILDER = $(if $(STD),xargo,cargo)

all: ta strip sign

ta:
@$(BUILDER) build --target $(TARGET_TA) --release --config $(LINKER_CFG)
@$(BUILDER) build --target $(TARGET) --release --config $(LINKER_CFG)

strip: ta
@$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
Expand Down
16 changes: 11 additions & 5 deletions examples/authentication-rs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ CROSS_COMPILE_TA ?= aarch64-linux-gnu-
TARGET_HOST ?= aarch64-unknown-linux-gnu
TARGET_TA ?= aarch64-unknown-linux-gnu

all:
$(q)make -C host TARGET_HOST=$(TARGET_HOST) \
CROSS_COMPILE_HOST=$(CROSS_COMPILE_HOST)
$(q)make -C ta TARGET_TA=$(TARGET_TA) \
CROSS_COMPILE_TA=$(CROSS_COMPILE_TA)
.PHONY: host ta all clean

all: host ta

host:
$(q)make -C host TARGET=$(TARGET_HOST) \
CROSS_COMPILE=$(CROSS_COMPILE_HOST)

ta:
$(q)make -C ta TARGET=$(TARGET_TA) \
CROSS_COMPILE=$(CROSS_COMPILE_TA)

clean:
$(q)make -C host clean
Expand Down
10 changes: 5 additions & 5 deletions examples/authentication-rs/host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

NAME := authentication-rs

TARGET_HOST ?= aarch64-unknown-linux-gnu
CROSS_COMPILE_HOST ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE_HOST)objcopy
LINKER_CFG := target.$(TARGET_HOST).linker=\"$(CROSS_COMPILE_HOST)gcc\"
TARGET ?= aarch64-unknown-linux-gnu
CROSS_COMPILE ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE)objcopy
LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"

OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release
OUT_DIR := $(CURDIR)/target/$(TARGET)/release


all: host strip
Expand Down
13 changes: 6 additions & 7 deletions examples/authentication-rs/ta/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@

UUID ?= $(shell cat "../uuid.txt")

CROSS_COMPILE_TA ?= aarch64-linux-gnu-
TARGET_TA ?= aarch64-unknown-linux-gnu
CROSS_COMPILE_TA ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE_TA)objcopy
LINKER_CFG := target.$(TARGET_TA).linker=\"$(CROSS_COMPILE_TA)ld.bfd\"
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
OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release
OUT_DIR := $(CURDIR)/target/$(TARGET)/release

BUILDER = $(if $(STD),xargo,cargo)

all: ta strip sign

ta:
@$(BUILDER) build --target $(TARGET_TA) --release --config $(LINKER_CFG)
@$(BUILDER) build --target $(TARGET) --release --config $(LINKER_CFG)

strip: ta
@$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
Expand Down
16 changes: 11 additions & 5 deletions examples/big_int-rs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ CROSS_COMPILE_TA ?= aarch64-linux-gnu-
TARGET_HOST ?= aarch64-unknown-linux-gnu
TARGET_TA ?= aarch64-unknown-linux-gnu

all:
$(q)make -C host TARGET_HOST=$(TARGET_HOST) \
CROSS_COMPILE_HOST=$(CROSS_COMPILE_HOST)
$(q)make -C ta TARGET_TA=$(TARGET_TA) \
CROSS_COMPILE_TA=$(CROSS_COMPILE_TA)
.PHONY: host ta all clean

all: host ta

host:
$(q)make -C host TARGET=$(TARGET_HOST) \
CROSS_COMPILE=$(CROSS_COMPILE_HOST)

ta:
$(q)make -C ta TARGET=$(TARGET_TA) \
CROSS_COMPILE=$(CROSS_COMPILE_TA)

clean:
$(q)make -C host clean
Expand Down
10 changes: 5 additions & 5 deletions examples/big_int-rs/host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

NAME := big_int-rs

TARGET_HOST ?= aarch64-unknown-linux-gnu
CROSS_COMPILE_HOST ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE_HOST)objcopy
LINKER_CFG := target.$(TARGET_HOST).linker=\"$(CROSS_COMPILE_HOST)gcc\"
TARGET ?= aarch64-unknown-linux-gnu
CROSS_COMPILE ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE)objcopy
LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"

OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release
OUT_DIR := $(CURDIR)/target/$(TARGET)/release


all: host strip
Expand Down
13 changes: 6 additions & 7 deletions examples/big_int-rs/ta/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@

UUID ?= $(shell cat "../uuid.txt")

CROSS_COMPILE_TA ?= aarch64-linux-gnu-
TARGET_TA ?= aarch64-unknown-linux-gnu
CROSS_COMPILE_TA ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE_TA)objcopy
LINKER_CFG := target.$(TARGET_TA).linker=\"$(CROSS_COMPILE_TA)ld.bfd\"
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
OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release
OUT_DIR := $(CURDIR)/target/$(TARGET)/release

BUILDER = $(if $(STD),xargo,cargo)

all: ta strip sign

ta:
@$(BUILDER) build --target $(TARGET_TA) --release --config $(LINKER_CFG)
@$(BUILDER) build --target $(TARGET) --release --config $(LINKER_CFG)

strip: ta
@$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
Expand Down
16 changes: 11 additions & 5 deletions examples/diffie_hellman-rs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ CROSS_COMPILE_TA ?= aarch64-linux-gnu-
TARGET_HOST ?= aarch64-unknown-linux-gnu
TARGET_TA ?= aarch64-unknown-linux-gnu

all:
$(q)make -C host TARGET_HOST=$(TARGET_HOST) \
CROSS_COMPILE_HOST=$(CROSS_COMPILE_HOST)
$(q)make -C ta TARGET_TA=$(TARGET_TA) \
CROSS_COMPILE_TA=$(CROSS_COMPILE_TA)
.PHONY: host ta all clean

all: host ta

host:
$(q)make -C host TARGET=$(TARGET_HOST) \
CROSS_COMPILE=$(CROSS_COMPILE_HOST)

ta:
$(q)make -C ta TARGET=$(TARGET_TA) \
CROSS_COMPILE=$(CROSS_COMPILE_TA)

clean:
$(q)make -C host clean
Expand Down
10 changes: 5 additions & 5 deletions examples/diffie_hellman-rs/host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

NAME := diffie_hellman-rs

TARGET_HOST ?= aarch64-unknown-linux-gnu
CROSS_COMPILE_HOST ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE_HOST)objcopy
LINKER_CFG := target.$(TARGET_HOST).linker=\"$(CROSS_COMPILE_HOST)gcc\"
TARGET ?= aarch64-unknown-linux-gnu
CROSS_COMPILE ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE)objcopy
LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"

OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release
OUT_DIR := $(CURDIR)/target/$(TARGET)/release


all: host strip
Expand Down
12 changes: 6 additions & 6 deletions examples/diffie_hellman-rs/ta/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@

UUID ?= $(shell cat "../uuid.txt")

TARGET_TA ?= aarch64-unknown-linux-gnu
CROSS_COMPILE_TA ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE_TA)objcopy
LINKER_CFG := target.$(TARGET_TA).linker=\"$(CROSS_COMPILE_TA)ld.bfd\"
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
OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release
OUT_DIR := $(CURDIR)/target/$(TARGET)/release

BUILDER = $(if $(STD),xargo,cargo)

all: ta strip sign

ta:
@$(BUILDER) build --target $(TARGET_TA) --release --config $(LINKER_CFG)
@$(BUILDER) build --target $(TARGET) --release --config $(LINKER_CFG)

strip: ta
@$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta
Expand Down
16 changes: 11 additions & 5 deletions examples/digest-rs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ CROSS_COMPILE_TA ?= aarch64-linux-gnu-
TARGET_HOST ?= aarch64-unknown-linux-gnu
TARGET_TA ?= aarch64-unknown-linux-gnu

all:
$(q)make -C host TARGET_HOST=$(TARGET_HOST) \
CROSS_COMPILE_HOST=$(CROSS_COMPILE_HOST)
$(q)make -C ta TARGET_TA=$(TARGET_TA) \
CROSS_COMPILE_TA=$(CROSS_COMPILE_TA)
.PHONY: host ta all clean

all: host ta

host:
$(q)make -C host TARGET=$(TARGET_HOST) \
CROSS_COMPILE=$(CROSS_COMPILE_HOST)

ta:
$(q)make -C ta TARGET=$(TARGET_TA) \
CROSS_COMPILE=$(CROSS_COMPILE_TA)

clean:
$(q)make -C host clean
Expand Down
10 changes: 5 additions & 5 deletions examples/digest-rs/host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

NAME := digest-rs

TARGET_HOST ?= aarch64-unknown-linux-gnu
CROSS_COMPILE_HOST ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE_HOST)objcopy
LINKER_CFG := target.$(TARGET_HOST).linker=\"$(CROSS_COMPILE_HOST)gcc\"
TARGET ?= aarch64-unknown-linux-gnu
CROSS_COMPILE ?= aarch64-linux-gnu-
OBJCOPY := $(CROSS_COMPILE)objcopy
LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"

OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release
OUT_DIR := $(CURDIR)/target/$(TARGET)/release


all: host strip
Expand Down
Loading

0 comments on commit d57ad65

Please sign in to comment.