GNU make version 4.3 introduced a backward-incompatible change. The
number sign '#' now should not have preceding backslash in a macro [1].
To make macros with number signs work regardless of make versions,
assign the number sign to a variable.
[1] https://lwn.net/Articles/810071/
Reported-by: Ziyang Zhang <ZiyangZhang@linux.alibaba.com>
Link: https://lore.kernel.org/linux-block/cfccc895-5a9b-f45b-5851-74c94219d743@linux.alibaba.com/
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
-HAVE_C_HEADER = $(shell if echo "\#include <$(1)>" | \
+H := \#
+
+HAVE_C_HEADER = $(shell if echo "$(H)include <$(1)>" | \
$(CC) -E - > /dev/null 2>&1; then echo "$(2)"; \
else echo "$(3)"; fi)
-HAVE_C_MACRO = $(shell if echo "#include <$(1)>" | \
+HAVE_C_MACRO = $(shell if echo "$(H)include <$(1)>" | \
$(CC) -E - 2>&1 /dev/null | grep $(2) > /dev/null 2>&1; \
then echo 1;else echo 0; fi)