--- Begin Message ---
Subject: |
Re: gmake $(eval()) question. |
Date: |
Fri, 29 Jun 2007 00:38:23 +0200 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/22.1.50 (gnu/linux) |
address@hidden writes:
> Hi,
>
> I have the following Makefile which demonstrates my problem:
>
> ---------Begin Makefile------------
> HI=$(eval HELLO=Hello)
>
> all:server client
>
> server:
> <tab>@echo "HELLO: $(HELLO)"
> <tab>@echo "HI: $(HI)"
>
> client:
> <tab>@echo "HELLO: $(HELLO)"
> <tab>@echo "HI: $(HI)"
> -----------End Makefile------------
>
> If I run gmake, I get this output:
> HELLO:
> HI:
> HELLO: Hello
> HI:
>
> This thing that puzzles me is why the first line only contains
> "HELLO:". As per my understanding, it should be the same as line 3.
This is not possible. When it execute the first echo "HELLO:
$(HELLO)", $(HI) has not been evaluated yet, so HELLO is not a
variable defined yet.
> If I run "gmake server" or "gmake client", I get:
> HELLO:
> HI:
>
> Again, I think the first line of output should be "HELLO: Hello"
Impossible, as above.
> So can anyone explain why this is happening? I am running gmake 3.81
> on Fedora Core 6.
info gmake
= is a textual definition. You can substitute all occurence of HI with
$(eval HELLO=Hello). Your makefile is equivalent to:
---------Begin Makefile------------
all:server client
server:
@echo "HELLO: $(HELLO)"
@echo "HI: $(eval HELLO=Hello)"
client:
@echo "HELLO: $(HELLO)"
@echo "HI: $(eval HELLO=Hello)"
-----------End Makefile------------
So you see, there's no variable named HELLO defined before you execute
one of the echo HI lines.
In info gmake, you should be able to read about := which may do what you want.
--
__Pascal Bourguignon__ http://www.informatimago.com/
NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
--- End Message ---
--- Begin Message ---
Subject: |
confirm 00e59901e8c55a74a2764556a30520c0f8222b5c |
If you reply to this message, keeping the Subject: header intact,
Mailman will discard the held message. Do this if the message is
spam. If you reply to this message and include an Approved: header
with the list password in it, the message will be approved for posting
to the list. The Approved: header can also appear in the first line
of the body of the reply.
--- End Message ---