Skip to contentSkip to conversation

src/Makefile: fix HAVE_C_DEF probe under a non-bash /bin/sh

PATCH Applied Mohamed Khalfella 2 participants 2 messages Sep 8 – Sep 11 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 src/Makefile: fix HAVE_C_DEF probe under a non-bash /bin/sh

HAVE_C_DEF feeds its test program to the compiler with "echo -e". The $(shell ...) function runs under /bin/sh, which is dash on Debian and Ubuntu, and dash's echo has no -e option. It prints the flag literally, so the first line of the probe becomes

-e #include <linux/ublk_cmd.h>

which is no longer a preprocessor directive. The header is never included, the tested macro is never defined, and the probe reports 0 regardless of what the installed headers contain.

The only user is HAVE_NEW_UBLK_INTF, so miniublk is skipped with

Skip miniublk build due to missing new ublk interface(v6.4+)

Use printf instead, which expands \n in any POSIX shell, and pass the substituted names as arguments so they are not reinterpreted.

---
 src/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
src/Makefile +3 -2
index ef9c887..dd64694 100644
@@ -8,8 +8,9 @@ HAVE_C_MACRO = $(shell if echo "$(H)include <$(1)>" |	\
 		$(CC) $(CFLAGS) -E - 2>&1 /dev/null | grep $(2) > /dev/null 2>&1; \
 		then echo 1;else echo 0; fi)
 
-HAVE_C_DEF = $(shell if echo -e "$(H)include <$(1)>\n$(H)ifdef $(2)\nHAVE_$(2)\n$(H)endif" | \
-		$(CC) $(CFLAGS) -E - 2>&1 /dev/null | grep HAVE_$(2) > /dev/null 2>&1; \
+HAVE_C_DEF = $(shell if printf '$(H)include <%s>\n$(H)ifdef %s\nHAVE_%s\n$(H)endif\n' \
+		"$(1)" "$(2)" "$(2)" | \
+		$(CC) $(CFLAGS) -E - 2>/dev/null | grep HAVE_$(2) > /dev/null 2>&1; \
 		then echo 1;else echo 0; fi)
 
 C_TARGETS := \
Signature · 1 line
2.55.0
#1 lore raw
Quoted 11 lines · Mohamed Khalfella

HAVE_C_DEF feeds its test program to the compiler with "echo -e". The $(shell ...) function runs under /bin/sh, which is dash on Debian and Ubuntu, and dash's echo has no -e option. It prints the flag literally, so the first line of the probe becomes

-e #include <linux/ublk_cmd.h>

which is no longer a preprocessor directive. The header is never included, the tested macro is never defined, and the probe reports 0 regardless of what the installed headers contain.

Quoted 8 lines

The only user is HAVE_NEW_UBLK_INTF, so miniublk is skipped with

Skip miniublk build due to missing new ublk interface(v6.4+)

Use printf instead, which expands \n in any POSIX shell, and pass the substituted names as arguments so they are not reinterpreted.

I applied the patch. Thanks!