]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
m4: readline: Extract code setting -D_FUNCTION_DEF
authorAndrea Bolognani <abologna@redhat.com>
Mon, 8 Apr 2019 14:39:57 +0000 (16:39 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 12 Apr 2019 14:22:23 +0000 (16:22 +0200)
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>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
m4/virt-readline.m4

index 649a52edfa3ffee1f6f120244bfe9d82336ebebc..998b891d53bd1d5b359ff6a97cb877fa4f4f67e4 100644 (file)
@@ -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],[