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>
bup_have_readline=''
bup_readline_includes_in_subdir=''
bup_readline_via_pkg_config=''
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 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
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
then
bup_have_readline=1
fi
fi
fi
if ! test "$bup_have_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
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
bup_readline_ldflags=-lreadline
bup_have_readline=1
fi