From 624fbe3ec1045a5a856b733bd78cc864442b0382 Mon Sep 17 00:00:00 2001 From: Michele Guerini Rocco Date: Fri, 17 May 2024 11:35:21 +0200 Subject: [PATCH] Makefile: fix .d generation for vendored libraries --- Makefile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 5c5763e..ba5d438 100644 --- a/Makefile +++ b/Makefile @@ -208,11 +208,14 @@ graph.svg: Makefile # Rebuild everything if the makefile changed .EXTRA_PREREQS += Makefile +# Search for source code in vendor/ subdirectory +vpath %.f90 $(SRCDIR):$(SRCDIR)/vendor + # Automatic generation of the Fortran prerequisites # Note 1: this is needed because gfortran -M flag doesn't properly work; # Note 2: this assumes matching module/file names and no circular # dependencies (ie. the dependency graph is a DAG); -$(OBJDIR)/%.d: $(SRCDIR)/%.f90 | $(OBJDIR) +$(OBJDIR)/%.d: %.f90 | $(OBJDIR) @printf '$(@:d=o): $< \\\n' > '$@' @grep -vE '^[[:blank:]]*use.*(intrinsic|iso_)' '$<' | \ sed -nE 's@^[[:blank:]]*use[[:blank:]]+'\ @@ -221,14 +224,10 @@ $(OBJDIR)/%.d: $(SRCDIR)/%.f90 | $(OBJDIR) @sed -nE 's@^#include "(.+)"@$(INCDIR)/\1 \\@p' '$<' >> '$@' # Load the generated rules --include $(DEPS) +include $(DEPS) # Compile a generic Fortran source -$(OBJDIR)/%.o: $(SRCDIR)/%.f90 | $(OBJDIR) $(INCDIR) - $(FC) -cpp $(CPPFLAGS) $(FFLAGS) -c '$<' -o '$@' - -# Compile vendored libraries -$(OBJDIR)/%.o: $(SRCDIR)/vendor/%.f90 | $(OBJDIR) $(INCDIR) +$(OBJDIR)/%.o: %.f90 | $(OBJDIR) $(INCDIR) $(FC) -cpp $(CPPFLAGS) $(FFLAGS) -c '$<' -o '$@' # Generate Fortran code from awk script