|
List Info
Thread: subst question
|
|
| subst question |

|
2007-01-26 05:00:59 |
All,
Another quick question. Does anyone know a way in GNU Make
to filter off the
first instance only of a given string.
For example, at the moment I'm doing
$(subst lib,,libfoo.a)
which gives me "foo.a". However if I do :
$(subst lib,,libbarlib.a)
this also gives me "bar.a" even though what I need
is "barlib.a".
Any ideas ?
Regards
Brendan
_______________________________________________
Help-make mailing list
Help-make gnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make
|
|
| Re: subst question |

|
2007-01-26 05:26:36 |
----- Original Message -----
From: "Brendan Heading" <brendanheading clara.co.uk>
To: <help-make gnu.org>
Sent: Friday, January 26, 2007 12:00 PM
Subject: subst question
> All,
>
> Another quick question. Does anyone know a way in GNU
Make to filter off
the
> first instance only of a given string.
>
> For example, at the moment I'm doing
>
> $(subst lib,,libfoo.a)
>
> which gives me "foo.a". However if I do :
>
> $(subst lib,,libbarlib.a)
>
> this also gives me "bar.a" even though what I
need is "barlib.a".
>
> Any ideas ?
I guess it depends on what you mean with 'the first instance
only'. If you
only want to replace the first instance in a word (and do
this for every
word) and you're sure the string you want to replace is at
the beginning of
a word, you could use the patsubst function: something like
$(patsubst
lib%,%,libbarlib.a) will do what you want. A similar thing
can be done if
the string is at the end of the word.
If the string can be located anywhere in your word - for
instance lib in
'mylibgreatlib.a' and you only want the first lib to be
replaced, the only
thing I can think of is using stuff like sed in combination
with the shell
function. For instance something like this:
LIBS := mylibgreatlib.a something.a
LIBS := $(shell echo $(LIBS) | sed 's/lib//')
# LIBS now contains 'mygreatlib.a something.a'
I guess that's not a perfect solution, but it works
Hope this helps,
Danny
_______________________________________________
Help-make mailing list
Help-make gnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make
|
|
| Re: subst question |

|
2007-01-26 08:53:55 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Brendan Heading wrote:
> Another quick question. Does anyone know a way in GNU
Make to filter off
> the first instance only of a given string.
> For example, at the moment I'm doing
> $(subst lib,,libfoo.a)
> which gives me "foo.a". However if I do :
> $(subst lib,,libbarlib.a)
> this also gives me "bar.a" even though what I
need is "barlib.a".
Use patsubst: $(patsubst lib%,%,libbarlib.a) will give the
result you
are looking for.
John.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFuhYDLphrp73n/hARAixtAJ4/AJ3wLNzwP/t/xyHHraW+npKrbACg
mW77
pAzeXnU4Rzcz87WGcx150a4=
=uIO5
-----END PGP SIGNATURE-----
_______________________________________________
Help-make mailing list
Help-make gnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make
|
|
| RE: subst question |

|
2007-01-26 08:43:29 |
On 26 January 2007 11:01, Brendan Heading wrote:
> All,
>
> Another quick question. Does anyone know a way in GNU
Make to filter off the
> first instance only of a given string.
>
> For example, at the moment I'm doing
>
> $(subst lib,,libfoo.a)
>
> which gives me "foo.a". However if I do :
>
> $(subst lib,,libbarlib.a)
>
> this also gives me "bar.a" even though what I
need is "barlib.a".
>
> Any ideas ?
How about
$(patsubst lib%,%,libbarlib.a)
cheers,
DaveK
--
Can't think of a witty .sigline today....
_______________________________________________
Help-make mailing list
Help-make gnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make
|
|
| Re: subst question |

|
2007-01-26 09:41:58 |
John Graham-Cumming writes:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Brendan Heading wrote:
>> Another quick question. Does anyone know a way in
GNU Make to filter off
>> the first instance only of a given string.
>> For example, at the moment I'm doing
>> $(subst lib,,libfoo.a)
>> which gives me "foo.a". However if I do
:
>> $(subst lib,,libbarlib.a)
>> this also gives me "bar.a" even though
what I need is "barlib.a".
>
> Use patsubst: $(patsubst lib%,%,libbarlib.a) will give
the result you
> are looking for.
Thanks everyone, that did exactly what I needed.
Regards
Brendan
_______________________________________________
Help-make mailing list
Help-make gnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make
|
|
[1-5]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|