[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Understanding $(eval)
From: |
Bryan Ischo |
Subject: |
Re: Understanding $(eval) |
Date: |
Tue, 11 Sep 2007 01:06:24 -0400 (EDT) |
User-agent: |
SquirrelMail/1.4.8-4.fc5 |
Paul Smith wrote:
> Originally when I set out to implement the feature provided by eval,
> this is exactly how I intended to do it: remove the restriction that a
> single line of a makefile must expand to a single line, and allow the
> expansion to create multiple lines which would then themselves be
> parsed. This turned out to be annoyingly tricky, although of course it
> would be doable: it's just programming. In fact, it could STILL be done
> if we wanted to do it.
Thank you for the explanation, it is very helpful in sanity checking my
understanding of eval and its use. Perhaps someday the make code base
will be altered to allow multi-line text replacements, in which case most
uses of $(eval) will be harmless but unnecessary.
> However, I then decided to just use an $(eval ...) function since it was
> simpler to implement, AND it does provide one very powerful feature you
> can't get using the original method; consider this:
>
> all: foo ; @echo $(FOO)
>
> foo: ; $(eval FOO = foo)
>
> Obviously this is a contrived example, but the ability to perform make
> operations such as setting make variable from inside command scripts can
> provide a lot of power.
$(eval) is an *incredibly* useful function and I am just really happy that
gnu make has added it, despite its (small) warts. I am writing a
reasonably gnarly makefile using $(eval) and $(call) extensively and some
things aren't quite working like I expect, probably because of bugs in my
makefile code. But I feel like the structure of the thing is really nice,
and I would never be able to do things as cleanly without $(eval) and
$(call).
Thanks again, and best wishes,
Bryan