aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorGilles Peskine <Gilles.Peskine@arm.com>2023-09-08 16:19:13 +0200
committerGilles Peskine <Gilles.Peskine@arm.com>2023-09-08 16:19:13 +0200
commit0b62b7a21f026581735f9bd5bf3c0384426c7c67 (patch)
tree42e5addc59034f8cc81840932d1cf8518ce2311f /Makefile
parent33fbd373bea54711ce935a376e5e594f85f9d020 (diff)
downloadmbedtls-0b62b7a21f026581735f9bd5bf3c0384426c7c67.zip
mbedtls-0b62b7a21f026581735f9bd5bf3c0384426c7c67.tar.gz
mbedtls-0b62b7a21f026581735f9bd5bf3c0384426c7c67.tar.bz2
Allow turning off re-generation of files with make
In make builds, when GEN_FILES is false (empty), don't try to re-generate configuration-independent source files, regardless of whether they seem out of date. This is useful, for example, if you have a source tree where `make generated_files` has already run and file timestamps reflect the time the files were copied or extracted, and you are now in an environment that lacks some of the necessary tools to re-generate the files. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile29
1 files changed, 25 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 1f36a06..b324b9a 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,27 @@ generated_files: programs/generated_files
generated_files: tests/generated_files
generated_files: visualc_files
+# Set GEN_FILES to the empty string to disable dependencies on generated
+# source files. Then `make generated_files` will only build files that
+# are missing, it will not rebuilt files that are present but out of date.
+# This is useful, for example, if you have a source tree where
+# `make generated_files` has already run and file timestamps reflect the
+# time the files were copied or extracted, and you are now in an environment
+# that lacks some of the necessary tools to re-generate the files.
+# If $(GEN_FILES) is non-empty, the generated source files' dependencies
+# are treated ordinarily, based on file timestamps.
+GEN_FILES ?= yes
+
+# In dependencies where the target is a configuration-independent generated
+# file, use `TARGET: $(gen_file_dep) DEPENDENCY1 DEPENDENCY2 ...`
+# rather than directly `TARGET: DEPENDENCY1 DEPENDENCY2 ...`. This
+# enables the re-generation to be turned off when GEN_FILES is disabled.
+ifdef GEN_FILES
+gen_file_dep =
+else
+gen_file_dep = |
+endif
+
.PHONY: visualc_files
VISUALC_FILES = visualc/VS2013/mbedTLS.sln visualc/VS2013/mbedTLS.vcxproj
# TODO: $(app).vcxproj for each $(app) in programs/
@@ -45,10 +66,10 @@ visualc_files: $(VISUALC_FILES)
# present before it runs. It doesn't matter if the files aren't up-to-date,
# they just need to be present.
$(VISUALC_FILES): | library/generated_files
-$(VISUALC_FILES): scripts/generate_visualc_files.pl
-$(VISUALC_FILES): scripts/data_files/vs2013-app-template.vcxproj
-$(VISUALC_FILES): scripts/data_files/vs2013-main-template.vcxproj
-$(VISUALC_FILES): scripts/data_files/vs2013-sln-template.sln
+$(VISUALC_FILES): $(gen_file_dep) scripts/generate_visualc_files.pl
+$(VISUALC_FILES): $(gen_file_dep) scripts/data_files/vs2013-app-template.vcxproj
+$(VISUALC_FILES): $(gen_file_dep) scripts/data_files/vs2013-main-template.vcxproj
+$(VISUALC_FILES): $(gen_file_dep) scripts/data_files/vs2013-sln-template.sln
# TODO: also the list of .c and .h source files, but not their content
$(VISUALC_FILES):
echo " Gen $@ ..."