--- configure.in.old Sat Aug 5 17:59:40 2000 +++ configure.in Sat Aug 5 19:10:39 2000 @@ -387,9 +387,59 @@ elif test "$WITH_READLINE" = "maybe"; then AC_CHECK_HEADER(readline/readline.h, have_readline_h=1, have_readline_h=0) if test "$have_readline_h" = "1"; then - AC_CHECK_LIB(readline, rl_callback_handler_install, - [SERVER_LIBS="-lreadline $SERVER_LIBS" - AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE)], , $SERVER_LIBS) + AC_CHECK_LIB(readline, rl_callback_handler_install, have_readline_lib=1, have_readline_lib=0) + if test "$have_readline_lib" = "1"; then + AC_MSG_CHECKING(whether readline hates ncurses) + templibs="$LIBS" + LIBS="-lreadline $LIBS" + AC_TRY_RUN([ +/* + * testrl.c + * File revision 0 + * Check to make sure that readline and ncurses play well. + * (c) 2000 Jacob Lundberg, jacob@xxxxxxxxxx + */ + +#include +/* We assume that the presence of readline has already been verified. */ +#include +#include + +/* Setup for readline. */ +#define TEMP_FILE "./conftest.readline.ncurses" +static char *history_file = NULL; +static int readline_handled_input = 0; + +static void handle_readline_input_callback(char *line) { +/* Generally taken from freeciv-1.11.4/server/sernet.c. */ + if(line) { + if(*line) + add_history(line); + printf(line); + } + readline_handled_input = 1; +} + +int main(void) { +/* Try to init readline and see if it barfs. */ + using_history(); + read_history(TEMP_FILE); + rl_initialize(); + rl_callback_handler_install(":-) ", handle_readline_input_callback); + return(0); +} + ], + [AC_MSG_RESULT(no) + SERVER_LIBS="-lreadline $SERVER_LIBS" + AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE)], + [AC_MSG_RESULT(yes) + AC_MSG_WARN(Readline is broken and will not be used.) + AC_MSG_WARN(You probably need to get a newer readline package.)], + [AC_MSG_RESULT(unknown: cross-compiling) + SERVER_LIBS="-lreadline $SERVER_LIBS" + AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE)]) + LIBS="$templibs" + fi fi fi fi