List Info

Thread: Executing Perl pattern substitution inside a Makefile




Executing Perl pattern substitution inside a Makefile
user name
2007-12-17 17:00:02

I want to issue the following Perl one liner inside a Makefile:

  perl -ple 's/${(w+)}/$ENV{$1}/g'

which would turn this:

  /pkg/qct/verif/qvm/lib/8.0.0/${VERA_VERSION}/novip/qmicro_xact_mon.vro

into this

  /pkg/qct/verif/qvm/lib/8.0.0/6.4.4/novip/qmicro_xact_mon.vro

eg.

  some_target:${VERA_LIBRARY_DEPS}
    $ ${VERA_LIBRARY_DEPS} | perl -ple 's/${(w+)}/$ENV{$1}/g' > $

The expression is not evaluated correctly ... I've tried any number of alternatives
with no luck. If someone can suggest something which would work I'd be much
obliged.

Thanks,

-Frazer

Re: Executing Perl pattern substitution inside a Makefile
user name
2007-12-17 23:25:55
On Mon, 2007-12-17 at 18:00 -0500, Frazer Worley wrote:
> perl -ple 's/${(w+)}/$ENV{$1}/g'

Check the GNU make manual.  Any dollar sign ($) in a recipe
is
interpreted as a make variable reference and expanded before
the recipe
is passed to the shell.

In order to escape dollar signs, you need to double them
($$).  So, use
this instead:

	perl -ple 's/$${(w+)}/$$ENV{$$1}/g'

-- 
------------------------------------------------------------
-------------------
 Paul D. Smith <psmithgnu.org>          Find
some GNU make tips at:
 http://www.gnu.org        
             http://make.mad-scientis
t.us
 "Please remain calm...I may be mad, but I am a
professional." --Mad Scientist


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

Re: Executing Perl pattern substitution inside a Makefile
user name
2007-12-18 11:29:55

Thanks - got that working:

  $ $ ${VERA_LIBRARY_DEPS} | perl -ple 's/$${(w+)}/$$ENV{$$1}/g'; >> $

Appreciate the help.

-Frazer


On Dec 18, 2007 12:25 AM, Paul Smith < psmithgnu.org">psmithgnu.org&gt; wrote:
On Mon, 2007-12-17 at 18:00 -0500, Frazer Worley wrote:
&gt; perl -ple 's/${(w+)}/$ENV{$1}/g'

Check the GNU make manual.  Any dollar sign ($) in a recipe is
interpreted as a make variable reference and expanded before the recipe
is passed to the shell.

In order to escape dollar signs, you need to double them ($$).  So, use
this instead:

       perl -ple 's/$${(w+)}/$$ENV{$$1}/g';

--
-------------------------------------------------------------------------------
&nbsp;Paul D. Smith < psmithgnu.org">psmithgnu.org&gt;          Find some GNU make tips at:
  http://www.gnu.org                      http://make.mad-scientist.us
&nbsp;"Please remain calm...I may be mad, but I am a professional." --Mad Scientist

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )