Makefile targets for automatically generated files
Run `make generated_files` to generate the automatically generated
C source files and build scripts.
Run `make neat` to remove all automatically generated files, even C
source files and build scripts.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/programs/Makefile b/programs/Makefile
index 0f1356e..b2ba08e 100644
--- a/programs/Makefile
+++ b/programs/Makefile
@@ -43,10 +43,12 @@
ifdef SHARED
SHARED_SUFFIX=.$(DLEXT)
endif
+PYTHON ?= python
else
DLEXT ?= so
EXEXT=
SHARED_SUFFIX=
+PYTHON ?= $(shell if type python3 >/dev/null 2>/dev/null; then echo python3; else echo python; fi)
endif
APPS = \
@@ -131,6 +133,25 @@
${MBEDTLS_TEST_OBJS}:
$(MAKE) -C ../tests mbedtls_test
+.PHONY: generated_files
+GENERATED_FILES = psa/psa_constant_names_generated.c test/query_config.c
+generated_files: $(GENERATED_FILES)
+
+psa/psa_constant_names_generated.c: ../scripts/generate_psa_constants.py
+psa/psa_constant_names_generated.c: ../include/psa/crypto_values.h
+psa/psa_constant_names_generated.c: ../include/psa/crypto_extra.h
+psa/psa_constant_names_generated.c: ../tests/suites/test_suite_psa_crypto_metadata.data
+psa/psa_constant_names_generated.c:
+ echo " Gen $@"
+ $(PYTHON) ../scripts/generate_psa_constants.py
+
+test/query_config.c: ../scripts/generate_query_config.pl
+test/query_config.c: ../include/mbedtls/config.h
+test/query_config.c: ../scripts/data_files/query_config.fmt
+test/query_config.c:
+ echo " Gen $@"
+ $(PERL) ../scripts/generate_query_config.pl
+
aes/crypt_and_hash$(EXEXT): aes/crypt_and_hash.c $(DEP)
echo " CC aes/crypt_and_hash.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) aes/crypt_and_hash.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
@@ -365,5 +386,12 @@
endif
$(MAKE) -C fuzz clean
+neat: clean
+ifndef WINDOWS
+ rm -f $(GENERATED_FILES)
+else
+ for %f in ($(subst /,\,$(GENERATED_FILES))) if exist %f del /Q /F %f
+endif
+
list:
echo $(APPS)