Skip to content

Commit acca9d9

Browse files
committed
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>
1 parent 3dd22d2 commit acca9d9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ all: check_ocxl_header obj/$(LIBSONAME) obj/libocxl.so obj/libocxl.a \
1919
HAS_WGET = $(shell /bin/which wget > /dev/null 2>&1 && echo y || echo n)
2020
HAS_CURL = $(shell /bin/which curl > /dev/null 2>&1 && echo y || echo n)
2121

22-
# Update this to test a single feature from the most recent header we require:
23-
CHECK_OCXL_HEADER_IS_UP_TO_DATE = $(shell /bin/echo -e \\\#include $(1)\\\nvoid test\(struct ocxl_ioctl_features test\)\; | \
22+
# Update this to test a single feature from the most recent header we require.
23+
#
24+
# Note that a backward-incompatible change in make 4.3 modified the
25+
# handling \# in a function invocation, so we define the test code in
26+
# a separate variable to work around it and keep consistent behavior
27+
# across all versions of make
28+
TEST_CODE = '\#include <misc/ocxl.h>\nvoid test(struct ocxl_ioctl_features test);'
29+
CHECK_OCXL_HEADER_IS_UP_TO_DATE = $(shell /bin/echo -e $(TEST_CODE) | \
2430
$(CC) $(CFLAGS) -Werror -x c -S -o /dev/null - > /dev/null 2>&1 && echo y || echo n)
2531

2632
check_ocxl_header:
27-
ifeq ($(call CHECK_OCXL_HEADER_IS_UP_TO_DATE,'<misc/ocxl.h>'),n)
33+
ifeq (${CHECK_OCXL_HEADER_IS_UP_TO_DATE},n)
2834
mkdir -p kernel/include/misc
2935
ifeq (${HAS_WGET},y)
3036
$(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)

0 commit comments

Comments
 (0)