help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re-evaluate date of file after updating?


From: Paul Smith
Subject: Re: Re-evaluate date of file after updating?
Date: Mon, 29 Mar 2010 15:58:56 -0400

On Mon, 2010-03-29 at 17:50 +0100, Norbert Nemec wrote:

> is there a way to define dependencies that re-evaluate the date of a 
> file *after* updating it? Currently, the MAKE program blindly assumes 
> that the target is actually modified its commands.

No it doesn't.  If the command script doesn't modify the timestamp on
the generated file then targets that depend on it won't consider it to
be updated.  This is very commonly used.

> My best attempt at implementing this kind of dependencies in a Makefile 
> is as follows

> lib.mod: lib.o
> lib.o: lib.f90
>         mv lib.mod lib.mod.old
>         f90 -c lib.f90
>         diff -qN lib.mod.old lib.mod > /dev/null && mv lib.mod.old lib.mod
>         rm -f lib.mod.old

> This behaves nearly as needed, but unfortunately, the rule for prog.o 
> does not care whether lib.mod has actually changed. It always recreates 
> prog.o when lib.f90 was modified.

That's because there's no command sequence for lib.mod.  If you add a
"do nothing" command to the lib.mod: lib.o rule, I think it will work as
you expect (note I didn't test this):

        lib.mod: lib.o ; @:






reply via email to

[Prev in Thread] Current Thread [Next in Thread]