<div dir="ltr">Very nice, thanks.<div>Merged.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 18, 2016 at 8:52 PM, Bart Van Assche <span dir="ltr"><<a href="mailto:bart.vanassche@sandisk.com" target="_blank">bart.vanassche@sandisk.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The current implementation of the code that checks for function<br>
presence is not correct because it checks for a prefix match only.<br>
Introduce a function that checks for the exact function name.<br>
Additionally, report whether or not the function has been found.<br>
An example of the output produced by this function if 'make' is<br>
run:<br>
<br>
Checking for dm_task_no_flush in /usr/include/libdevmapper.h ... yes<br>
Checking for dm_task_set_cookie in /usr/include/libdevmapper.h ... yes<br>
Checking for udev_monitor_set_receive_<wbr>buffer_size in /usr/include/libudev.h ... yes<br>
Checking for dm_task_deferred_remove in /usr/include/libdevmapper.h ... yes<br>
<br>
Signed-off-by: Bart Van Assche <<a href="mailto:bart.vanassche@sandisk.com">bart.vanassche@sandisk.com</a>><br>
---<br>
 Makefile.inc          | 14 ++++++++++++++<br>
 kpartx/Makefile       |  4 +---<br>
 libmultipath/Makefile | 16 ++++------------<br>
 3 files changed, 19 insertions(+), 15 deletions(-)<br>
<br>
diff --git a/Makefile.inc b/Makefile.inc<br>
index 1cc8f44..e7f4e05 100644<br>
--- a/Makefile.inc<br>
+++ b/Makefile.inc<br>
@@ -69,5 +69,19 @@ OPTFLAGS     = -O2 -g -pipe -Wall -Wextra -Wformat=2 \<br>
 CFLAGS         = $(OPTFLAGS) -fPIC -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\"<br>
 SHARED_FLAGS   = -shared<br>
<br>
+# Check whether a function with name $1 has been declared in header file $2.<br>
+check_func =                                                                  \<br>
+    $(shell                                                                   \<br>
+       if grep -Eq "^[^[:blank:]]+[[:blank:]]+$1[<wbr>[:blank:]]*(.*)*" "$2"; then \<br>
+          found=1;                                                            \<br>
+          status="yes";                                                       \<br>
+       else                                                                   \<br>
+          found=0;                                                            \<br>
+          status="no";                                                        \<br>
+       fi;                                                                    \<br>
+       echo 1>&2 "Checking for $1 in $2 ... $$status";                        \<br>
+       echo "$$found"                                                         \<br>
+    )<br>
+<br>
 %.o:   %.c<br>
        $(CC) $(CFLAGS) -c -o $@ $<<br>
diff --git a/kpartx/Makefile b/kpartx/Makefile<br>
index e8a59f2..9441a2b 100644<br>
--- a/kpartx/Makefile<br>
+++ b/kpartx/Makefile<br>
@@ -7,9 +7,7 @@ CFLAGS += -I. -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64<br>
<br>
 LIBDEPS += -ldevmapper<br>
<br>
-LIBDM_API_COOKIE = $(shell grep -Ecs '^[a-z]*[[:space:]]+dm_task_<wbr>set_cookie' /usr/include/libdevmapper.h)<br>
-<br>
-ifneq ($(strip $(LIBDM_API_COOKIE)),0)<br>
+ifneq ($(call check_func,dm_task_set_cookie,<wbr>/usr/include/libdevmapper.h),<wbr>0)<br>
        CFLAGS += -DLIBDM_API_COOKIE<br>
 endif<br>
<br>
diff --git a/libmultipath/Makefile b/libmultipath/Makefile<br>
index 495cebe..a11e483 100644<br>
--- a/libmultipath/Makefile<br>
+++ b/libmultipath/Makefile<br>
@@ -20,27 +20,19 @@ ifdef SYSTEMD<br>
        endif<br>
 endif<br>
<br>
-LIBDM_API_FLUSH = $(shell grep -Ecs '^[a-z]*[[:space:]]+dm_task_<wbr>no_flush' /usr/include/libdevmapper.h)<br>
-<br>
-ifneq ($(strip $(LIBDM_API_FLUSH)),0)<br>
+ifneq ($(call check_func,dm_task_no_flush,/<wbr>usr/include/libdevmapper.h),0)<br>
        CFLAGS += -DLIBDM_API_FLUSH -D_GNU_SOURCE<br>
 endif<br>
<br>
-LIBDM_API_COOKIE = $(shell grep -Ecs '^[a-z]*[[:space:]]+dm_task_<wbr>set_cookie' /usr/include/libdevmapper.h)<br>
-<br>
-ifneq ($(strip $(LIBDM_API_COOKIE)),0)<br>
+ifneq ($(call check_func,dm_task_set_cookie,<wbr>/usr/include/libdevmapper.h),<wbr>0)<br>
        CFLAGS += -DLIBDM_API_COOKIE<br>
 endif<br>
<br>
-LIBUDEV_API_RECVBUF = $(shell grep -Ecs '^[a-z]*[[:space:]]+udev_<wbr>monitor_set_receive_buffer_<wbr>size' /usr/include/libudev.h)<br>
-<br>
-ifneq ($(strip $(LIBUDEV_API_RECVBUF)),0)<br>
+ifneq ($(call check_func,udev_monitor_set_<wbr>receive_buffer_size,/usr/<wbr>include/libudev.h),0)<br>
        CFLAGS += -DLIBUDEV_API_RECVBUF<br>
 endif<br>
<br>
-LIBDM_API_DEFERRED = $(shell grep -Ecs '^[a-z]*[[:space:]]+dm_task_<wbr>deferred_remove' /usr/include/libdevmapper.h)<br>
-<br>
-ifneq ($(strip $(LIBDM_API_DEFERRED)),0)<br>
+ifneq ($(call check_func,dm_task_deferred_<wbr>remove,/usr/include/<wbr>libdevmapper.h),0)<br>
        CFLAGS += -DLIBDM_API_DEFERRED<br>
 endif<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.10.1<br>
<br>
</font></span></blockquote></div><br></div>