From 1411c7c0d6ce956da378384ac634493e9c09972c Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 22 Apr 2021 14:50:16 +0200 Subject: [PATCH] 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 --- library/Makefile | 9 +++++++-- programs/Makefile | 7 ++++++- tests/Makefile | 7 ++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/library/Makefile b/library/Makefile index aff814d00d..90a477d431 100644 --- a/library/Makefile +++ b/library/Makefile @@ -279,14 +279,19 @@ generated_files: $(GENERATED_FILES) 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 b2ba08e135..5795cd6dac 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -146,7 +146,12 @@ psa/psa_constant_names_generated.c: $(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 ef571698c3..c1620d6e72 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -64,7 +64,12 @@ GENERATED_FILES := $(GENERATED_DATA_FILES) 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