help-make
[Top][All Lists]
Advanced

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

Re: using the date relationship of two older files as a prerequisit


From: Britton Kerin
Subject: Re: using the date relationship of two older files as a prerequisit
Date: Fri, 30 Nov 2012 08:29:31 -0900

On Thu, Nov 29, 2012 at 8:50 AM, Brian J. Murrell <address@hidden> wrote:
> I have a file which is not created by make but is created/updated by an
> outside process.  The time stamp on this file will always be some time
> in the past.  Let's call this file "O".
>
> I have a target which I want make to build which we'll call "T".  I want
> T rebuilt if file O is newer than it was the last time T was built.  But
> even though the time on O might be newer than it was the last time T was
> built, it will still not be newer than T.
>
> Somehow I need to introduce some kind of time tracking mechanism on O
> which triggers a dependency on T, perhaps through a "stamp" file of some
> sort but I'm not quite getting my head around it.

I think this will do what you want:

O_update_stamp: O
        touch $@

T: O_update_stamp
        @echo Time to rebuild T...
        touch $@

clean:
        rm -f O_update_stamp T

Here is how I tested it:

$ make clean
rm -f O_update_stamp T
$ make T
touch O_update_stamp
Time to rebuild T...
touch T
$ make T
make: `T' is up to date.
$ touch O
$ touch T
$ make T
touch O_update_stamp
Time to rebuild T...
touch T
$

It works because the intermediate stamp ends up older than O after O is
updated, which in turn triggers a rebuild of T (even though O_update_stamp
isn't actually used in the build).

>
> Any ideas?
>
> Cheers,
> b.
>
>
> _______________________________________________
> Help-make mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-make
>



reply via email to

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