[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using the date relationship of two older files as a prerequisite
From: |
Brian J. Murrell |
Subject: |
Re: using the date relationship of two older files as a prerequisite |
Date: |
Fri, 07 Dec 2012 09:43:02 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
On 12-12-04 11:04 AM, Cook, Malcolm wrote:
> Brian - try this:
>
> # Path to this current makefile
> MAKEFILE=$(lastword $(MAKEFILE_LIST))
>
> # constructed path to a subdirectory to hold datestamp files
> DATESTAMP=$(MAKEFILE).d/datestamp
>
> # rule to create datestamp files, copying the files date
> $(DATESTAMP)/%: %
> mkdir -p $(@D) ; \
> touch -r $* $@
>
> T: O $(DATESTAMP)/O
> cat O > T
This does not appear to work. Given the three files:
-rw-rw-r-- 1 brian brian 0 Dec 3 13:00 Makefile.d/datestamp/O
-rw-rw-r-- 1 brian brian 0 Dec 5 16:06 O
-rw-rw-r-- 1 brian brian 0 Dec 7 09:25 T
Which were created from a previous run where only O existed and after
touching O to make it newer than the Makefile.d/datestamp/O (but older
than T, as I had previously stated could/would be the case).
$ make -d -f Makefile
...
Updating goal targets....
Considering target file `T'.
Considering target file `O'.
...
No need to remake target `O'.
Considering target file `Makefile.d/datestamp/O'.
Looking for an implicit rule for `Makefile.d/datestamp/O'.
Trying pattern rule with stem `O'.
Trying implicit prerequisite `O'.
Found an implicit rule for `Makefile.d/datestamp/O'.
Pruning file `O'.
Finished prerequisites of target file `Makefile.d/datestamp/O'.
Prerequisite `O' is newer than target `Makefile.d/datestamp/O'.
Must remake target `Makefile.d/datestamp/O'.
mkdir -p Makefile.d/datestamp ; \
touch -r O Makefile.d/datestamp/O
Putting child 0x08aa2090 (Makefile.d/datestamp/O) PID 29521 on the chain.
Live child 0x08aa2090 (Makefile.d/datestamp/O) PID 29521
Reaping winning child 0x08aa2090 PID 29521
Removing child 0x08aa2090 PID 29521 from chain.
Successfully remade target file `Makefile.d/datestamp/O'.
Finished prerequisites of target file `T'.
Prerequisite `O' is older than target `T'.
Prerequisite `Makefile.d/datestamp/O' is newer than target `T'.
No need to remake target `T'.
And indeed:
$ ls -l O Makefile.d/datestamp/O T
-rw-rw-r-- 1 brian brian 0 Dec 5 16:06 Makefile.d/datestamp/O
-rw-rw-r-- 1 brian brian 0 Dec 5 16:06 O
-rw-rw-r-- 1 brian brian 0 Dec 7 09:25 T
Makefile.d/datestamp/O was updated to O's timestamp but T was not
updated since it was not re-made.
Cheers and thanks much for your time and consideration. I do appreciate
it. Sorry it took me a bit to get back to it.
b.
signature.asc
Description: OpenPGP digital signature