@@ -13,26 +13,26 @@ SONAMEOPT = -Wl,-soname,$(LIBSONAME)
1313
1414DOCDIR = docs
1515
16- all : obj/$(LIBSONAME ) obj/libocxl.so obj/libocxl.a
16+ all : check_ocxl_header obj/$(LIBSONAME ) obj/libocxl.so obj/libocxl.a
1717
1818HAS_WGET = $(shell /bin/which wget > /dev/null 2>&1 && echo y || echo n)
1919HAS_CURL = $(shell /bin/which curl > /dev/null 2>&1 && echo y || echo n)
2020
2121# Update this to test a single feature from the most recent header we require:
22- # CHECK_CXL_HEADER_IS_UP_TO_DATE = $(shell /bin/echo -e \\\#include $(1)\\\ nvoid test\(struct cxl_afu_id test\)\; | \
23- # $(CC) $(CFLAGS) -Werror -x c -S -o /dev/null - > /dev/null 2>&1 && echo y || echo n)
24- #
25- # check_cxl_header :
26- # ifeq ($(call CHECK_CXL_HEADER_IS_UP_TO_DATE,"< misc/cxl.h> "),n)
27- # mkdir -p include/misc
28- # ifeq (${HAS_WGET},y)
29- # $(call Q,WGET include/misc/cxl .h, wget -O include/misc/cxl .h -q http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/include/uapi/misc/cxl .h)
30- # else ifeq (${HAS_CURL},y)
31- # $(call Q,CURL include/misc/cxl .h, curl -o include/misc/cxl .h -s http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/include/uapi/misc/cxl .h)
32- # else
33- # $(error 'cxl .h is non-existant or out of date, Download from http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/include/uapi/misc/cxl .h and place in ${PWD}/include/misc/cxl .h')
34- # endif
35- # endif
22+ CHECK_OCXL_HEADER_IS_UP_TO_DATE = $(shell /bin/echo -e \\\#include \" $(1 ) \"\\\ nvoid test\(struct ocxl_ioctl_metadata test\) \; | \
23+ $(CC ) $(CFLAGS ) -Werror -x c -S -o /dev/null - > /dev/null 2>&1 && echo y || echo n)
24+
25+ check_ocxl_header :
26+ ifeq ($(call CHECK_OCXL_HEADER_IS_UP_TO_DATE,"kernel/include/ misc/ocxl.h ") ,n)
27+ mkdir -p kernel/ include/misc
28+ ifeq (${HAS_WGET},y)
29+ $(call Q,WGET kernel/ include/misc/ocxl .h, wget -O kernel/ include/misc/ocxl .h -q http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/include/uapi/misc/ocxl .h)
30+ else ifeq (${HAS_CURL},y)
31+ $(call Q,CURL kernel/ include/misc/ocxl .h, curl -o kernel/ include/misc/ocxl .h -s http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/include/uapi/misc/ocxl .h)
32+ else
33+ $(error 'ocxl .h is non-existant or out of date, Download from http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/include/uapi/misc/ocxl .h and place in ${PWD}/kernel/ include/misc/ocxl .h')
34+ endif
35+ endif
3636
3737obj :
3838 mkdir obj
@@ -61,7 +61,7 @@ testobj/libocxl.a: $(TEST_OBJS)
6161testobj/unittests : testobj/unittests.o-test testobj/virtocxl.o-test
6262 $(call Q,CC, $(CC ) $(CFLAGS ) $(LDFLAGS ) -o testobj/unittests testobj/unittests.o-test testobj/virtocxl.o-test testobj/libocxl.a -lfuse -lpthread, testobj/unittests)
6363
64- test : testobj/unittests
64+ test : check_ocxl_header testobj/unittests
6565 sudo testobj/unittests
6666
6767valgrind : testobj/unittests
@@ -106,4 +106,4 @@ dist:
106106 tar Jcf $(VERSION_DIR ) .txz --exclude $(VERSION_DIR ) /debian --exclude $(VERSION_DIR ) /.git --exclude $(VERSION_DIR ) /$(VERSION_DIR ) $(VERSION_DIR ) /*
107107 rm $(VERSION_DIR )
108108
109- .PHONY : clean all install docs precommit cppcheck cppcheck-xml dist
109+ .PHONY : clean all install docs precommit cppcheck cppcheck-xml dist check_ocxl_header
0 commit comments