summaryrefslogtreecommitdiff
path: root/common/build.mk
diff options
context:
space:
mode:
Diffstat (limited to 'common/build.mk')
-rw-r--r--common/build.mk13
1 files changed, 10 insertions, 3 deletions
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)