Don't make configuration-independent files depend on config.h
Don't regenerate configuration-independent files when config.h or
crypto_config.h changes. These files only depend on the set of symbols
present in the headers and not on which symbols are enabled. To avoid
rebuilding the generated files whenever the configuration changes,
don't declare the configuration as a dependency.
In the rare event that a maintainer makes an edit to *config.h that
affects the generated files, they'll have to remove the generated files.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/library/Makefile b/library/Makefile
index aff814d..90a477d 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -279,14 +279,19 @@
error.c: ../scripts/generate_errors.pl
error.c: ../scripts/data_files/error.fmt
-error.c: $(wildcard ../include/mbedtls/*.h)
+error.c: $(filter-out %config%,$(wildcard ../include/mbedtls/*.h))
error.c:
echo " Gen $@"
$(PERL) ../scripts/generate_errors.pl
version_features.c: ../scripts/generate_features.pl
version_features.c: ../scripts/data_files/version_features.fmt
-version_features.c: ../include/mbedtls/config.h
+## The generated file only depends on the options that are present in config.h,
+## not on which options are set. To avoid regenerating this file all the time
+## when switching between configurations, don't declare config.h as a
+## dependency. Remove this file from your working tree if you've just added or
+## removed an option in config.h.
+#version_features.c: ../include/mbedtls/config.h
version_features.c:
echo " Gen $@"
$(PERL) ../scripts/generate_features.pl
diff --git a/programs/Makefile b/programs/Makefile
index b2ba08e..5795cd6 100644
--- a/programs/Makefile
+++ b/programs/Makefile
@@ -146,7 +146,12 @@
$(PYTHON) ../scripts/generate_psa_constants.py
test/query_config.c: ../scripts/generate_query_config.pl
-test/query_config.c: ../include/mbedtls/config.h
+## The generated file only depends on the options that are present in config.h,
+## not on which options are set. To avoid regenerating this file all the time
+## when switching between configurations, don't declare config.h as a
+## dependency. Remove this file from your working tree if you've just added or
+## removed an option in config.h.
+#test/query_config.c: ../include/mbedtls/config.h
test/query_config.c: ../scripts/data_files/query_config.fmt
test/query_config.c:
echo " Gen $@"
diff --git a/tests/Makefile b/tests/Makefile
index ef57169..c1620d6 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -64,7 +64,12 @@
generated_files: $(GENERATED_FILES)
$(GENERATED_DATA_FILES): scripts/generate_psa_tests.py
-$(GENERATED_DATA_FILES): ../include/psa/crypto_config.h
+## The generated file only depends on the options that are present in
+## crypto_config.h, not on which options are set. To avoid regenerating this
+## file all the time when switching between configurations, don't declare
+## crypto_config.h as a dependency. Remove this file from your working tree
+## if you've just added or removed an option in crypto_config.h.
+#$(GENERATED_DATA_FILES): ../include/psa/crypto_config.h
$(GENERATED_DATA_FILES): ../include/psa/crypto_values.h
$(GENERATED_DATA_FILES): ../include/psa/crypto_extra.h
$(GENERATED_DATA_FILES): suites/test_suite_psa_crypto_metadata.data