Hello,
I have a Makefile-dependency question regarding Fortran: In Fortran one
can have so-called modules. If one compiles such a file, a .mod file is
generated which contains the public interface and a .o file which
contains the binary.
If one changes the source file (.f90) without modifying the interface,
the file should be compiled - and the relinking happening, but no other
files should be compiled.
If the source file is changed such that the the interface (.mod file)
changes, all source files depending on the .mod file should be recompiled.
The question is how one can squeeze this into a Makefile; what I can
tune is whether the .mod file gets "touched" (file modification date
changed) or not after modification.
The following is a default dependency file, which in principle nicely
works, but I either get a complete recompilation as soon as the date of
the .mod file changes.
myprogram: myprogram.o mymodule.o
$(FC) -o myprogram myprogram.o mymodule.o
mymodule.o mymodule.mod: mymodule.f90
$(FC) -c mymodule.f90
myprogram.o: myprogram.f90 mymodule.mod
$(FC) -c myprogram.f90
Assuming the .mod date does not change, the Makefile above will cause a
complete recompilation of "mymodule" every time as "mymodule.mod" is
always older than "mymodule.f90". I could try the following, but it does
not work if one either has the wrong order in the "myprogram:"
dependency list or when one calls "make myprogram.o" (assuming that
mymodule.f90 has changed such that the interface is different - and that
myprogram.f90 needs this change).
Any idea? Is is better for the compiler to change the .mod file
modification date or not?
Background: gfortran currently does not, but it causes obviously some
problems; cf. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47495
Tobias
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make