+with_ncurses="yes"
+AC_CHECK_HEADERS(ncurses.h, [with_ncurses="yes"], [with_ncurses="no"])
+if test "x$with_ncurses" = "xyes"
+then
+ AC_CHECK_LIB(ncurses, mvwprintw, [with_ncurses="yes"], [with_ncurses="no"])
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBNCURSES, test "x$with_ncurses" = "xyes")
+
+AC_FUNC_STRERROR_R
+
+AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug], [Enable extensive debugging output.])],
+[
+ if test "x$enable_debug" = "xyes"
+ then
+ AC_DEFINE(WITH_DEBUG, 1, [Define to 1 if you want to get debugging output.])
+ fi
+], [])
+AM_CONDITIONAL(BUILD_WITH_DEBUG, test "x$enable_debug" = "xyes")
+
+AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
+[
+ if test "x$withval" != "xno" && test "x$withval" != "xyes"
+ then
+ PERL_BINDINGS_OPTIONS="$withval"
+ with_perl_bindings="yes"
+ else
+ PERL_BINDINGS_OPTIONS=""
+ with_perl_bindings="$withval"
+ fi
+],
+[
+ PERL_BINDINGS_OPTIONS=""
+ with_perl_bindings="yes"
+])
+
+if test "x$with_perl_bindings" = "xyes"
+then
+ BINDINGS="perl-bindings"
+else
+ BINDINGS=""
+fi
+
+AC_SUBST(PERL_BINDINGS_OPTIONS)
+
+AC_SUBST(BINDINGS)
+
+AC_OUTPUT(Makefile src/Makefile src/mans/Makefile bindings/Makefile)