help-make
[Top][All Lists]

## Re: What is wrong ?

 From: Paul D. Smith Subject: Re: What is wrong ? Date: Fri, 7 Apr 2006 12:21:58 -0400

```%% "PATTON, BILLY \(SBCSI\)" <address@hidden> writes:

pb> I'm using the gmsl lib to help me with this.
pb> define refresh_proj_bb
pb> \$(1)\$(sep)\$(2)\$(sep)\$(3) : \$(warning \$(\$(call
uc,\$(1))\$(sep)\$(2)\$(sep)\$(3)))
pb> endef

pb> \$(1) = refresh
pb> \$(2) = proj
pb> \$(3) = bb
pb> \$(sep) = +

Eh?  Don't you mean:

1 = refresh
2 = proj
3 = bb
sep = +

?  Also naming these variables "1", "2", and "3" will really confuse you
when using \$(call ...); I strongly urge you to use something else:

pre = refresh
mid = proj
end = bb
sep = +

pb> If I do:
pb> \$(warning \$(call uc,\$(1)))

Then: \$(warning \$(call uc,\$(pre)))

etc.

pb> I will print REFRESH as expected

pb> I have:
pb> \$(warning \$(\$(call uc,\$(1))\$(sep)\$(2)\$(sep)\$(3)))
^^                                   ^
Why do you have the extra \$( ... ) here?

That means you're taking the result of \$(call uc,\$(1))\$(sep)\$(2)\$(sep)\$(3)
which is 'REFRESH+proj+bb', and using it as the name of a variable and
dereferencing it.

Assuming you have no variable named REFRESH+proj+bb, that will yield the
empty string.

pb> I wan it to print :
pb> REFRESH+proj+bb

Change to:

\$(warning \$(call uc,\$(1))\$(sep)\$(2)\$(sep)\$(3))

pb> What is wrong?  probably need \$\$ somewhere :(

No.  You're going nuts-o with the extra variable referencing!!  Only use
it where necessary.  You can't just add them all over the place like
extra escape sequences :-).

--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden>          Find some GNU make tips at:
http://www.gnu.org                      http://make.paulandlesley.org