[ipxe-devel] [ipxe/ipxe] fix EMBED: don't eagerly assign over non-empty value (#115)

realtime-neil notifications at github.com
Thu Jun 18 01:05:56 UTC 2020


> What problem is this actually solving?

Allow me to demonstrate:

```
$ echo && cat Makefile.bad && echo && EMBED=foobar make -f Makefile.bad && echo && cat Makefile.good && EMBED=foobar make -f Makefile.good 

EMBED := $(EMBEDDED_IMAGE)

.PHONY: all
all:
	echo "EMBEDDED_IMAGE: $(EMBEDDED_IMAGE)"
	echo "EMBED: $(EMBED)"


echo "EMBEDDED_IMAGE: "
EMBEDDED_IMAGE: 
echo "EMBED: "
EMBED: 

EMBED ?= $(EMBEDDED_IMAGE)

.PHONY: all
all:
	echo "EMBEDDED_IMAGE: $(EMBEDDED_IMAGE)"
	echo "EMBED: $(EMBED)"

echo "EMBEDDED_IMAGE: "
EMBEDDED_IMAGE: 
echo "EMBED: foobar"
EMBED: foobar
```

When the definition of the shell variable `EMBED` precedes `make`, `Makefile.good` shows the effect and `Makefile.bad` does not.

> Any variables specified in the `make` command line will override assignments within the Makefile. Building with `make EMBED=...` works with no problems already.

You're not wrong: `make EMBED=...` works. What doesn't work is `EMBED=... make` or any combination of exporting a shell variable for later consumption by a `make` invocation. For reasons that I have yet to dig out of the GNU Make manual, consuming that variable definition only works when it appears as a argument to the `make` command.

Strictly speaking, it's not incorrect to accept only variable assignments that happen to follow the command, but it will confuse others (like me) that assume the `EMBED` should behave like a shell variable when the immediate assignment prevents exactly that.


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/ipxe/ipxe/pull/115#issuecomment-645707277
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20200617/cc0133e1/attachment.htm>


More information about the ipxe-devel mailing list