From: Rob Browning Date: Sun, 21 Jun 2020 17:46:50 +0000 (-0500) Subject: configure: test for functional readline more carefully X-Git-Tag: 0.31~33 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=8f1a5aace7788ee23fb67530252ba434f35e7c51 configure: test for functional readline more carefully 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 Tested-by: Rob Browning --- diff --git a/config/configure b/config/configure index 33670dd..916bec3 100755 --- a/config/configure +++ b/config/configure @@ -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 # . See what's really going on. - if bup_try_c_code '#include ' "$bup_readline_cflags" + if bup_try_c_code "#include $readline_test_code" \ + "$bup_readline_cflags" then bup_have_readline=1 bup_readline_includes_in_subdir=1 - elif bup_try_c_code '#include ' "$bup_readline_cflags" + elif bup_try_c_code "#include $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 '; then + if bup_try_c_code "#include $readline_test_code"; then bup_readline_ldflags=-lreadline bup_have_readline=1 bup_readline_includes_in_subdir=1 - elif bup_try_c_code '#include '; then + elif bup_try_c_code "#include $readline_test_code"; then bup_readline_ldflags=-lreadline bup_have_readline=1 fi