help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: searching for a comman with $(findstring)


From: John Graham-Cumming
Subject: Re: searching for a comman with $(findstring)
Date: Mon, 18 Jun 2007 15:08:21 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040208 Thunderbird/0.5 Mnenhy/0.6.0.104

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mike Frysinger wrote:
> is it possible to search for a comma using $(findstring) ?  i tried escaping 
> it with no luck :(
> 
> test:
>       echo $(findstring -Wl,moo,$(LDFLAGS))
> 
> which obviously behaves like:
>       find = -Wl
>       in = moo,$(LDFLAGS)
> 
> this also fails:
>       echo $(findstring -Wl\,moo,$(LDFLAGS))
> 
> the best i have is:
> MOO = -Wl,moo
> $(findstring $(MOO),$(LDFLAGS))

Firstly, escaping in GNU Make doesn't work (most of the time :-) and so
what you are trying to do looks good, but doesn't do anything.

You will need to define a variable that contains the comma.   Since GNU
Make has incredibly liberal variable naming it's possible to do the
following:

    ,:=,

That defines a variable called , which has the value ,.   You can use
this variable by writing $(,) anywhere you need a comma.  Since GNU Make
also has the short form variable expansion ($(a) can be written $a) that
means you can get a comma by writing $, and if you close your eyes you
can pretend that's an escape sequence :-)

So your example could be written:

    , := ,

    test:
        echo $(findstring -Wl$(,)moo,$(LDFLAGS))

(You can't use the $, contraction here because of the way that argument
splitting is done by GNU Make, pity :-)

John.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGdoPELphrp73n/hARAmEFAKDTs08PxsqlucmDC/iamM1zvXYTtgCeNoAu
1yzoZ2/KhEDmBc32dm7zB2s=
=NSiV
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]