Makefile: rebuild on flags changes

This invalidates all caches in case a flag like DEBUG=1 is specified on
the make command line.
This commit is contained in:
Michele Guerini Rocco 2025-04-17 08:32:23 +02:00
parent 4372db2169
commit 8a219c4979
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450
2 changed files with 10 additions and 2 deletions

1
.gitignore vendored
View File

@ -2,5 +2,6 @@
build
__pycache__
configure.mk
flags.mk
result
gcroots

View File

@ -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 '$@'