AC_INIT(readlinemod.c)
AC_CONFIG_HEADER(readline_machine.h)
AC_ARG_WITH(readline,[  --with(out)-readline   support command line editing],[],[with_readline=yes])

sinclude(../module_configure.in)

if test x$with_readline = xyes ; then
  AC_MSG_CHECKING(Checking for GNU directory)

  AC_CACHE_VAL(pike_cv_gnu_dir, [
    for pike_cv_gnu_dir in /usr/gnu /opt/gnu /usr/local/gnu /sw/gnu no; do
      if test -d $pike_cv_gnu_dir/. ; then
	break
      else
	:
      fi
    done
  ])
  AC_MSG_RESULT($pike_cv_gnu_dir)

  if test x$pike_cv_gnu_dir != xno; then
    if test -d $pike_cv_gnu_dir/include/. ; then
      echo Adding $pike_cv_gnu_dir/include to the include path
      CPPFLAGS="$CPPFLAGS -I$pike_cv_gnu_dir/include"
    else
      :
    fi
    if test -d $pike_cv_gnu_dir/lib/. ; then
      echo Adding $pike_cv_gnu_dir/lib to the runtime link path
      echo $pike_cv_gnu_dir/lib >lib_dirs
    elif test -f lib_dirs ; then
      rm lib_dirs
    else
      :
    fi
  else
    :
  fi

  AC_CHECK_HEADERS(readline.h history.h readline/readline.h history/history.h readline/history.h)

  if test $ac_cv_header_readline_h = yes -o $ac_cv_header_readline_readline_h = yes ; then
    if test $ac_cv_header_history_h = yes -o $ac_cv_header_history_history_h = yes -o $ac_cv_header_readline_history_h = yes ; then
      AC_CHECK_LIB(termcap, tputs)
      AC_CHECK_LIB(readline, readline)
    fi
  fi
fi

AC_OUTPUT(Makefile,echo FOO >stamp-h )


