| 1 | AC_PREREQ(2.50) |
| 2 | |
| 3 | AC_INIT |
| 4 | AC_CONFIG_SRCDIR([readline.c]) |
| 5 | . $srcdir/../GUILE-VERSION |
| 6 | PACKAGE=guile-readline |
| 7 | AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define) |
| 8 | |
| 9 | AC_PROG_INSTALL |
| 10 | AC_PROG_CC |
| 11 | AM_PROG_CC_STDC |
| 12 | AC_LIBTOOL_WIN32_DLL |
| 13 | AC_PROG_LIBTOOL |
| 14 | |
| 15 | dnl |
| 16 | dnl Check for Winsock and other functionality on Win32 (*not* CygWin) |
| 17 | dnl |
| 18 | AC_CYGWIN |
| 19 | AC_MINGW32 |
| 20 | EXTRA_DEFS="" |
| 21 | if test "$MINGW32" = "yes" ; then |
| 22 | if test $enable_shared = yes ; then |
| 23 | EXTRA_DEFS="-DSCM_IMPORT" |
| 24 | fi |
| 25 | fi |
| 26 | AC_SUBST(EXTRA_DEFS) |
| 27 | |
| 28 | for termlib in ncurses curses termcap terminfo termlib ; do |
| 29 | AC_CHECK_LIB(${termlib}, tgoto, |
| 30 | [LIBS="-l${termlib} $LIBS"; break]) |
| 31 | done |
| 32 | |
| 33 | AC_CHECK_LIB(readline, readline) |
| 34 | if test $ac_cv_lib_readline_readline = no; then |
| 35 | AC_MSG_WARN([libreadline was not found on your system.]) |
| 36 | fi |
| 37 | |
| 38 | AC_CHECK_FUNCS(siginterrupt rl_clear_signals rl_cleanup_after_signal) |
| 39 | |
| 40 | dnl Check for modern readline naming |
| 41 | AC_CHECK_FUNCS(rl_filename_completion_function) |
| 42 | |
| 43 | dnl Check for rl_pre_input_hook. This is more complicated because on |
| 44 | dnl some systems (HP/UX), the linker wont let us treat |
| 45 | dnl rl_pre_input_hook as a function when it really is a function |
| 46 | dnl pointer. |
| 47 | |
| 48 | AC_MSG_CHECKING([for rl_pre_input_hook]) |
| 49 | AC_CACHE_VAL(ac_cv_var_rl_pre_input_hook, |
| 50 | [AC_TRY_LINK([ |
| 51 | #include <stdio.h> |
| 52 | #include <readline/readline.h> |
| 53 | ], [ |
| 54 | rl_pre_input_hook = 0; |
| 55 | ], |
| 56 | ac_cv_var_rl_pre_input_hook=yes, |
| 57 | ac_cv_var_rl_pre_input_hook=no)]) |
| 58 | AC_MSG_RESULT($ac_cv_var_rl_pre_input_hook) |
| 59 | if test $ac_cv_var_rl_pre_input_hook = yes; then |
| 60 | AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK) |
| 61 | fi |
| 62 | |
| 63 | |
| 64 | AC_MSG_CHECKING(if readline clears SA_RESTART flag for SIGWINCH) |
| 65 | AC_CACHE_VAL(guile_cv_sigwinch_sa_restart_cleared, |
| 66 | AC_TRY_RUN([#include <signal.h> |
| 67 | #include <stdio.h> |
| 68 | #include <readline/readline.h> |
| 69 | |
| 70 | int |
| 71 | hook () |
| 72 | { |
| 73 | struct sigaction action; |
| 74 | |
| 75 | sigaction (SIGWINCH, NULL, &action); |
| 76 | rl_cleanup_after_signal(); |
| 77 | |
| 78 | /* exit with 0 if readline disabled SA_RESTART */ |
| 79 | exit (action.sa_flags & SA_RESTART); |
| 80 | } |
| 81 | |
| 82 | int |
| 83 | main () |
| 84 | { |
| 85 | struct sigaction action; |
| 86 | |
| 87 | sigaction (SIGWINCH, NULL, &action); |
| 88 | action.sa_flags |= SA_RESTART; |
| 89 | sigaction (SIGWINCH, &action, NULL); |
| 90 | |
| 91 | /* Give readline something to read. Otherwise, it might hang, for |
| 92 | example when run as a background process with job control. |
| 93 | */ |
| 94 | rl_instream = fopen ("/dev/null", "r"); |
| 95 | if (rl_instream == NULL) |
| 96 | { |
| 97 | perror ("/dev/null"); |
| 98 | exit (1); |
| 99 | } |
| 100 | |
| 101 | rl_pre_input_hook = hook; |
| 102 | readline (""); |
| 103 | }], |
| 104 | guile_cv_sigwinch_sa_restart_cleared=yes, |
| 105 | guile_cv_sigwinch_sa_restart_cleared=no, |
| 106 | guile_cv_sigwinch_sa_restart_cleared=yes)) |
| 107 | AC_MSG_RESULT($guile_cv_sigwinch_sa_restart_cleared) |
| 108 | if test $guile_cv_sigwinch_sa_restart_cleared = yes; then |
| 109 | AC_DEFINE(GUILE_SIGWINCH_SA_RESTART_CLEARED) |
| 110 | fi |
| 111 | |
| 112 | AC_CACHE_CHECK([for rl_getc_function pointer in readline], |
| 113 | ac_cv_var_rl_getc_function, |
| 114 | [AC_TRY_LINK([ |
| 115 | #include <stdio.h> |
| 116 | #include <readline/readline.h>], |
| 117 | [printf ("%ld", (long) rl_getc_function)], |
| 118 | [ac_cv_var_rl_getc_function=yes], |
| 119 | [ac_cv_var_rl_getc_function=no])]) |
| 120 | if test "${ac_cv_var_rl_getc_function}" = "yes"; then |
| 121 | AC_DEFINE(HAVE_RL_GETC_FUNCTION, 1, |
| 122 | [Define if your readline library has the rl_getc_function variable.]) |
| 123 | fi |
| 124 | |
| 125 | if test $ac_cv_lib_readline_readline = yes \ |
| 126 | -a $ac_cv_var_rl_getc_function = no; then |
| 127 | AC_MSG_WARN([*** libreadline is too old on your system.]) |
| 128 | AC_MSG_WARN([*** You need readline version 2.1 or later.]) |
| 129 | fi |
| 130 | |
| 131 | AC_CHECK_FUNCS(strdup) |
| 132 | |
| 133 | . $srcdir/LIBGUILEREADLINE-VERSION |
| 134 | AC_SUBST(LIBGUILEREADLINE_INTERFACE_CURRENT) |
| 135 | AC_SUBST(LIBGUILEREADLINE_INTERFACE_REVISION) |
| 136 | AC_SUBST(LIBGUILEREADLINE_INTERFACE_AGE) |
| 137 | AC_SUBST(LIBGUILEREADLINE_INTERFACE) |
| 138 | |
| 139 | AC_SUBST(GUILE_EFFECTIVE_VERSION) |
| 140 | |
| 141 | AC_CONFIG_FILES(Makefile) |
| 142 | AC_OUTPUT |