]> arthur.barton.de Git - bup.git/commitdiff
configure: test for functional readline more carefully
authorRob Browning <rlb@defaultvalue.org>
Sun, 21 Jun 2020 17:46:50 +0000 (12:46 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 5 Jul 2020 16:16:23 +0000 (11:16 -0500)
Apparently on (cirrus) macos, just testing for the ability to compile
readline.h isn't sufficient because configure ends up selecting the
built-in readline (which is insufficient) rather than the one we
specifically installed via brew.  More specifically, the built-in
readline has the wrong prototype for rl_completion_entry_function
which causes this error:

  _helpers.c:2096:38: error: incompatible function pointer types assigning to 'Function *' (aka 'int (*)(const char *, int)') from 'char *(const char *, int)' [-Werror,-Wincompatible-function-pointer-types]
        rl_completion_entry_function = on_completion_entry;
                                     ^ ~~~~~~~~~~~~~~~~~~~~

So change the test for an acceptable readline to check that
specifically, which is a better test for all the platforms.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
config/configure

index 33670dd45ed12584e3612a8eacd0cbe676e194a2..916bec371ea8864f563e5b422aa6962ef374cbfc 100755 (executable)
@@ -179,17 +179,26 @@ TLOGN "checking for readline"
 bup_have_readline=''
 bup_readline_includes_in_subdir=''
 bup_readline_via_pkg_config=''
+# We test this specific thing because it should work everywhere and it was
+# a particulary problem on macos (we'd get the wrong includes if we just
+# tested that the includes work).
+readline_test_code='
+  static char *on_completion_entry(const char *text, int state) { return NULL; }
+  void bup_test(void) { rl_completion_entry_function = on_completion_entry; }
+'
 if pkg-config readline; then
     bup_readline_cflags="$(pkg-config readline --cflags)" || exit $?
     bup_readline_ldflags="$(pkg-config readline --libs)" || exit $?
     # It looks like it's not uncommon for pkg-config to provide a -I
     # that doesn't support the documentation's specified #include
     # <readline/readline.h>.  See what's really going on.
-    if bup_try_c_code '#include <readline/readline.h>' "$bup_readline_cflags"
+    if bup_try_c_code "#include <readline/readline.h> $readline_test_code" \
+                      "$bup_readline_cflags"
     then
         bup_have_readline=1
         bup_readline_includes_in_subdir=1
-    elif bup_try_c_code '#include <readline.h>' "$bup_readline_cflags"
+    elif bup_try_c_code "#include <readline.h> $readline_test_code" \
+                        "$bup_readline_cflags"
     then
         bup_have_readline=1
     fi
@@ -201,11 +210,11 @@ if pkg-config readline; then
     fi
 fi
 if ! test "$bup_have_readline"; then
-    if bup_try_c_code '#include <readline/readline.h>'; then
+    if bup_try_c_code "#include <readline/readline.h> $readline_test_code"; then
         bup_readline_ldflags=-lreadline
         bup_have_readline=1
         bup_readline_includes_in_subdir=1
-    elif bup_try_c_code '#include <readline.h>'; then
+    elif bup_try_c_code "#include <readline.h> $readline_test_code"; then
         bup_readline_ldflags=-lreadline
         bup_have_readline=1
     fi