diff options
-rw-r--r-- | board/cr50/build.mk | 29 | ||||
-rw-r--r-- | common/build.mk | 13 |
2 files changed, 32 insertions, 10 deletions
diff --git a/board/cr50/build.mk b/board/cr50/build.mk index 46871c7ec8..a06bcd3065 100644 --- a/board/cr50/build.mk +++ b/board/cr50/build.mk @@ -109,16 +109,31 @@ CFLAGS += -DEMBEDDED_MODE=1 # Configure cryptoc headers to handle unaligned accesses. CFLAGS += -DSUPPORT_UNALIGNED=1 -TPM2_OBJS = $(shell find $(out)/tpm2 -name '*.cp.o') +# Use absolute path as the destination to ensure that TPM2 makefile finds the +# place for output. +outdir := $(realpath $(out))/tpm2 +cmd_tpm2_base = $(MAKE) obj=$(outdir) EMBEDDED_MODE=1 \ + -C $(EXTLIB) --no-print-directory + +TPM2_OBJS := $(shell $(cmd_tpm2_base) list_copied_objs) + +TPM2_TARGET := $(outdir)/.copied_objs + # Add dependencies on that library $(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: LDFLAGS_EXTRA += $(TPM2_OBJS) -$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: copied_objs +$(out)/RW/ec.RW.elf $(out)/RW/ec.RW_B.elf: $(TPM2_TARGET) + +cmd_tpm2lib = $(cmd_tpm2_base) $(TPM2_TARGET) + +tpm2lib_check_clean = $(cmd_tpm2lib) -q && echo clean + +ifneq ($(shell $(tpm2lib_check_clean)),clean) +# Force the external build only if it is needed. +.PHONY: $(TPM2_TARGET) +endif -# Force the external build each time, so it can look for changed sources. -.PHONY: copied_objs -copied_objs: - $(MAKE) obj=$(realpath $(out))/tpm2 EMBEDDED_MODE=1 \ - -C $(EXTLIB) copied_objs +$(TPM2_TARGET): + $(call quiet,tpm2lib,TPM2 ) endif # BOARD_MK_INCLUDED_ONCE is nonempty diff --git a/common/build.mk b/common/build.mk index f0a55ccb61..ec592b8f9f 100644 --- a/common/build.mk +++ b/common/build.mk @@ -257,11 +257,18 @@ endif CPPFLAGS += -I$(CRYPTOCLIB)/include CRYPTOC_LDFLAGS := -L$(out)/cryptoc -lcryptoc -# Force the external build each time, so it can look for changed sources. +cmd_cryptolib = $(MAKE) obj=$(realpath $(out))/cryptoc SUPPORT_UNALIGNED=1 \ + CONFIG_UPTO_SHA512=$(CONFIG_UPTO_SHA512) -C $(CRYPTOCLIB) + +cryptolib_check_clean = $(cmd_cryptolib) -q && echo clean + +ifneq ($(shell $(cryptolib_check_clean)),clean) +# Force the external build only if it is needed. .PHONY: $(out)/cryptoc/libcryptoc.a +endif + $(out)/cryptoc/libcryptoc.a: - $(MAKE) obj=$(realpath $(out))/cryptoc SUPPORT_UNALIGNED=1 \ - CONFIG_UPTO_SHA512=$(CONFIG_UPTO_SHA512) -C $(CRYPTOCLIB) + $(call quiet,cryptolib,CRYPTOLIB) # Link RO and RW against cryptoc. $(out)/RO/ec.RO.elf $(out)/RO/ec.RO_B.elf: LDFLAGS_EXTRA += $(CRYPTOC_LDFLAGS) |