In library, with make, only require the framework for generated files
This way, `make lib` will work in the absence of the framework, as long as
generated files are present.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/Makefile b/Makefile
index 2e41aba..47a3895 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,19 @@
PREFIX=mbedtls_
PERL ?= perl
-include framework/exported.make
+ifneq (,$(filter-out lib library/%,$(or $(MAKECMDGOALS),all)))
+ ifeq (,$(wildcard framework/exported.make))
+ # Use the define keyword to get a multi-line message.
+ # GNU make appends ". Stop.", so tweak the ending of our message accordingly.
+ define error_message
+$(MBEDTLS_PATH)/framework/exported.make not found.
+Run `git submodule update --init` to fetch the submodule contents.
+This is a fatal error
+ endef
+ $(error $(error_message))
+ endif
+ include framework/exported.make
+endif
.SILENT:
diff --git a/library/Makefile b/library/Makefile
index 2f42124..77cfe07 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -2,15 +2,25 @@
MBEDTLS_PATH := ..
endif
-ifeq (,$(wildcard $(MBEDTLS_PATH)/framework/exported.make))
-define error_message
+GENERATED_FILES := \
+ error.c version_features.c \
+ ssl_debug_helpers_generated.c \
+ psa_crypto_driver_wrappers.h \
+ psa_crypto_driver_wrappers_no_static.c
+
+ifneq ($(GENERATED_FILES),$(wildcard $(GENERATED_FILES)))
+ ifeq (,$(wildcard $(MBEDTLS_PATH)/framework/exported.make))
+ # Use the define keyword to get a multi-line message.
+ # GNU make appends ". Stop.", so tweak the ending of our message accordingly.
+ define error_message
$(MBEDTLS_PATH)/framework/exported.make not found.
Run `git submodule update --init` to fetch the submodule contents.
This is a fatal error
-endef
-$(error $(error_message))
+ endef
+ $(error $(error_message))
+ endif
+ include $(MBEDTLS_PATH)/framework/exported.make
endif
-include $(MBEDTLS_PATH)/framework/exported.make
# Also see "include/mbedtls/mbedtls_config.h"
@@ -327,11 +337,6 @@
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
.PHONY: generated_files
-GENERATED_FILES = \
- error.c version_features.c \
- ssl_debug_helpers_generated.c \
- psa_crypto_driver_wrappers.h \
- psa_crypto_driver_wrappers_no_static.c
generated_files: $(GENERATED_FILES)
# See root Makefile