summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Barrat <fbarrat@linux.ibm.com>2020-07-24 15:05:31 +0200
committerfbarrat <fbarrat@linux.ibm.com>2020-08-24 11:00:24 +0200
commitacca9d9e59572ebc9477ac5338c1656e307dd2b7 (patch)
tree610839923aa5d0d8e15ae9bb17e612f8823e4921
parent3dd22d2a5928a47dc7fe43942f58e47ff22c947c (diff)
Makefile: Fix header file detection with latest versions of make
Gnu make 4.3 introduced a backward-incompatible change in its handling of the escape character before # when calling a function. And it is used when writing some test code to check the latest version of the ocxl header file (#include <misc/ocxl.h>). This patch reworks how the test code is passed to the compiler to avoid complications and be compatible with all version of make. Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
-rw-r--r--Makefile12
1 files changed, 9 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 46e5916..352d4fc 100644
--- a/Makefile
+++ b/Makefile
@@ -19,12 +19,18 @@ all: check_ocxl_header obj/$(LIBSONAME) obj/libocxl.so obj/libocxl.a \
HAS_WGET = $(shell /bin/which wget > /dev/null 2>&1 && echo y || echo n)
HAS_CURL = $(shell /bin/which curl > /dev/null 2>&1 && echo y || echo n)
-# Update this to test a single feature from the most recent header we require:
-CHECK_OCXL_HEADER_IS_UP_TO_DATE = $(shell /bin/echo -e \\\#include $(1)\\\nvoid test\(struct ocxl_ioctl_features test\)\; | \
+# Update this to test a single feature from the most recent header we require.
+#
+# Note that a backward-incompatible change in make 4.3 modified the
+# handling \# in a function invocation, so we define the test code in
+# a separate variable to work around it and keep consistent behavior
+# across all versions of make
+TEST_CODE = '\#include <misc/ocxl.h>\nvoid test(struct ocxl_ioctl_features test);'
+CHECK_OCXL_HEADER_IS_UP_TO_DATE = $(shell /bin/echo -e $(TEST_CODE) | \
$(CC) $(CFLAGS) -Werror -x c -S -o /dev/null - > /dev/null 2>&1 && echo y || echo n)
check_ocxl_header:
-ifeq ($(call CHECK_OCXL_HEADER_IS_UP_TO_DATE,'<misc/ocxl.h>'),n)
+ifeq (${CHECK_OCXL_HEADER_IS_UP_TO_DATE},n)
mkdir -p kernel/include/misc
ifeq (${HAS_WGET},y)
$(call Q,WGET kernel/include/misc/ocxl.h, wget -O kernel/include/misc/ocxl.h -q https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/include/uapi/misc/ocxl.h)