SECONDEXPANSION and $(shell) bug in make 3.82.90

View: New views
3 Messages — Rating Filter:   Alert me  

SECONDEXPANSION and $(shell) bug in make 3.82.90

by Martin d'Anjou-5 :: Rate this Message:

| View Threaded | Show Only this Message

Hi,

I try to use GNU Make at the CVS head because of the memory leak in 3.82
(see http://lists.gnu.org/archive/html/help-make/2011-11/msg00080.html).

After much work to get the CVS head to compile on redhat 5.5 (had to do a
local install of gettext and misc toolchain stuff), I run into a problem
with the SECONDEXPANSION and $(shell):

Here is the makefile:
.SECONDEXPANSION:
all: $$(shell find . \( -name "*.swp" \))
        echo $<

Here is the result:
$ make
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `find . ( -name "*.swp" )'
echo

Here is the version:
$ make --version
GNU Make 3.82.90

There is no issue running this with make 3.81:
$ make
echo .makefile.swp
.makefile.swp
$ make --version
GNU Make 3.81

What should I do? I want 3.82 because of the ONESHELL feature.

Thanks,
Martin
_______________________________________________
Help-make mailing list
Help-make@...
https://lists.gnu.org/mailman/listinfo/help-make

Re: SECONDEXPANSION and $(shell) bug in make 3.82.90

by Paul Smith-20 :: Rate this Message:

| View Threaded | Show Only this Message

On Thu, 2012-04-12 at 16:01 -0400, Martin d'Anjou wrote:
> Here is the makefile:
> .SECONDEXPANSION:
> all: $$(shell find . \( -name "*.swp" \))
>         echo $<

Did this used to work?  I'd be surprised if did; if so it was probably a
bug in the old version of make.

You need to be sure that make knows where the variable ends, so that
requires quoting the end paren at least from make, AND you need to quote
the parens to the shell as well.

Does it work if you just switch to the alternative delimiters:

  all: $${shell find . \( name "*.swp" \)}

?

What about if you put the command in a variable?

  find := find . \( name "*.swp" \)
  all: $$(shell $$(find))



_______________________________________________
Help-make mailing list
Help-make@...
https://lists.gnu.org/mailman/listinfo/help-make

Re: SECONDEXPANSION and $(shell) bug in make 3.82.90

by Martin d'Anjou-5 :: Rate this Message:

| View Threaded | Show Only this Message

On 12-04-12 05:26 PM, Paul Smith wrote:
> On Thu, 2012-04-12 at 16:01 -0400, Martin d'Anjou wrote:
>> Here is the makefile:
>> .SECONDEXPANSION:
>> all: $$(shell find . \( -name "*.swp" \))
>>          echo $<
> Did this used to work?  I'd be surprised if did; if so it was probably a
> bug in the old version of make.
Yes, it works in 3.81, and I use it quite a bit actually, to create
conditional pre-requisites.

>
> You need to be sure that make knows where the variable ends, so that
> requires quoting the end paren at least from make, AND you need to quote
> the parens to the shell as well.
>
> Does it work if you just switch to the alternative delimiters:
>
>    all: $${shell find . \( name "*.swp" \)}
>
No luck. It still fails the same way with the curly-braces.


>
> What about if you put the command in a variable?
>
>    find := find . \( name "*.swp" \)
>    all: $$(shell $$(find))

Bingo! This solution works... for this small example... however, when I
go back to my full-scale makefile, I run into a memory leak. I will do a
separate post.

Thanks,
Martin

_______________________________________________
Help-make mailing list
Help-make@...
https://lists.gnu.org/mailman/listinfo/help-make