Index: /trunk/gsdl/configure.in
===================================================================
--- /trunk/gsdl/configure.in	(revision 683)
+++ /trunk/gsdl/configure.in	(revision 684)
@@ -1,4 +1,6 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_INIT(lib/text_t.h)
+AC_CONFIG_HEADER(config.h)
+AC_ARG_PROGRAM
 
 PACKAGE=gsdl
@@ -21,8 +23,37 @@
 AC_PROG_CC
 AC_PROG_CXX
+AC_PROG_AWK
+AC_PROG_YACC
 dnl AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
 AC_PROG_RANLIB
+
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_AIX
+AC_ISC_POSIX
+AC_MINIX
+fp_C_PROTOTYPES
+AC_C_CONST
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+AC_HEADER_TIME
+AC_STRUCT_TM
+
+dnl --- This should be in the stdc checking -----------------
+if test "$ac_cv_prog_cc_stdc" = '-Xc'; then
+dnl The Pyramids running SMP_DC.OSx on MIPS r3000 chips with
+dnl /usr/opt/cc3.11/bin/cc treat -Xc as full ANSI mode - no POSIX or
+dnl XOPEN extensions (like popen).
+dnl Unfortunately -D_{XOPEN,POSIX}_SOURCE can't provide all that mg
+dnl needs. So drop back to -Xa
+AC_TRY_COMPILE(
+[#include <stdio.h>
+], [ FILE *rubbish = popen("yes", "r"); ],,
+[CC="`echo $CC | sed 's/-Xc/-Xa/'`"    ac_cv_prog_cc_stdc='-Xa'])
+fi
+dnl ----------------------
+
 
 dnl Checks for libraries.
@@ -37,11 +68,102 @@
 
 dnl Checks for header files.
+AC_HEADER_DIRENT
 AC_HEADER_STDC
-AC_CHECK_HEADERS(fcntl.h)
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_HEADER_TIME
-
+AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h string.h memory.h sys/procfs.h)
+AC_EGREP_HEADER(fread, stdio.h, AC_DEFINE(HAVE_FREAD_DECL))
+AC_EGREP_HEADER(fgetc, stdio.h, AC_DEFINE(HAVE_FGETC_DECL))
+AC_EGREP_HEADER(pr_brksize, sys/procfs.h, AC_DEFINE(HAVE_PR_BRKSIZE))
+
+dnl Checks for library functions.
+AC_FUNC_ALLOCA
+AC_PROG_GCC_TRADITIONAL
+AC_TYPE_SIGNAL
+AC_FUNC_VPRINTF
+AC_CHECK_FUNCS(ftime select strftime strtol getrusage times mallinfo setbuffer getpagesize)
+AC_REPLACE_FUNCS(ftruncate strstr strcasecmp)
+
+
+# *** Custom checking (based on GNU tar configure.in) ***
+# ---------------------------------------------------------------------------
+AC_MSG_CHECKING(for HP-UX needing gmalloc)
+if test "`(uname -s) 2> /dev/null`" = 'HP-UX'; then
+  AC_MSG_RESULT(yes)
+  LIBOBJS="$LIBOBJS gmalloc.o"
+  AC_DEFINE(HAVE_VALLOC)
+else
+  AC_MSG_RESULT(no)
+  AC_CHECK_FUNCS(valloc)
+fi
+
+fp_WITH_DMALLOC
+fp_WITH_REGEX
+
+# ---------------------------------------------------------------------------
+if test "$ac_cv_func_alloca" = 'no'; then
+dnl    support functions for alloca.c
+  LIBOBJS="$LIBOBJS xmalloc.o error.o"
+fi
+
+
+# ---------------------------------------------------------------------------
+
+dnl
+dnl Switch into C++
+dnl
+AC_LANG_CPLUSPLUS
+
+dnl
+dnl Check that the GDBM library is available
+dnl
+AC_MSG_CHECKING("that the GDBM library is available")
+AC_TRY_COMPILE(
+[#include <gdbm.h>
+],
+[],
+success=yes,
+success=no
+)
+AC_MSG_RESULT($success)
+if test $success = "no"; then
+AC_MSG_ERROR("GDBM Library not available - cannot install")
+fi
+
+dnl
+dnl Now check that Perl is actually around, and can be found
+dnl
+AC_MSG_CHECKING("that Perl 5 is available")
+success="no"
+pl_path="$PATH"
+IFS="${IFS=   }"; pl_save_ifs="$IFS"; IFS=":"
+for pl_dir in $pl_path; do
+  test -z "$pl_dir" && pl_dir=.
+  if test -x $pl_dir/perl; then
+    success="yes"
+    break
+  fi
+done
+IFS="$pl_save_ifs"
+
+dnl
+dnl Perl actually can be run; now we see if it is version 5 by
+dnl running a sample script (which returns a "clean" version number
+dnl and then tests the result using expr.  If perl errors in some
+dnl way (eg. broken Perl executable, missing script), we set a failure
+dnl value ("0") and then proceed as best we can
+dnl
+if test $success = "yes"; then
+try=`perl configtest.pl` || try="0"
+try=`expr $try \> 5.000`
+if test $try = "1"; then
+AC_MSG_RESULT("yes")
+else
+success="no"
+fi
+fi
+
+if test $success = "no"; then
+AC_MSG_RESULT("no")
+AC_MSG_ERROR("Perl 5 not available - cannot install")
+fi
 
 dnl
@@ -53,5 +175,4 @@
 dnl know now, before things really go wrong!
 dnl
-AC_LANG_CPLUSPLUS
 success=no
 AC_MSG_CHECKING("whether STL library has known faults")
@@ -89,5 +210,5 @@
 else
 AC_MSG_RESULT("yes")
-AC_MSG_ERROR("STL Broken - new not found in vector header file")
+AC_MSG_ERROR("STL Broken - Obtain newer version of GNU C Compiler")
 fi
 
@@ -95,10 +216,33 @@
 AC_SUBST(gsdlos)
 
-dnl Checks for library functions.
-AC_FUNC_VPRINTF
-
-AC_OUTPUT(src/hashfile/Makefile src/colservr/Makefile src/recpt/Makefile src/txt2db/Makefile src/db2txt/Makefile lib/Makefile collect/cstr/src/recpt/Makefile collect/niupepa/src/recpt/Makefile Makefile)
-
-
-
-
+AC_MSG_CHECKING(for HP-UX needing gmalloc)
+if test "`(uname -s) 2> /dev/null`" = 'HP-UX'; then
+  AC_MSG_RESULT(yes)
+  LIBOBJS="$LIBOBJS gmalloc.o"
+  AC_DEFINE(HAVE_VALLOC)
+else
+  AC_MSG_RESULT(no)
+  AC_CHECK_FUNCS(valloc)
+fi
+
+fp_WITH_DMALLOC
+fp_WITH_REGEX
+
+# ---------------------------------------------------------------------------
+if test "$ac_cv_func_alloca" = 'no'; then
+dnl    support functions for alloca.c
+  LIBOBJS="$LIBOBJS xmalloc.o error.o"
+fi
+
+
+# ---------------------------------------------------------------------------
+
+AC_OUTPUT(packages/mg/Makefile packages/mg/src/text/Makefile packages/mg/src/images/Makefile 
+          packages/mg/src/scripts/Makefile packages/mg/lib/Makefile
+          src/hashfile/Makefile src/colservr/Makefile src/recpt/Makefile src/txt2db/Makefile 
+          src/db2txt/Makefile lib/Makefile collect/cstr/src/recpt/Makefile 
+          collect/niupepa/src/recpt/Makefile Makefile)
+
+
+
+
