[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Did $(if $(myvar),...) behavior change from make 3.81 to make 4.1?
From: |
Paul Smith |
Subject: |
Re: Did $(if $(myvar),...) behavior change from make 3.81 to make 4.1? |
Date: |
Mon, 12 Jun 2017 21:49:00 -0400 |
On Mon, 2017-06-12 at 18:26 -0500, David Drinnan wrote:
> I have a makefile that works just fine in make 3.81 on RHEL 6.8, but
> quickly fails with make 4.1 on Ubuntu 16.04.
>
> It's failing on this line (details changed, but same logic):
>
> $(if $(myvar),myothervar := abc,myothervar := xyz)
>
> with error message:
>
> build.mk:3: *** empty variable name. Stop.
This is an issue in the parser. I doesn't matter whether myvar is empty
or not, that's not what it's complaining about. The problem is that the
parser is interpreting this as a target-specific variable assignment,
not a normal variable assignment. That is, instead of expanding to:
myothervar := abc
it's expanding as if you'd written:
myothervar : = abc
which is a target-specific variable assignment with an empty variable
name.
This is a bug: it would be greatly helpful if you could file this on
Savannah, here: https://savannah.gnu.org/bugs/?func=additem&group=make
As for workarounds, the simplest one is to move the if-statement into
the right-hand side; I'm not sure why you need to include the entire
assignment in the if-statement. Like this:
myothervar := $(if $(myvar),abc,xyz)