This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Makefile with .mod files


I'm having some problems with a Makefile for a Fortran program, and
I've tracked it down to the fact that .mod files don't have their
timestamp updated when compiling if they don't change.

This is a change from 4.2, IIRC, and it was done because users complained that .mod files had their timestamps updated while not changing, which triggered massive useless recompilations because of Makefile dependencies ;-)


all: a.o b.o

a.mod a.o: a.f90 b.mod
        gfortran -c $<

b.mod b.o: b.f90
        gfortran -c $<

Now I have to run "make" twice, I guess it's because make does not know
b.mod can change due to a change in b.f90, as it is an order-only
dependency...


So, is there a solution for this?

Yes, I believe there is; the following Makefile seems to work fine:


all: a.o b.o

a.o: a.f90 b.mod
        gfortran -c $<

b.o: b.f90
        gfortran -c $<

b.mod: b.f90 b.o
        @true

a.mod: a.f90 a.o
        @true


I know it's not as easy as one could hope, but I intend to add options to generate Makefile dependencies (-M options) in gfortran-4.4.


Regards,
FX


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]