[libvirt] [PATCH v2 4/7] m4: readline: Extract code setting -D_FUNCTION_DEF

Andrea Bolognani posted 7 patches 6 years, 10 months ago
[libvirt] [PATCH v2 4/7] m4: readline: Extract code setting -D_FUNCTION_DEF
Posted by Andrea Bolognani 6 years, 10 months ago
The current code is a bit awkward, and we're going to need
to share it later anyway. We can drop the call to AC_SUBST()
while we're at it, since LIBVIRT_CHECK_LIB() already marks
READLINE_CFLAGS for substitution.

The new code goes to some extra length to avoid setting
-D_FUNCTION_DEF twice: this is mostly for cosmetic reasons,
and it's necessary because LIBVIRT_CHECK_READLINE() is called
twice: once on its own, and then once more as part of
LIBVIRT_CHECK_BASH_COMPLETION().

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 m4/virt-readline.m4 | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/m4/virt-readline.m4 b/m4/virt-readline.m4
index 649a52edfa..998b891d53 100644
--- a/m4/virt-readline.m4
+++ b/m4/virt-readline.m4
@@ -63,10 +63,18 @@ AC_DEFUN([LIBVIRT_CHECK_READLINE],[
   # function, to ensure we aren't being confused by caching.
   LIBS=$lv_saved_libs
   AC_CHECK_LIB([readline], [rl_initialize],
-               [READLINE_CFLAGS="-D_FUNCTION_DEF $READLINE_CFLAGS"
-                AC_SUBST(READLINE_CFLAGS)],
+               [],
                [READLINE_LIBS="$READLINE_LIBS $extra_LIBS"])
   LIBS=$lv_saved_libs
+
+  # We need this to avoid compilation issues with modern compilers.
+  # See 9ea3424a178 for a more detailed explanation
+  if test "$with_readline" = "yes" ; then
+    case "$READLINE_CFLAGS" in
+      *-D_FUNCTION_DEF*) ;;
+      *) READLINE_CFLAGS="-D_FUNCTION_DEF $READLINE_CFLAGS" ;;
+    esac
+  fi
 ])
 
 AC_DEFUN([LIBVIRT_RESULT_READLINE],[
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 4/7] m4: readline: Extract code setting -D_FUNCTION_DEF
Posted by Daniel P. Berrangé 6 years, 10 months ago
On Tue, Apr 09, 2019 at 04:27:47PM +0200, Andrea Bolognani wrote:
> The current code is a bit awkward, and we're going to need
> to share it later anyway. We can drop the call to AC_SUBST()
> while we're at it, since LIBVIRT_CHECK_LIB() already marks
> READLINE_CFLAGS for substitution.
> 
> The new code goes to some extra length to avoid setting
> -D_FUNCTION_DEF twice: this is mostly for cosmetic reasons,
> and it's necessary because LIBVIRT_CHECK_READLINE() is called
> twice: once on its own, and then once more as part of
> LIBVIRT_CHECK_BASH_COMPLETION().

Technically theres a way to cache things so that the funcs are only
run once, but its not worth the pain of learning more m4

> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  m4/virt-readline.m4 | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list