Skip to content

Commit

Permalink
Makefile: Fix header file detection with latest versions of make
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
fbarrat committed Aug 24, 2020
1 parent 3dd22d2 commit acca9d9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit acca9d9

Please sign in to comment.