Work around GNU Make bug involving shell built-ins v1 PROPOSED

Christopher Wellons: 1
 Work around GNU Make bug involving shell built-ins

 1 files changed, 1 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~skeeto/public-inbox/patches/20756/mbox | git am -3
Learn more about email & git

[PATCH] Work around GNU Make bug involving shell built-ins Export this patch

The workaround for MSYS2 in 475c111 interacts badly with a long-standing
bug in GNU Make where it avoids spawning a shell when it believes it can
handle a command itself as a sort of Bourne shell emulation. Since
"command" is typically implemented as a special shell built-in and not
an actual program, and GNU Make does not implement this built-in in its
Bourne shell emulation, GNU Make's shell function fails to invoke it
properly, resulting in an error:

    make: command: Command not found

One work-around is to set a custom shell that is not "/bin/sh" so that
GNU Make does not assume any particular shell semantics. For instance:

    make SHELL=dash

A second work-around is to use a shell feature not implemented by GNU
Make, such as redirection or variable assignment (this patch), causing
it to spawn an actual shell to handle the shell command.
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 4cb8d924c..5fe327519 100644
--- a/Makefile
+++ b/Makefile
@@ -308,7 +308,7 @@ CHECK		= sparse

# Handle MSYS2 weirdness
ifneq ($(CROSS_COMPILE),)
ifeq ($(shell command -v $(AR)),)
ifeq ($(shell _= command -v $(AR)),)
AR := $(CROSS_COMPILE)gcc-ar
STRIP := strip
WINDRES := windres