+dnl --- *@-mdw_DECL_ENVIRON-@* ---
+dnl
+dnl Author: Mark Wooding
+dnl
+dnl Synopsis: mdw_DECL_ENVIRON
+dnl
+dnl Arguments: ---
+dnl
+dnl Use: If the global variable `environ' is declared anywhere
+dnl `obvious', then define the preprocessor symbol DECL_ENVIRON.
+
+AC_DEFUN(mdw_DECL_ENVIRON,
+[AC_CHECK_HEADERS([unistd.h])
+AC_CACHE_CHECK([for declaration of \`environ'], sw_cv_environ,
+[AC_EGREP_CPP(environ,
+[#include <sys/types.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif], [sw_cv_environ=yes], [sw_cv_environ=no])])
+if test $sw_cv_environ = yes; then
+ AC_DEFINE(DECL_ENVIRON)
+fi])
+
+dnl --- *@-mdw_CURSES-@* ---
+dnl
+dnl Author: Mark Wooding
+dnl
+dnl Synopsis: mdw_CURSES
+dnl
+dnl Arguments: ---
+dnl
+dnl Use: Attempts to find an implementation of `curses'. A `curses'
+dnl library (`ncurses' by preference) will be added to `LIBS'.
+dnl If a library could be found, the preprocessor symbol
+dnl HAVE_CURSES is defined, along with one of HAVE_NCURSES_H,
+dnl HAVE_NCURSES_NCURSES_H or HAVE_CURSES_H, suggesting which
+dnl header to include (in the obvious way).
+
+AC_DEFUN(mdw_CURSES,
+[mdw_CHECK_MANYLIBS(newwin, ncurses curses, AC_DEFINE(HAVE_CURSES))
+if test $mdw_cv_lib_newwin != no; then
+AC_CHECK_HEADERS([ncurses.h ncurses/ncurses.h curses.h], [break])
+if test "$ac_cv_header_ncurses_h" = "no" &&
+ test "$ac_cv_header_ncurses_ncurses_h" = "no" &&
+ test "$ac_cv_header_curses_h" = "no"; then
+ AC_MSG_WARN([couldn't find a \`curses' header. Assuming \`curses.h'.])
+ AC_DEFINE(HAVE_CURSES_H)
+fi
+AC_CHECK_FUNCS(wresize)
+fi])
+
+dnl --- *@-mdw_TYPE_SSIZE_T-@* ---
+dnl
+dnl Author: Mark Wooding
+dnl
+dnl Synopsis: mdw_TYPE_SSIZE_T
+dnl
+dnl Arguments: ---
+dnl
+dnl Use: Finds an appropriate type for `ssize_t' if there isn't a
+dnl sensible one to use already.
+
+AC_DEFUN(mdw_TYPE_SSIZE_T,
+[AC_CACHE_CHECK(for ssize_t, sw_cv_ssize_t,
+[AC_EGREP_CPP(ssize_t,
+[#include <sys/types.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif],
+[sw_cv_ssize_t=yes], [sw_cv_ssize_t=no])])
+if test $sw_cv_ssize_t = no; then
+ AC_DEFINE(ssize_t, int)
+fi])
+