On Wed, Jul 21, 2010 at 1:28 AM, Edward Welbourne
<address@hidden> wrote:
> previous_var:
> echo $(VAR) > previous_var
> .PHONY: previous_var
I suggest you eliminate this .PHONY - previous_var is a real file on
disk, so not a phony target. There might be a case for it to be
declared .PHONY in an *else* clause, when PREVIOUS_VAR agrees with
VAR.
The .PHONY forces make to update the file, even though it has no dependencies and would otherwise be considered up-to-date.
> /source/test $ make VAR=abc
> cat: previous_var: No such file or directory
I suggest
PREVIOUS_VAR := $(if $(wildcard previous_var),$(shell cat previous_var),)
to avoid that one, or simply
PREVIOUS_VAR := $(shell cat previous_var 2>/dev/null)
True. I was trying to keep the example fairly simple, and ensure that the $(wildcard ) didn't mess up the directory cache as other bugs suggest might happen.
Not that I expect either of these to fix your problem (albeit the
first might) !
Eddy.