From 8a219c4979c71d9b4e462bc023c76990f6e3b1de Mon Sep 17 00:00:00 2001 From: Michele Guerini Rocco Date: Thu, 17 Apr 2025 08:32:23 +0200 Subject: [PATCH] Makefile: rebuild on flags changes This invalidates all caches in case a flag like DEBUG=1 is specified on the make command line. --- .gitignore | 1 + Makefile | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index fe3e4d0..1b24f38 100755 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ build __pycache__ configure.mk +flags.mk result gcroots diff --git a/Makefile b/Makefile index 06aa5cc..740b237 100644 --- a/Makefile +++ b/Makefile @@ -253,6 +253,13 @@ graph.svg: Makefile # Rebuild everything if the makefile changed .EXTRA_PREREQS += Makefile +# Rebuild everything if a flag changed +.EXTRA_PREREQS += flags.mk + +# Store current make flags +FLAGS=$(filter-out -%,$(MAKEFLAGS)) +$(shell test '$(FLAGS)' != "`cat flags.mk 2>&1`" && echo '$(FLAGS)' > flags.mk) + # Search for source code in vendor/ subdirectory vpath %.f90 $(SRCDIR):$(SRCDIR)/vendor @@ -275,7 +282,7 @@ $(OBJDIR)/%.d: %.f90 | $(OBJDIR) %.a : ; $(AR) $(ARFLAGS) $@ $? # Load the generated rules -include $(DEPS) +-include $(DEPS) # Compile a generic Fortran source $(OBJDIR)/%.o: %.f90 | $(OBJDIR) $(INCDIR) @@ -287,4 +294,4 @@ $(INCDIR)/%.inc: $(SRCDIR)/%.awk | $(INCDIR) # Create directories $(DIRS): - mkdir -p '$@' + @mkdir -p '$@'