[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re-evaluate date of file after updating?
From: |
Norbert Nemec |
Subject: |
Re-evaluate date of file after updating? |
Date: |
Mon, 29 Mar 2010 17:50:34 +0100 |
User-agent: |
Thunderbird 2.0.0.24 (X11/20100317) |
Hi there,
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. Sometimes, however,
you want the commands themselves determine whether a file has changed.
MAKE should then be able to check this by the file date after the
commands have completed.
To give my use-case in more detail (strongly simplified):
===============
I am currently trying to set up an intelligent build system for a large
Fortran project. In Fortran, when a file lib.f90 is compiled by
f90 -c lib.f90
the interface is written into a file lib.mod, the code itself into lib.o
Very often, when lib.f90 has changed, the object file lib.o is modified
but the interface lib.mod remains the same.
Other files using the module only depend on the interface. If lib.mod
has not changed, they do not need to be recompiled.
My best attempt at implementing this kind of dependencies in a Makefile
is as follows
------------
prog: prog.o lib.o
f90 -o prog prog.o lib.o
prog.o: lib.mod
f90 -c prog.f90
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.
An alternative attempt was to modify the rule for lib.mod into
------------
lib.mod: | lib.o
------------
This, however, did not work either: Now, the prog.o would not be
recompiled, even if lib.mod was modified when re-compiling lib.f90. The
only solution here was to run MAKE twice.
It seems that the MAKE program reads in all the file timestamps at the
beginning of the build process and then never checks again. What I would
need is some mechanism that checks the file dates of the prerequisites
*after* they have been rebuilt.
===============
Greetings,
Norbert Nemec
--
_________________________________________Norbert Nemec
71 High Street, Trumpington, Cambridge CB2 9HZ, UK
Tel: +44-1223-479234 Mobile: +44-752-8205872
eMail: <address@hidden>
- Re-evaluate date of file after updating?,
Norbert Nemec <=