All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe Varoqui <christophe.varoqui@opensvc.com>
To: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: device-mapper development <dm-devel@redhat.com>
Subject: Re: [PATCH] Makefiles: Fix function availability checks
Date: Sun, 20 Nov 2016 14:40:05 +0100	[thread overview]
Message-ID: <CABr-GnckhrCEK2P-WH90zmZ6nq8WihgwjqoajHp4x=0CzXwbPw@mail.gmail.com> (raw)
In-Reply-To: <1c628eb2-589d-d8b8-952c-d64c5e74d785@sandisk.com>


[-- Attachment #1.1: Type: text/plain, Size: 3854 bytes --]

Very nice, thanks.
Merged.

On Fri, Nov 18, 2016 at 8:52 PM, Bart Van Assche <bart.vanassche@sandisk.com
> wrote:

> The current implementation of the code that checks for function
> presence is not correct because it checks for a prefix match only.
> Introduce a function that checks for the exact function name.
> Additionally, report whether or not the function has been found.
> An example of the output produced by this function if 'make' is
> run:
>
> Checking for dm_task_no_flush in /usr/include/libdevmapper.h ... yes
> Checking for dm_task_set_cookie in /usr/include/libdevmapper.h ... yes
> Checking for udev_monitor_set_receive_buffer_size in
> /usr/include/libudev.h ... yes
> Checking for dm_task_deferred_remove in /usr/include/libdevmapper.h ... yes
>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> ---
>  Makefile.inc          | 14 ++++++++++++++
>  kpartx/Makefile       |  4 +---
>  libmultipath/Makefile | 16 ++++------------
>  3 files changed, 19 insertions(+), 15 deletions(-)
>
> diff --git a/Makefile.inc b/Makefile.inc
> index 1cc8f44..e7f4e05 100644
> --- a/Makefile.inc
> +++ b/Makefile.inc
> @@ -69,5 +69,19 @@ OPTFLAGS     = -O2 -g -pipe -Wall -Wextra -Wformat=2 \
>  CFLAGS         = $(OPTFLAGS) -fPIC -DLIB_STRING=\"${LIB}\"
> -DRUN_DIR=\"${RUN}\"
>  SHARED_FLAGS   = -shared
>
> +# Check whether a function with name $1 has been declared in header file
> $2.
> +check_func =
>     \
> +    $(shell
>      \
> +       if grep -Eq "^[^[:blank:]]+[[:blank:]]+$1[[:blank:]]*(.*)*" "$2";
> then \
> +          found=1;
>     \
> +          status="yes";
>      \
> +       else
>      \
> +          found=0;
>     \
> +          status="no";
>     \
> +       fi;
>     \
> +       echo 1>&2 "Checking for $1 in $2 ... $$status";
>     \
> +       echo "$$found"
>      \
> +    )
> +
>  %.o:   %.c
>         $(CC) $(CFLAGS) -c -o $@ $<
> diff --git a/kpartx/Makefile b/kpartx/Makefile
> index e8a59f2..9441a2b 100644
> --- a/kpartx/Makefile
> +++ b/kpartx/Makefile
> @@ -7,9 +7,7 @@ CFLAGS += -I. -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
>
>  LIBDEPS += -ldevmapper
>
> -LIBDM_API_COOKIE = $(shell grep -Ecs '^[a-z]*[[:space:]]+dm_task_set_cookie'
> /usr/include/libdevmapper.h)
> -
> -ifneq ($(strip $(LIBDM_API_COOKIE)),0)
> +ifneq ($(call check_func,dm_task_set_cookie,/usr/include/libdevmapper.h),
> 0)
>         CFLAGS += -DLIBDM_API_COOKIE
>  endif
>
> diff --git a/libmultipath/Makefile b/libmultipath/Makefile
> index 495cebe..a11e483 100644
> --- a/libmultipath/Makefile
> +++ b/libmultipath/Makefile
> @@ -20,27 +20,19 @@ ifdef SYSTEMD
>         endif
>  endif
>
> -LIBDM_API_FLUSH = $(shell grep -Ecs '^[a-z]*[[:space:]]+dm_task_no_flush'
> /usr/include/libdevmapper.h)
> -
> -ifneq ($(strip $(LIBDM_API_FLUSH)),0)
> +ifneq ($(call check_func,dm_task_no_flush,/usr/include/libdevmapper.h),0)
>         CFLAGS += -DLIBDM_API_FLUSH -D_GNU_SOURCE
>  endif
>
> -LIBDM_API_COOKIE = $(shell grep -Ecs '^[a-z]*[[:space:]]+dm_task_set_cookie'
> /usr/include/libdevmapper.h)
> -
> -ifneq ($(strip $(LIBDM_API_COOKIE)),0)
> +ifneq ($(call check_func,dm_task_set_cookie,/usr/include/libdevmapper.h),
> 0)
>         CFLAGS += -DLIBDM_API_COOKIE
>  endif
>
> -LIBUDEV_API_RECVBUF = $(shell grep -Ecs '^[a-z]*[[:space:]]+udev_
> monitor_set_receive_buffer_size' /usr/include/libudev.h)
> -
> -ifneq ($(strip $(LIBUDEV_API_RECVBUF)),0)
> +ifneq ($(call check_func,udev_monitor_set_receive_buffer_size,/usr/
> include/libudev.h),0)
>         CFLAGS += -DLIBUDEV_API_RECVBUF
>  endif
>
> -LIBDM_API_DEFERRED = $(shell grep -Ecs '^[a-z]*[[:space:]]+dm_task_deferred_remove'
> /usr/include/libdevmapper.h)
> -
> -ifneq ($(strip $(LIBDM_API_DEFERRED)),0)
> +ifneq ($(call check_func,dm_task_deferred_remove,/usr/include/
> libdevmapper.h),0)
>         CFLAGS += -DLIBDM_API_DEFERRED
>  endif
>
> --
> 2.10.1
>
>

[-- Attachment #1.2: Type: text/html, Size: 5675 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



      reply	other threads:[~2016-11-20 13:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-18 19:52 [PATCH] Makefiles: Fix function availability checks Bart Van Assche
2016-11-20 13:40 ` Christophe Varoqui [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABr-GnckhrCEK2P-WH90zmZ6nq8WihgwjqoajHp4x=0CzXwbPw@mail.gmail.com' \
    --to=christophe.varoqui@opensvc.com \
    --cc=bart.vanassche@sandisk.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.