[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Variable assignment that depends on a generated target
From: |
Paul Smith |
Subject: |
Re: Variable assignment that depends on a generated target |
Date: |
Wed, 25 Apr 2007 18:48:28 -0400 |
On Wed, 2007-04-25 at 21:25 +0300, Eli Zaretskii wrote:
> > From: Paul Smith <address@hidden>
> > Cc: David Wuertele <address@hidden>, address@hidden
> > Date: Wed, 25 Apr 2007 09:12:34 -0400
> >
> > > VERSION := $(shell make /path/to/some/file && grep VERSION
> > > /path/to/some/file)
> >
> > This will work, but I prefer the include version I mentioned earlier.
>
> Can you explain why you prefer that method?
Well, firstly because as written your method will recurse infinitely :).
You'd need something like:
VERSION := $(shell $(MAKE) VERSION= /path/to/some/file && grep VERSION
/path/to/some/file)
to avoid that.
Secondly, in your method the invocation of the sub-make will happen
every time this makefile is parsed, while with the include method the
version.mk is only rebuilt (and make re-invoked) if /path/to/some/file
has actually changed. Also you could avoid re-invoking make by having
the script to build version.mk smart enough to not change the file if
the version string didn't change (even if /path/to/some/file did).
But beyond that, I just think it's cleaner and nicer to use make's
builtin capabilities in this area, rather than force it with
$(shell ...)
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist