#41: When an external library is rebuilt, its dependencies should also be rebuilt
Reporter:Erik Schnetter
Status:open
Milestone:
Version:
Type:bug
Priority:minor
Component:Cactus

Comment (by Roland Haas):

Not so easy after all. It seems as if gfortran ends up in a chicken and egg situation where in order to generate the dependency file for a F90 file which uses modules, those very modules need to already exist: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49149 . The gfortran devs do not seem to consider this a bug. The workaround mentioned in that ticket is some clever use of makefile targets that has make try and generate the dependency files again and again until it eventually succeeds. This makefiles (which generates its own sources) demonstrates the method:

‌

SOURCES := foo.f90 bar.f90 baz.f90

.PHONY: all clean

all: $(patsubst %.f90,%.o,$(SOURCES))

clean:
    rm -f *.mod *.o *.d *.f90

%.d: %.f90
    gfortran -cpp -M -MF $@ $<

%.o: %.f90 %.d
    gfortran -c $<

# include any gnerated dependency files, don't worry about ones you did not
# find yet
ifneq ($(MAKECMDGOALS),clean)
-include $(patsubst %.f90,%.d,$(SOURCES))
endif

# demo files:
define FOO_F90
subroutine foosub
  use baz

--
Ticket URL: https://bitbucket.org/einsteintoolkit/tickets/issues/41/when-an-external-library-is-rebuilt-its