From b0c3c48eb3779d9637a03c455f3934d9d7c08030 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Sat, 27 Jul 2002 20:10:05 +0000
Subject: [PATCH] Assemble portability modules into libpgport library. Some
 makefile simplifications.

---
 config/c-library.m4                      |   26 +-
 configure                                | 1906 +++++++---------------
 configure.in                             |   88 +-
 contrib/pg_controldata/Makefile          |    8 +-
 contrib/pg_resetxlog/Makefile            |    8 +-
 doc/FAQ_Solaris                          |   14 +-
 src/Makefile                             |    5 +-
 src/Makefile.global.in                   |   32 +-
 src/Makefile.shlib                       |    4 +-
 src/backend/Makefile                     |   16 +-
 src/backend/port/Makefile                |   10 +-
 src/backend/port/inet_aton.c             |  152 --
 src/bin/pg_dump/Makefile                 |   18 +-
 src/bin/pg_encoding/Makefile             |   23 +-
 src/bin/psql/Makefile                    |   21 +-
 src/interfaces/ecpg/preproc/Makefile     |   15 +-
 src/interfaces/libpgtcl/Makefile         |    8 +-
 src/interfaces/libpq++/examples/Makefile |    4 +-
 src/interfaces/libpq/Makefile            |   18 +-
 src/makefiles/Makefile.win               |    3 +-
 src/port/Makefile                        |   15 +-
 src/port/inet_aton.h                     |    3 -
 src/utils/Makefile                       |   18 +
 src/{backend/port => utils}/dllinit.c    |    0
 24 files changed, 731 insertions(+), 1684 deletions(-)
 delete mode 100644 src/backend/port/inet_aton.c
 delete mode 100644 src/port/inet_aton.h
 create mode 100644 src/utils/Makefile
 rename src/{backend/port => utils}/dllinit.c (100%)

diff --git a/config/c-library.m4 b/config/c-library.m4
index 10a91d43b4f..0a5d844d879 100644
--- a/config/c-library.m4
+++ b/config/c-library.m4
@@ -1,5 +1,5 @@
 # Macros that test various C library quirks
-# $Header: /cvsroot/pgsql/config/c-library.m4,v 1.13 2002/03/30 00:59:52 petere Exp $
+# $Header: /cvsroot/pgsql/config/c-library.m4,v 1.14 2002/07/27 20:10:03 petere Exp $
 
 
 # PGAC_VAR_INT_TIMEZONE
@@ -36,30 +36,6 @@ if test x"$pgac_cv_func_gettimeofday_1arg" = xyes ; then
 fi])# PGAC_FUNC_GETTIMEOFDAY_1ARG
 
 
-# PGAC_FUNC_MEMCMP
-# ----------------
-# Check if memcmp() properly handles negative bytes and returns +/-.
-# SunOS does not.
-# AC_FUNC_MEMCMP
-AC_DEFUN([PGAC_FUNC_MEMCMP],
-[AC_CACHE_CHECK(for 8-bit clean memcmp, pgac_cv_func_memcmp_clean,
-[AC_TRY_RUN([
-main()
-{
-  char c0 = 0x40, c1 = 0x80, c2 = 0x81;
-  exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1);
-}
-], pgac_cv_func_memcmp_clean=yes, pgac_cv_func_memcmp_clean=no,
-pgac_cv_func_memcmp_clean=no)])
-if test $pgac_cv_func_memcmp_clean = no ; then
-  MEMCMP=memcmp.o
-else
-  MEMCMP=
-fi
-AC_SUBST(MEMCMP)dnl
-])
-
-
 # PGAC_UNION_SEMUN
 # ----------------
 # Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
diff --git a/configure b/configure
index 18743ba3650..77bcc1993eb 100755
--- a/configure
+++ b/configure
@@ -7365,6 +7365,7 @@ fi
 ##
 ## Header files
 ##
+
 echo "$as_me:$LINENO: checking for ANSI C header files" >&5
 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
 if test "${ac_cv_header_stdc+set}" = set; then
@@ -9127,6 +9128,7 @@ fi
 ## Types, structures, compiler characteristics
 ##
 
+
 echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
 if test "${ac_cv_c_const+set}" = set; then
@@ -10203,6 +10205,7 @@ fi
 ##
 ## Functions, global variables
 ##
+
 echo "$as_me:$LINENO: checking for int timezone" >&5
 echo $ECHO_N "checking for int timezone... $ECHO_C" >&6
 if test "${pgac_cv_var_int_timezone+set}" = set; then
@@ -10404,24 +10407,55 @@ _ACEOF
 fi
 
 # SunOS doesn't handle negative byte comparisons properly with +/- return
-echo "$as_me:$LINENO: checking for 8-bit clean memcmp" >&5
-echo $ECHO_N "checking for 8-bit clean memcmp... $ECHO_C" >&6
-if test "${pgac_cv_func_memcmp_clean+set}" = set; then
+echo "$as_me:$LINENO: checking for working memcmp" >&5
+echo $ECHO_N "checking for working memcmp... $ECHO_C" >&6
+if test "${ac_cv_func_memcmp_working+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test "$cross_compiling" = yes; then
-  pgac_cv_func_memcmp_clean=no
+  ac_cv_func_memcmp_working=no
 else
   cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
 
-main()
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
 {
+
+  /* Some versions of memcmp are not 8-bit clean.  */
   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
-  exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1);
-}
+  if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
+    exit (1);
+
+  /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
+     or more and with at least one buffer not starting on a 4-byte boundary.
+     William Lewis provided this test program.   */
+  {
+    char foo[21];
+    char bar[21];
+    int i;
+    for (i = 0; i < 4; i++)
+      {
+        char *a = foo + i;
+        char *b = bar + i;
+        strcpy (a, "--------01111111");
+        strcpy (b, "--------10000000");
+        if (memcmp (a, b, 16) >= 0)
+          exit (1);
+      }
+    exit (0);
+  }
 
+  ;
+  return 0;
+}
 _ACEOF
 rm -f conftest$ac_exeext
 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
@@ -10434,24 +10468,20 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  pgac_cv_func_memcmp_clean=yes
+  ac_cv_func_memcmp_working=yes
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
 ( exit $ac_status )
-pgac_cv_func_memcmp_clean=no
+ac_cv_func_memcmp_working=no
 fi
 rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
-echo "$as_me:$LINENO: result: $pgac_cv_func_memcmp_clean" >&5
-echo "${ECHO_T}$pgac_cv_func_memcmp_clean" >&6
-if test $pgac_cv_func_memcmp_clean = no ; then
-  MEMCMP=memcmp.o
-else
-  MEMCMP=
-fi
+echo "$as_me:$LINENO: result: $ac_cv_func_memcmp_working" >&5
+echo "${ECHO_T}$ac_cv_func_memcmp_working" >&6
+test $ac_cv_func_memcmp_working = no && LIBOBJS="$LIBOBJS memcmp.$ac_objext"
 
 
 
@@ -10670,7 +10700,7 @@ fi
 # also decide to use snprintf.c if snprintf() is present but does not
 # have working "long long int" support -- see below.
 
-SNPRINTF=''
+pgac_need_repl_snprintf=no
 
 for ac_func in snprintf
 do
@@ -10745,7 +10775,7 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
 _ACEOF
 
 else
-  SNPRINTF='$(top_builddir)/src/port/snprintf.o'
+  pgac_need_repl_snprintf=yes
 fi
 done
 
@@ -10823,13 +10853,12 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
 _ACEOF
 
 else
-  SNPRINTF='$(top_builddir)/src/port/snprintf.o'
+  pgac_need_repl_snprintf=yes
 fi
 done
 
 
 
-
 # Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
 # include/c.h will provide declarations.  Note this is a separate test
 # from whether the functions exist in the C library --- there are
@@ -11017,9 +11046,8 @@ cat >>confdefs.h <<\_ACEOF
 #define HAVE_ISINF 1
 _ACEOF
 
-  ISINF=
 else
-  ISINF='isinf.o'
+  LIBOBJS="$LIBOBJS isinf.$ac_objext"
   # Look for a way to implement a substitute for isinf()
 
 
@@ -11105,7 +11133,14 @@ fi
 
 
 
-for ac_func in getrusage
+
+
+
+
+
+
+
+for ac_func in gethostname getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -11178,13 +11213,30 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
 _ACEOF
 
 else
-  GETRUSAGE='$(top_builddir)/src/port/getrusage.o'
+  LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
 fi
 done
 
 
 
-for ac_func in srandom
+# Solaris has a very slow qsort in certain cases.
+case $host_os in
+  solaris*) LIBOBJS="$LIBOBJS qsort.$ac_objext" ;;
+esac
+
+# On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
+# this hackery with HPUXMATHLIB allows us to cope.
+HPUXMATHLIB=""
+case $host_cpu in
+  hppa1.1)
+	if [ -r /lib/pa1.1/libm.a ] ; then
+	    HPUXMATHLIB="-L /lib/pa1.1 -lm"
+	fi ;;
+esac
+
+
+
+for ac_func in rint
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -11257,35 +11309,24 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
 _ACEOF
 
 else
-  SRANDOM='$(top_builddir)/src/port/srandom.o'
-fi
-done
-
-
-
-for ac_func in gethostname
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for rint in -lm" >&5
+echo $ECHO_N "checking for rint in -lm... $ECHO_C" >&6
+if test "${ac_cv_lib_m_rint+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lm $HPUXMATHLIB $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
+
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
 extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
-
+char rint ();
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
      extern "C"
@@ -11295,15 +11336,7 @@ char (*f) ();
 int
 main ()
 {
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func;
-#endif
-
+rint ();
   ;
   return 0;
 }
@@ -11320,50 +11353,41 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
+  ac_cv_lib_m_rint=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-eval "$as_ac_var=no"
+ac_cv_lib_m_rint=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+echo "$as_me:$LINENO: result: $ac_cv_lib_m_rint" >&5
+echo "${ECHO_T}$ac_cv_lib_m_rint" >&6
+if test $ac_cv_lib_m_rint = yes; then
+  cat >>confdefs.h <<\_ACEOF
+#define HAVE_RINT 1
 _ACEOF
 
-else
-  GETHOSTNAME='$(top_builddir)/src/port/gethostname.o'
+fi
+
 fi
 done
 
 
 
-for ac_func in random
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
+if test "$with_readline" = yes; then
+  echo "$as_me:$LINENO: checking for rl_completion_append_character" >&5
+echo $ECHO_N "checking for rl_completion_append_character... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
+#include <stdio.h>
+#ifdef HAVE_READLINE_READLINE_H
+# include <readline/readline.h>
+#elif defined(HAVE_READLINE_H)
+# include <readline.h>
 #endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
 
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
@@ -11374,15 +11398,7 @@ char (*f) ();
 int
 main ()
 {
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func;
-#endif
-
+rl_completion_append_character = 'x';
   ;
   return 0;
 }
@@ -11399,29 +11415,23 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_RL_COMPLETION_APPEND_CHARACTER 1
+_ACEOF
+
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-eval "$as_ac_var=no"
+echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-else
-  MISSING_RANDOM='$(top_builddir)/src/port/random.o'
-fi
-done
 
 
-
-for ac_func in inet_aton
+for ac_func in rl_completion_matches rl_filename_completion_function
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -11493,36 +11503,18 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
-else
-  INET_ATON='$(top_builddir)/src/port/inet_aton.o'
 fi
 done
 
+fi
 
 
-for ac_func in strerror
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
+echo "$as_me:$LINENO: checking for finite" >&5
+echo $ECHO_N "checking for finite... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
-
+#include <math.h>
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
      extern "C"
@@ -11532,15 +11524,7 @@ char (*f) ();
 int
 main ()
 {
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func;
-#endif
-
+int dummy=finite(1.0);
   ;
   return 0;
 }
@@ -11557,51 +11541,27 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_FINITE 1
+_ACEOF
+
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-eval "$as_ac_var=no"
+echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-else
-  STRERROR='$(top_builddir)/src/port/strerror.o'
-fi
-done
-
-
 
-for ac_func in strdup
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
+echo "$as_me:$LINENO: checking for sigsetjmp" >&5
+echo $ECHO_N "checking for sigsetjmp... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
-
+#include <setjmp.h>
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
      extern "C"
@@ -11611,15 +11571,7 @@ char (*f) ();
 int
 main ()
 {
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func;
-#endif
-
+sigjmp_buf x; sigsetjmp(x, 1);
   ;
   return 0;
 }
@@ -11636,41 +11588,31 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-eval "$as_ac_var=no"
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SIGSETJMP 1
 _ACEOF
 
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
 else
-  STRDUP='$(top_builddir)/src/port/strdup.o'
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
-done
-
-
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
-for ac_func in strtol
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
+echo "$as_me:$LINENO: checking for syslog" >&5
+echo $ECHO_N "checking for syslog... $ECHO_C" >&6
+if test "${ac_cv_func_syslog+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
+    which can conflict with char syslog (); below.  */
 #include <assert.h>
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
@@ -11678,7 +11620,7 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char $ac_func ();
+char syslog ();
 char (*f) ();
 
 #ifdef F77_DUMMY_MAIN
@@ -11693,10 +11635,10 @@ main ()
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+#if defined (__stub_syslog) || defined (__stub___syslog)
 choke me
 #else
-f = $ac_func;
+f = syslog;
 #endif
 
   ;
@@ -11715,29 +11657,185 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
+  ac_cv_func_syslog=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-eval "$as_ac_var=no"
+ac_cv_func_syslog=no
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+echo "$as_me:$LINENO: result: $ac_cv_func_syslog" >&5
+echo "${ECHO_T}$ac_cv_func_syslog" >&6
+if test $ac_cv_func_syslog = yes; then
+  if test "${ac_cv_header_syslog_h+set}" = set; then
+  echo "$as_me:$LINENO: checking for syslog.h" >&5
+echo $ECHO_N "checking for syslog.h... $ECHO_C" >&6
+if test "${ac_cv_header_syslog_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_syslog_h" >&5
+echo "${ECHO_T}$ac_cv_header_syslog_h" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking syslog.h usability" >&5
+echo $ECHO_N "checking syslog.h usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+$ac_includes_default
+#include <syslog.h>
 _ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
 
+# Is the header present?
+echo "$as_me:$LINENO: checking syslog.h presence" >&5
+echo $ECHO_N "checking syslog.h presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+#include <syslog.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
 else
-  STRTOL='$(top_builddir)/src/port/strtol.o'
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: syslog.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: syslog.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: syslog.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: syslog.h: proceeding with the preprocessor's result" >&2;};;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: syslog.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: syslog.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: syslog.h: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: syslog.h: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: syslog.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: syslog.h: proceeding with the preprocessor's result" >&2;};;
+esac
+echo "$as_me:$LINENO: checking for syslog.h" >&5
+echo $ECHO_N "checking for syslog.h... $ECHO_C" >&6
+if test "${ac_cv_header_syslog_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_header_syslog_h=$ac_header_preproc
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_syslog_h" >&5
+echo "${ECHO_T}$ac_cv_header_syslog_h" >&6
+
+fi
+if test $ac_cv_header_syslog_h = yes; then
+  cat >>confdefs.h <<\_ACEOF
+#define HAVE_SYSLOG 1
+_ACEOF
+
+fi
+
+
+fi
+
+
+echo "$as_me:$LINENO: checking for optreset" >&5
+echo $ECHO_N "checking for optreset... $ECHO_C" >&6
+if test "${pgac_cv_var_int_optreset+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+#include <unistd.h>
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+extern int optreset; optreset = 1;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  pgac_cv_var_int_optreset=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+pgac_cv_var_int_optreset=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $pgac_cv_var_int_optreset" >&5
+echo "${ECHO_T}$pgac_cv_var_int_optreset" >&6
+if test x"$pgac_cv_var_int_optreset" = x"yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_INT_OPTRESET 1
+_ACEOF
+
 fi
-done
 
 
 
-for ac_func in strtoul
+for ac_func in strtoll strtoq
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -11808,15 +11906,13 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
   cat >>confdefs.h <<_ACEOF
 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
-
-else
-  STRTOUL='$(top_builddir)/src/port/strtoul.o'
+ break
 fi
 done
 
 
 
-for ac_func in strcasecmp
+for ac_func in strtoull strtouq
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -11887,41 +11983,14 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
   cat >>confdefs.h <<_ACEOF
 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
-
-else
-  STRCASECMP='$(top_builddir)/src/port/strcasecmp.o'
+ break
 fi
 done
 
 
+# Check for one of atexit() or on_exit()
 
-# Set path of dllinit.c for cygwin
-DLLINIT=""
-case $host_os in
-  cygwin*) DLLINIT='$(top_builddir)/src/backend/port/dllinit.o' ;;
-esac
-
-
-# Set path of qsort for solaris, which has a very slow qsort in certain cases.
-QSORT=""
-case $host_os in
-  solaris*) DLLINIT='$(top_builddir)/src/backend/port/qsort.o' ;;
-esac
-
-
-# On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
-# this hackery with HPUXMATHLIB allows us to cope.
-HPUXMATHLIB=""
-case $host_cpu in
-  hppa1.1)
-	if [ -r /lib/pa1.1/libm.a ] ; then
-	    HPUXMATHLIB="-L /lib/pa1.1 -lm"
-	fi ;;
-esac
-
-
-
-for ac_func in rint
+for ac_func in atexit
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -11994,134 +12063,13 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
 _ACEOF
 
 else
-  echo "$as_me:$LINENO: checking for rint in -lm" >&5
-echo $ECHO_N "checking for rint in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_rint+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm $HPUXMATHLIB $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char rint ();
-#ifdef F77_DUMMY_MAIN
-#  ifdef __cplusplus
-     extern "C"
-#  endif
-   int F77_DUMMY_MAIN() { return 1; }
-#endif
-int
-main ()
-{
-rint ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_rint=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_lib_m_rint=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_rint" >&5
-echo "${ECHO_T}$ac_cv_lib_m_rint" >&6
-if test $ac_cv_lib_m_rint = yes; then
-  cat >>confdefs.h <<\_ACEOF
-#define HAVE_RINT 1
-_ACEOF
-
-fi
-
-fi
-done
-
-
-
-if test "$with_readline" = yes; then
-  echo "$as_me:$LINENO: checking for rl_completion_append_character" >&5
-echo $ECHO_N "checking for rl_completion_append_character... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-#include <stdio.h>
-#ifdef HAVE_READLINE_READLINE_H
-# include <readline/readline.h>
-#elif defined(HAVE_READLINE_H)
-# include <readline.h>
-#endif
-
-#ifdef F77_DUMMY_MAIN
-#  ifdef __cplusplus
-     extern "C"
-#  endif
-   int F77_DUMMY_MAIN() { return 1; }
-#endif
-int
-main ()
-{
-rl_completion_append_character = 'x';
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_RL_COMPLETION_APPEND_CHARACTER 1
-_ACEOF
-
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-
-
-for ac_func in rl_completion_matches rl_filename_completion_function
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
+
+for ac_func in on_exit
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
@@ -12188,916 +12136,229 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: neither atexit() nor on_exit() found" >&5
+echo "$as_me: error: neither atexit() nor on_exit() found" >&2;}
+   { (exit 1); exit 1; }; }
 fi
 done
 
 fi
+done
 
 
-echo "$as_me:$LINENO: checking for finite" >&5
-echo $ECHO_N "checking for finite... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
+
+# This test makes sure that run tests work at all.  Sometimes a shared
+# library is found by the linker, but the runtime linker can't find it.
+# This check should come after all modifications of compiler or linker
+# variables, and before any other run tests.
+echo "$as_me:$LINENO: checking test program" >&5
+echo $ECHO_N "checking test program... $ECHO_C" >&6
+if test "$cross_compiling" = yes; then
+  echo "$as_me:$LINENO: result: cross-compiling" >&5
+echo "${ECHO_T}cross-compiling" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
-#include <math.h>
-#ifdef F77_DUMMY_MAIN
-#  ifdef __cplusplus
-     extern "C"
-#  endif
-   int F77_DUMMY_MAIN() { return 1; }
-#endif
-int
-main ()
-{
-int dummy=finite(1.0);
-  ;
-  return 0;
-}
+int main() { return 0; }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
+rm -f conftest$ac_exeext
 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_FINITE 1
-_ACEOF
-
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+  echo "$as_me:$LINENO: result: ok" >&5
+echo "${ECHO_T}ok" >&6
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+( exit $ac_status )
+echo "$as_me:$LINENO: result: failed" >&5
+echo "${ECHO_T}failed" >&6
+{ { echo "$as_me:$LINENO: error:
+*** Could not execute a simple test program.  This may be a problem
+*** related to locating shared libraries.  Check the file 'config.log'
+*** for the exact reason." >&5
+echo "$as_me: error:
+*** Could not execute a simple test program.  This may be a problem
+*** related to locating shared libraries.  Check the file 'config.log'
+*** for the exact reason." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
-echo "$as_me:$LINENO: checking for sigsetjmp" >&5
-echo $ECHO_N "checking for sigsetjmp... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
+
+
+echo "$as_me:$LINENO: checking whether long int is 64 bits" >&5
+echo $ECHO_N "checking whether long int is 64 bits... $ECHO_C" >&6
+if test "${pgac_cv_type_long_int_64+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  pgac_cv_type_long_int_64=no
+{ echo "$as_me:$LINENO: WARNING: 64 bit arithmetic disabled when cross-compiling" >&5
+echo "$as_me: WARNING: 64 bit arithmetic disabled when cross-compiling" >&2;}
+else
+  cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
-#include <setjmp.h>
-#ifdef F77_DUMMY_MAIN
-#  ifdef __cplusplus
-     extern "C"
-#  endif
-   int F77_DUMMY_MAIN() { return 1; }
-#endif
-int
-main ()
+typedef long int int64;
+
+/*
+ * These are globals to discourage the compiler from folding all the
+ * arithmetic tests down to compile-time constants.
+ */
+int64 a = 20000001;
+int64 b = 40000005;
+
+int does_int64_work()
 {
-sigjmp_buf x; sigsetjmp(x, 1);
-  ;
-  return 0;
+  int64 c,d;
+
+  if (sizeof(int64) != 8)
+    return 0;			/* definitely not the right size */
+
+  /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
+  c = a * b;
+  d = (c + b) / b;
+  if (d != a+1)
+    return 0;
+  return 1;
+}
+main() {
+  exit(! does_int64_work());
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
+rm -f conftest$ac_exeext
 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SIGSETJMP 1
-_ACEOF
-
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-
-echo "$as_me:$LINENO: checking for syslog" >&5
-echo $ECHO_N "checking for syslog... $ECHO_C" >&6
-if test "${ac_cv_func_syslog+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char syslog (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char syslog ();
-char (*f) ();
-
-#ifdef F77_DUMMY_MAIN
-#  ifdef __cplusplus
-     extern "C"
-#  endif
-   int F77_DUMMY_MAIN() { return 1; }
-#endif
-int
-main ()
-{
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_syslog) || defined (__stub___syslog)
-choke me
-#else
-f = syslog;
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_syslog=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_func_syslog=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_syslog" >&5
-echo "${ECHO_T}$ac_cv_func_syslog" >&6
-if test $ac_cv_func_syslog = yes; then
-  if test "${ac_cv_header_syslog_h+set}" = set; then
-  echo "$as_me:$LINENO: checking for syslog.h" >&5
-echo $ECHO_N "checking for syslog.h... $ECHO_C" >&6
-if test "${ac_cv_header_syslog_h+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_syslog_h" >&5
-echo "${ECHO_T}$ac_cv_header_syslog_h" >&6
-else
-  # Is the header compilable?
-echo "$as_me:$LINENO: checking syslog.h usability" >&5
-echo $ECHO_N "checking syslog.h usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-$ac_includes_default
-#include <syslog.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_header_compiler=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_header_compiler=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking syslog.h presence" >&5
-echo $ECHO_N "checking syslog.h presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-#include <syslog.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  ac_header_preproc=yes
-else
-  echo "$as_me: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc in
-  yes:no )
-    { echo "$as_me:$LINENO: WARNING: syslog.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: syslog.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: syslog.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: syslog.h: proceeding with the preprocessor's result" >&2;};;
-  no:yes )
-    { echo "$as_me:$LINENO: WARNING: syslog.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: syslog.h: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: syslog.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: syslog.h: check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: syslog.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: syslog.h: proceeding with the preprocessor's result" >&2;};;
-esac
-echo "$as_me:$LINENO: checking for syslog.h" >&5
-echo $ECHO_N "checking for syslog.h... $ECHO_C" >&6
-if test "${ac_cv_header_syslog_h+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_cv_header_syslog_h=$ac_header_preproc
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_syslog_h" >&5
-echo "${ECHO_T}$ac_cv_header_syslog_h" >&6
-
-fi
-if test $ac_cv_header_syslog_h = yes; then
-  cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYSLOG 1
-_ACEOF
-
-fi
-
-
-fi
-
-
-echo "$as_me:$LINENO: checking for optreset" >&5
-echo $ECHO_N "checking for optreset... $ECHO_C" >&6
-if test "${pgac_cv_var_int_optreset+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-#include <unistd.h>
-#ifdef F77_DUMMY_MAIN
-#  ifdef __cplusplus
-     extern "C"
-#  endif
-   int F77_DUMMY_MAIN() { return 1; }
-#endif
-int
-main ()
-{
-extern int optreset; optreset = 1;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  pgac_cv_var_int_optreset=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-pgac_cv_var_int_optreset=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $pgac_cv_var_int_optreset" >&5
-echo "${ECHO_T}$pgac_cv_var_int_optreset" >&6
-if test x"$pgac_cv_var_int_optreset" = x"yes"; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_INT_OPTRESET 1
-_ACEOF
-
-fi
-
-
-# This test makes sure that run tests work at all.  Sometimes a shared
-# library is found by the linker, but the runtime linker can't find it.
-# This check should come after all modifications of compiler or linker
-# variables, and before any other run tests.
-echo "$as_me:$LINENO: checking test program" >&5
-echo $ECHO_N "checking test program... $ECHO_C" >&6
-if test "$cross_compiling" = yes; then
-  echo "$as_me:$LINENO: result: cross-compiling" >&5
-echo "${ECHO_T}cross-compiling" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-int main() { return 0; }
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:$LINENO: result: ok" >&5
-echo "${ECHO_T}ok" >&6
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-( exit $ac_status )
-echo "$as_me:$LINENO: result: failed" >&5
-echo "${ECHO_T}failed" >&6
-{ { echo "$as_me:$LINENO: error:
-*** Could not execute a simple test program.  This may be a problem
-*** related to locating shared libraries.  Check the file 'config.log'
-*** for the exact reason." >&5
-echo "$as_me: error:
-*** Could not execute a simple test program.  This may be a problem
-*** related to locating shared libraries.  Check the file 'config.log'
-*** for the exact reason." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-
-echo "$as_me:$LINENO: checking whether long int is 64 bits" >&5
-echo $ECHO_N "checking whether long int is 64 bits... $ECHO_C" >&6
-if test "${pgac_cv_type_long_int_64+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$cross_compiling" = yes; then
-  pgac_cv_type_long_int_64=no
-{ echo "$as_me:$LINENO: WARNING: 64 bit arithmetic disabled when cross-compiling" >&5
-echo "$as_me: WARNING: 64 bit arithmetic disabled when cross-compiling" >&2;}
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-typedef long int int64;
-
-/*
- * These are globals to discourage the compiler from folding all the
- * arithmetic tests down to compile-time constants.
- */
-int64 a = 20000001;
-int64 b = 40000005;
-
-int does_int64_work()
-{
-  int64 c,d;
-
-  if (sizeof(int64) != 8)
-    return 0;			/* definitely not the right size */
-
-  /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
-  c = a * b;
-  d = (c + b) / b;
-  if (d != a+1)
-    return 0;
-  return 1;
-}
-main() {
-  exit(! does_int64_work());
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  pgac_cv_type_long_int_64=yes
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-( exit $ac_status )
-pgac_cv_type_long_int_64=no
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-echo "$as_me:$LINENO: result: $pgac_cv_type_long_int_64" >&5
-echo "${ECHO_T}$pgac_cv_type_long_int_64" >&6
-
-HAVE_LONG_INT_64=$pgac_cv_type_long_int_64
-if test x"$pgac_cv_type_long_int_64" = xyes ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_LONG_INT_64
-_ACEOF
-
-fi
-
-
-if test x"$HAVE_LONG_INT_64" = x"no" ; then
-  echo "$as_me:$LINENO: checking whether long long int is 64 bits" >&5
-echo $ECHO_N "checking whether long long int is 64 bits... $ECHO_C" >&6
-if test "${pgac_cv_type_long_long_int_64+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$cross_compiling" = yes; then
-  pgac_cv_type_long_long_int_64=no
-{ echo "$as_me:$LINENO: WARNING: 64 bit arithmetic disabled when cross-compiling" >&5
-echo "$as_me: WARNING: 64 bit arithmetic disabled when cross-compiling" >&2;}
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-typedef long long int int64;
-
-/*
- * These are globals to discourage the compiler from folding all the
- * arithmetic tests down to compile-time constants.
- */
-int64 a = 20000001;
-int64 b = 40000005;
-
-int does_int64_work()
-{
-  int64 c,d;
-
-  if (sizeof(int64) != 8)
-    return 0;			/* definitely not the right size */
-
-  /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
-  c = a * b;
-  d = (c + b) / b;
-  if (d != a+1)
-    return 0;
-  return 1;
-}
-main() {
-  exit(! does_int64_work());
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  pgac_cv_type_long_long_int_64=yes
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-( exit $ac_status )
-pgac_cv_type_long_long_int_64=no
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-echo "$as_me:$LINENO: result: $pgac_cv_type_long_long_int_64" >&5
-echo "${ECHO_T}$pgac_cv_type_long_long_int_64" >&6
-
-HAVE_LONG_LONG_INT_64=$pgac_cv_type_long_long_int_64
-if test x"$pgac_cv_type_long_long_int_64" = xyes ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_LONG_LONG_INT_64
-_ACEOF
-
-fi
-
-fi
-
-
-
-if [ x"$HAVE_LONG_LONG_INT_64" = xyes ] ; then
-  cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-
-#define INT64CONST(x)  x##LL
-long long int foo = INT64CONST(0x1234567890123456);
-
-#ifdef F77_DUMMY_MAIN
-#  ifdef __cplusplus
-     extern "C"
-#  endif
-   int F77_DUMMY_MAIN() { return 1; }
-#endif
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_LL_CONSTANTS 1
-_ACEOF
-
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-
-if [ x"$HAVE_LONG_LONG_INT_64" = xyes ] ; then
-  if [ x$SNPRINTF = x ] ; then
-    echo "$as_me:$LINENO: checking whether snprintf handles 'long long int' as %lld" >&5
-echo $ECHO_N "checking whether snprintf handles 'long long int' as %lld... $ECHO_C" >&6
-    if test "$cross_compiling" = yes; then
-   echo "$as_me:$LINENO: result: assuming not on target machine" >&5
-echo "${ECHO_T}assuming not on target machine" >&6
-	# Force usage of our own snprintf, since we cannot test foreign snprintf
-	SNPRINTF='$(top_builddir)/src/port/snprintf.o'
-	INT64_FORMAT='"%lld"'
-
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-#include <stdio.h>
-typedef long long int int64;
-#define INT64_FORMAT "%lld"
-
-int64 a = 20000001;
-int64 b = 40000005;
-
-int does_int64_snprintf_work()
-{
-  int64 c;
-  char buf[100];
-
-  if (sizeof(int64) != 8)
-    return 0;			/* doesn't look like the right size */
-
-  c = a * b;
-  snprintf(buf, 100, INT64_FORMAT, c);
-  if (strcmp(buf, "800000140000005") != 0)
-    return 0;			/* either multiply or snprintf is busted */
-  return 1;
-}
-main() {
-  exit(! does_int64_snprintf_work());
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-   echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-	  INT64_FORMAT='"%lld"'
-
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-( exit $ac_status )
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-    echo "$as_me:$LINENO: checking whether snprintf handles 'long long int' as %qd" >&5
-echo $ECHO_N "checking whether snprintf handles 'long long int' as %qd... $ECHO_C" >&6
-    if test "$cross_compiling" = yes; then
-   echo "$as_me:$LINENO: result: assuming not on target machine" >&5
-echo "${ECHO_T}assuming not on target machine" >&6
-	# Force usage of our own snprintf, since we cannot test foreign snprintf
-	SNPRINTF='$(top_builddir)/src/port/snprintf.o'
-	INT64_FORMAT='"%lld"'
-
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-#include <stdio.h>
-typedef long long int int64;
-#define INT64_FORMAT "%qd"
-
-int64 a = 20000001;
-int64 b = 40000005;
-
-int does_int64_snprintf_work()
-{
-  int64 c;
-  char buf[100];
-
-  if (sizeof(int64) != 8)
-    return 0;     /* doesn't look like the right size */
-
-  c = a * b;
-  snprintf(buf, 100, INT64_FORMAT, c);
-  if (strcmp(buf, "800000140000005") != 0)
-    return 0;     /* either multiply or snprintf is busted */
-  return 1;
-}
-main() {
-  exit(! does_int64_snprintf_work());
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-   echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-    INT64_FORMAT='"%qd"'
-
+  pgac_cv_type_long_int_64=yes
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
 ( exit $ac_status )
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-	# Force usage of our own snprintf, since system snprintf is broken
-	SNPRINTF='$(top_builddir)/src/port/snprintf.o'
-	INT64_FORMAT='"%lld"'
-
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
+pgac_cv_type_long_int_64=no
 fi
 rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-  else
-    # here if we previously decided we needed to use our own snprintf
-    INT64_FORMAT='"%lld"'
-  fi
-else
-  # Here if we are not using 'long long int' at all
-  INT64_FORMAT='"%ld"'
 fi
+echo "$as_me:$LINENO: result: $pgac_cv_type_long_int_64" >&5
+echo "${ECHO_T}$pgac_cv_type_long_int_64" >&6
 
+HAVE_LONG_INT_64=$pgac_cv_type_long_int_64
+if test x"$pgac_cv_type_long_int_64" = xyes ; then
 
-cat >>confdefs.h <<_ACEOF
-#define INT64_FORMAT $INT64_FORMAT
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LONG_INT_64
 _ACEOF
 
-
-
-
-
-for ac_func in strtoll strtoq
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line $LINENO "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
-
-#ifdef F77_DUMMY_MAIN
-#  ifdef __cplusplus
-     extern "C"
-#  endif
-   int F77_DUMMY_MAIN() { return 1; }
-#endif
-int
-main ()
-{
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func;
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-eval "$as_ac_var=no"
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
- break
 fi
-done
-
 
 
-for ac_func in strtoull strtouq
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
+if test x"$HAVE_LONG_INT_64" = x"no" ; then
+  echo "$as_me:$LINENO: checking whether long long int is 64 bits" >&5
+echo $ECHO_N "checking whether long long int is 64 bits... $ECHO_C" >&6
+if test "${pgac_cv_type_long_long_int_64+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  pgac_cv_type_long_long_int_64=no
+{ echo "$as_me:$LINENO: WARNING: 64 bit arithmetic disabled when cross-compiling" >&5
+echo "$as_me: WARNING: 64 bit arithmetic disabled when cross-compiling" >&2;}
 else
   cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
+typedef long long int int64;
 
-#ifdef F77_DUMMY_MAIN
-#  ifdef __cplusplus
-     extern "C"
-#  endif
-   int F77_DUMMY_MAIN() { return 1; }
-#endif
-int
-main ()
+/*
+ * These are globals to discourage the compiler from folding all the
+ * arithmetic tests down to compile-time constants.
+ */
+int64 a = 20000001;
+int64 b = 40000005;
+
+int does_int64_work()
 {
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func;
-#endif
+  int64 c,d;
 
-  ;
-  return 0;
+  if (sizeof(int64) != 8)
+    return 0;			/* definitely not the right size */
+
+  /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
+  c = a * b;
+  d = (c + b) / b;
+  if (d != a+1)
+    return 0;
+  return 1;
+}
+main() {
+  exit(! does_int64_work());
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
+rm -f conftest$ac_exeext
 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
+  pgac_cv_type_long_long_int_64=yes
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-eval "$as_ac_var=no"
+( exit $ac_status )
+pgac_cv_type_long_long_int_64=no
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+fi
+echo "$as_me:$LINENO: result: $pgac_cv_type_long_long_int_64" >&5
+echo "${ECHO_T}$pgac_cv_type_long_long_int_64" >&6
+
+HAVE_LONG_LONG_INT_64=$pgac_cv_type_long_long_int_64
+if test x"$pgac_cv_type_long_long_int_64" = xyes ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LONG_LONG_INT_64
 _ACEOF
- break
+
 fi
-done
 
+fi
 
-# Check for one of atexit() or on_exit()
 
-for ac_func in atexit
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+
+if [ x"$HAVE_LONG_LONG_INT_64" = xyes ] ; then
   cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
+
+#define INT64CONST(x)  x##LL
+long long int foo = INT64CONST(0x1234567890123456);
 
 #ifdef F77_DUMMY_MAIN
 #  ifdef __cplusplus
@@ -13108,130 +12369,187 @@ char (*f) ();
 int
 main ()
 {
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func;
-#endif
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
+         { ac_try='test -s conftest.$ac_objext'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LL_CONSTANTS 1
+_ACEOF
+
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-eval "$as_ac_var=no"
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+
+
+
+if test x"$HAVE_LONG_LONG_INT_64" = xyes ; then
+  if test $pgac_need_repl_snprintf = no; then
+    echo "$as_me:$LINENO: checking whether snprintf handles 'long long int' as %lld" >&5
+echo $ECHO_N "checking whether snprintf handles 'long long int' as %lld... $ECHO_C" >&6
+    if test "$cross_compiling" = yes; then
+   echo "$as_me:$LINENO: result: cannot test (not on host machine)" >&5
+echo "${ECHO_T}cannot test (not on host machine)" >&6
+	# Force usage of our own snprintf, since we cannot test foreign snprintf
+        pgac_need_repl_snprintf=yes
+	INT64_FORMAT='"%lld"'
+
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+#include <stdio.h>
+typedef long long int int64;
+#define INT64_FORMAT "%lld"
+
+int64 a = 20000001;
+int64 b = 40000005;
+
+int does_int64_snprintf_work()
+{
+  int64 c;
+  char buf[100];
+
+  if (sizeof(int64) != 8)
+    return 0;			/* doesn't look like the right size */
+
+  c = a * b;
+  snprintf(buf, 100, INT64_FORMAT, c);
+  if (strcmp(buf, "800000140000005") != 0)
+    return 0;			/* either multiply or snprintf is busted */
+  return 1;
+}
+main() {
+  exit(! does_int64_snprintf_work());
+}
 _ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+   echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+	  INT64_FORMAT='"%lld"'
 
 else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+( exit $ac_status )
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+    echo "$as_me:$LINENO: checking whether snprintf handles 'long long int' as %qd" >&5
+echo $ECHO_N "checking whether snprintf handles 'long long int' as %qd... $ECHO_C" >&6
+    if test "$cross_compiling" = yes; then
+   echo "$as_me:$LINENO: result: cannot test (not on host machine)" >&5
+echo "${ECHO_T}cannot test (not on host machine)" >&6
+	# Force usage of our own snprintf, since we cannot test foreign snprintf
+        pgac_need_repl_snprintf=yes
+	INT64_FORMAT='"%lld"'
 
-for ac_func in on_exit
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
 #line $LINENO "configure"
 #include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
+#include <stdio.h>
+typedef long long int int64;
+#define INT64_FORMAT "%qd"
 
-#ifdef F77_DUMMY_MAIN
-#  ifdef __cplusplus
-     extern "C"
-#  endif
-   int F77_DUMMY_MAIN() { return 1; }
-#endif
-int
-main ()
+int64 a = 20000001;
+int64 b = 40000005;
+
+int does_int64_snprintf_work()
 {
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func;
-#endif
+  int64 c;
+  char buf[100];
 
-  ;
-  return 0;
+  if (sizeof(int64) != 8)
+    return 0;     /* doesn't look like the right size */
+
+  c = a * b;
+  snprintf(buf, 100, INT64_FORMAT, c);
+  if (strcmp(buf, "800000140000005") != 0)
+    return 0;     /* either multiply or snprintf is busted */
+  return 1;
+}
+main() {
+  exit(! does_int64_snprintf_work());
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
+rm -f conftest$ac_exeext
 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
+   echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+    INT64_FORMAT='"%qd"'
+
 else
-  echo "$as_me: failed program was:" >&5
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-eval "$as_ac_var=no"
+( exit $ac_status )
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+	# Force usage of our own snprintf, since system snprintf is broken
+        pgac_need_repl_snprintf=yes
+	INT64_FORMAT='"%lld"'
+
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+  else
+    # here if we previously decided we needed to use our own snprintf
+    INT64_FORMAT='"%lld"'
+  fi
 else
-  { { echo "$as_me:$LINENO: error: neither atexit() nor on_exit() found" >&5
-echo "$as_me: error: neither atexit() nor on_exit() found" >&2;}
-   { (exit 1); exit 1; }; }
+  # Here if we are not using 'long long int' at all
+  INT64_FORMAT='"%ld"'
 fi
-done
 
-fi
-done
 
+cat >>confdefs.h <<_ACEOF
+#define INT64_FORMAT $INT64_FORMAT
+_ACEOF
+
+
+if test $pgac_need_repl_snprintf = yes; then
+  LIBOBJS="$LIBOBJS snprintf.$ac_objext"
+fi
 
 
 echo "$as_me:$LINENO: checking for unsigned long" >&5
@@ -17577,21 +16895,7 @@ s,@python_moduledir@,$python_moduledir,;t t
 s,@python_moduleexecdir@,$python_moduleexecdir,;t t
 s,@python_includespec@,$python_includespec,;t t
 s,@python_libspec@,$python_libspec,;t t
-s,@MEMCMP@,$MEMCMP,;t t
-s,@SNPRINTF@,$SNPRINTF,;t t
-s,@ISINF@,$ISINF,;t t
-s,@GETRUSAGE@,$GETRUSAGE,;t t
-s,@SRANDOM@,$SRANDOM,;t t
-s,@GETHOSTNAME@,$GETHOSTNAME,;t t
-s,@MISSING_RANDOM@,$MISSING_RANDOM,;t t
-s,@INET_ATON@,$INET_ATON,;t t
-s,@STRERROR@,$STRERROR,;t t
-s,@STRDUP@,$STRDUP,;t t
-s,@STRTOL@,$STRTOL,;t t
-s,@STRTOUL@,$STRTOUL,;t t
-s,@STRCASECMP@,$STRCASECMP,;t t
-s,@DLLINIT@,$DLLINIT,;t t
-s,@QSORT@,$QSORT,;t t
+s,@LIBOBJS@,$LIBOBJS,;t t
 s,@HPUXMATHLIB@,$HPUXMATHLIB,;t t
 s,@HAVE_POSIX_SIGNALS@,$HAVE_POSIX_SIGNALS,;t t
 s,@MSGFMT@,$MSGFMT,;t t
diff --git a/configure.in b/configure.in
index 8650e126e86..8ea4f1f15fc 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $Header: /cvsroot/pgsql/configure.in,v 1.193 2002/07/19 17:35:09 momjian Exp $
+dnl $Header: /cvsroot/pgsql/configure.in,v 1.194 2002/07/27 20:10:03 petere Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -747,6 +747,7 @@ fi
 ##
 ## Header files
 ##
+
 dnl sys/socket.h is required by AC_FUNC_ACCEPT_ARGTYPES
 AC_CHECK_HEADERS([crypt.h dld.h endian.h fp_class.h getopt.h ieeefp.h pwd.h sys/ipc.h sys/pstat.h sys/select.h sys/sem.h sys/socket.h sys/shm.h sys/un.h termios.h kernel/OS.h kernel/image.h SupportDefs.h])
 
@@ -798,6 +799,7 @@ fi
 ##
 ## Types, structures, compiler characteristics
 ##
+
 m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that.
 AC_C_CONST
 AC_C_INLINE
@@ -840,12 +842,13 @@ fi
 ##
 ## Functions, global variables
 ##
+
 PGAC_VAR_INT_TIMEZONE
 AC_FUNC_ACCEPT_ARGTYPES
 PGAC_FUNC_GETTIMEOFDAY_1ARG
 
 # SunOS doesn't handle negative byte comparisons properly with +/- return
-PGAC_FUNC_MEMCMP
+AC_FUNC_MEMCMP
 
 AC_CHECK_FUNCS([cbrt fcvt getopt_long memmove pstat setproctitle setsid sigprocmask sysconf waitpid dlopen fdatasync])
 
@@ -870,10 +873,9 @@ fi
 # also decide to use snprintf.c if snprintf() is present but does not
 # have working "long long int" support -- see below.
 
-SNPRINTF=''
-AC_CHECK_FUNCS(snprintf, [], SNPRINTF='$(top_builddir)/src/port/snprintf.o')
-AC_CHECK_FUNCS(vsnprintf, [], SNPRINTF='$(top_builddir)/src/port/snprintf.o')
-AC_SUBST(SNPRINTF)
+pgac_need_repl_snprintf=no
+AC_CHECK_FUNCS(snprintf, [], pgac_need_repl_snprintf=yes)
+AC_CHECK_FUNCS(vsnprintf, [], pgac_need_repl_snprintf=yes)
 
 
 # Check whether <stdio.h> declares snprintf() and vsnprintf(); if not,
@@ -895,49 +897,18 @@ AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
 
 if test $ac_cv_func_isinf = yes ; then
   AC_DEFINE(HAVE_ISINF, 1, [Define to 1 if you have isinf()])
-  ISINF=
 else
-  ISINF='isinf.o'
+  AC_LIBOBJ(isinf)
   # Look for a way to implement a substitute for isinf()
   AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
 fi
-AC_SUBST(ISINF)
-
-
-AC_CHECK_FUNCS(getrusage, [], GETRUSAGE='$(top_builddir)/src/port/getrusage.o')
-AC_SUBST(GETRUSAGE)
-AC_CHECK_FUNCS(srandom, [], SRANDOM='$(top_builddir)/src/port/srandom.o')
-AC_SUBST(SRANDOM)
-AC_CHECK_FUNCS(gethostname, [], GETHOSTNAME='$(top_builddir)/src/port/gethostname.o')
-AC_SUBST(GETHOSTNAME)
-AC_CHECK_FUNCS(random, [], MISSING_RANDOM='$(top_builddir)/src/port/random.o')
-AC_SUBST(MISSING_RANDOM)
-AC_CHECK_FUNCS(inet_aton, [], INET_ATON='$(top_builddir)/src/port/inet_aton.o')
-AC_SUBST(INET_ATON)
-AC_CHECK_FUNCS(strerror, [], STRERROR='$(top_builddir)/src/port/strerror.o')
-AC_SUBST(STRERROR)
-AC_CHECK_FUNCS(strdup, [], STRDUP='$(top_builddir)/src/port/strdup.o')
-AC_SUBST(STRDUP)
-AC_CHECK_FUNCS(strtol, [], STRTOL='$(top_builddir)/src/port/strtol.o')
-AC_SUBST(STRTOL)
-AC_CHECK_FUNCS(strtoul, [], STRTOUL='$(top_builddir)/src/port/strtoul.o')
-AC_SUBST(STRTOUL)
-AC_CHECK_FUNCS(strcasecmp, [], STRCASECMP='$(top_builddir)/src/port/strcasecmp.o')
-AC_SUBST(STRCASECMP)
-
-# Set path of dllinit.c for cygwin
-DLLINIT=""
-case $host_os in 
-  cygwin*) DLLINIT='$(top_builddir)/src/backend/port/dllinit.o' ;;
-esac
-AC_SUBST(DLLINIT)
 
-# Set path of qsort for solaris, which has a very slow qsort in certain cases.
-QSORT=""
+AC_REPLACE_FUNCS([gethostname getrusage inet_aton random srandom strcasecmp strdup strerror strtol strtoul])
+
+# Solaris has a very slow qsort in certain cases.
 case $host_os in 
-  solaris*) DLLINIT='$(top_builddir)/src/backend/port/qsort.o' ;;
+  solaris*) AC_LIBOBJ(qsort) ;;
 esac
-AC_SUBST(QSORT)
 
 # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
 # this hackery with HPUXMATHLIB allows us to cope.
@@ -992,6 +963,14 @@ if test x"$pgac_cv_var_int_optreset" = x"yes"; then
   AC_DEFINE(HAVE_INT_OPTRESET, 1, [Define to 1 if you have the global variable 'int optreset'])
 fi
 
+AC_CHECK_FUNCS([strtoll strtoq], [break])
+AC_CHECK_FUNCS([strtoull strtouq], [break])
+
+# Check for one of atexit() or on_exit()
+AC_CHECK_FUNCS(atexit, [],
+               [AC_CHECK_FUNCS(on_exit, [],
+                               [AC_MSG_ERROR([neither atexit() nor on_exit() found])])])
+
 
 # This test makes sure that run tests work at all.  Sometimes a shared
 # library is found by the linker, but the runtime linker can't find it.
@@ -1047,8 +1026,8 @@ dnl We cope with snprintfs that use either %lld or %qd as the format.
 dnl If neither works, fall back to our own snprintf emulation (which we
 dnl know uses %lld).
 
-if [[ x"$HAVE_LONG_LONG_INT_64" = xyes ]] ; then
-  if [[ x$SNPRINTF = x ]] ; then
+if test x"$HAVE_LONG_LONG_INT_64" = xyes ; then
+  if test $pgac_need_repl_snprintf = no; then
     AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld)
     AC_TRY_RUN([#include <stdio.h>
 typedef long long int int64;
@@ -1108,17 +1087,17 @@ main() {
   ],
   [ AC_MSG_RESULT(no)
 	# Force usage of our own snprintf, since system snprintf is broken
-	SNPRINTF='$(top_builddir)/src/port/snprintf.o'
+        pgac_need_repl_snprintf=yes
 	INT64_FORMAT='"%lld"'
   ],
-  [ AC_MSG_RESULT(assuming not on target machine)
+  [ AC_MSG_RESULT([cannot test (not on host machine)])
 	# Force usage of our own snprintf, since we cannot test foreign snprintf
-	SNPRINTF='$(top_builddir)/src/port/snprintf.o'
+        pgac_need_repl_snprintf=yes
 	INT64_FORMAT='"%lld"'
   ]) ],
-  [ AC_MSG_RESULT(assuming not on target machine)
+  [ AC_MSG_RESULT([cannot test (not on host machine)])
 	# Force usage of our own snprintf, since we cannot test foreign snprintf
-	SNPRINTF='$(top_builddir)/src/port/snprintf.o'
+        pgac_need_repl_snprintf=yes
 	INT64_FORMAT='"%lld"'
   ])
   else
@@ -1133,14 +1112,9 @@ fi
 AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT,
                    [Define this as the appropriate snprintf format for 64-bit ints, if any])
 
-
-AC_CHECK_FUNCS([strtoll strtoq], [break])
-AC_CHECK_FUNCS([strtoull strtouq], [break])
-
-# Check for one of atexit() or on_exit()
-AC_CHECK_FUNCS(atexit, [],
-               [AC_CHECK_FUNCS(on_exit, [],
-                               [AC_MSG_ERROR([neither atexit() nor on_exit() found])])])
+if test $pgac_need_repl_snprintf = yes; then
+  AC_LIBOBJ(snprintf)
+fi
 
 dnl Need a #define for the size of Datum (unsigned long)
 
diff --git a/contrib/pg_controldata/Makefile b/contrib/pg_controldata/Makefile
index 0feeb973d4f..7cc20828e5f 100644
--- a/contrib/pg_controldata/Makefile
+++ b/contrib/pg_controldata/Makefile
@@ -1,16 +1,18 @@
-# $Header: /cvsroot/pgsql/contrib/pg_controldata/Attic/Makefile,v 1.7 2002/07/18 04:33:39 momjian Exp $
+# $Header: /cvsroot/pgsql/contrib/pg_controldata/Attic/Makefile,v 1.8 2002/07/27 20:10:03 petere Exp $
 
 subdir = contrib/pg_controldata
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
+all: submake-libpgport
+
 PROGRAM = pg_controldata
-OBJS	= pg_controldata.o pg_crc.o $(SNPRINTF)
+OBJS	= pg_controldata.o pg_crc.o
 
 pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
 	rm -f $@ && $(LN_S) $< .
 
-EXTRA_CLEAN = pg_crc.c snprintf.c
+EXTRA_CLEAN = pg_crc.c
 
 DOCS = README.pg_controldata
 
diff --git a/contrib/pg_resetxlog/Makefile b/contrib/pg_resetxlog/Makefile
index 93eeffe491b..193e8bb93a5 100644
--- a/contrib/pg_resetxlog/Makefile
+++ b/contrib/pg_resetxlog/Makefile
@@ -1,16 +1,18 @@
-# $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/Makefile,v 1.5 2002/07/18 04:33:39 momjian Exp $
+# $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/Makefile,v 1.6 2002/07/27 20:10:03 petere Exp $
 
 subdir = contrib/pg_resetxlog
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
+all: submake-libpgport
+
 PROGRAM = pg_resetxlog
-OBJS	= pg_resetxlog.o pg_crc.o $(SNPRINTF)
+OBJS	= pg_resetxlog.o pg_crc.o
 
 pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
 	rm -f $@ && $(LN_S) $< .
 
-EXTRA_CLEAN = pg_crc.c snprintf.c
+EXTRA_CLEAN = pg_crc.c
 
 DOCS = README.pg_resetxlog
 
diff --git a/doc/FAQ_Solaris b/doc/FAQ_Solaris
index 06f15250674..984f21b0a24 100644
--- a/doc/FAQ_Solaris
+++ b/doc/FAQ_Solaris
@@ -3,7 +3,7 @@ Frequently Asked Questions (FAQ) for PostgreSQL 7.2
 Sun Solaris specific
 to be read in conjunction with the installation instructions
 ============================================================
-last updated:        $Date: 2002/07/15 21:34:04 $
+last updated:        $Date: 2002/07/27 20:10:03 $
 
 current maintainer:  Peter Eisentraut <peter_e@gmx.net>
 
@@ -88,15 +88,15 @@ to work on Solaris 7:
 On Solaris 7 and older, the 64-bit version of libc has a buggy vsnprintf
 routine, which leads to erratic core dumps in PostgreSQL.  The simplest known
 workaround is to force PostgreSQL to use its own version of vsnprintf rather
-than the library copy.  To do this, after you run 'configure' edit two files
+than the library copy.  To do this, after you run 'configure' edit a file
 produced by configure:
 
-(1) In src/Makefile.global, change the line
-	SNPRINTF = 
+In src/Makefile.global, change the line
+    LIBOBJS =
 to read
-	SNPRINTF = $(top_builddir)/src/backend/port/snprint.o
+    LIBOBJS = snprintf.o
 
-(2) In src/backend/port/Makefile, add "snprintf.o" to OBJS.  (Skip this
-step if you see "$(SNPRINTF)" already listed in OBJS.)
+(There might be other files already listed in this variable.  Order
+does not matter.)
 
 Then build as usual.
diff --git a/src/Makefile b/src/Makefile
index f7d67350dcf..91a97df4928 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/Makefile,v 1.25 2002/07/18 22:15:10 tgl Exp $
+# $Header: /cvsroot/pgsql/src/Makefile,v 1.26 2002/07/27 20:10:04 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -14,6 +14,7 @@ include Makefile.global
 
 
 all install installdirs uninstall dep depend distprep:
+	$(MAKE) -C port $@
 	$(MAKE) -C backend $@
 	$(MAKE) -C include $@
 	$(MAKE) -C interfaces $@
@@ -24,6 +25,7 @@ install-all-headers:
 	$(MAKE) -C include $@
 
 clean:
+	$(MAKE) -C port $@
 	$(MAKE) -C backend $@
 	$(MAKE) -C include $@
 	$(MAKE) -C interfaces $@
@@ -32,6 +34,7 @@ clean:
 	$(MAKE) -C test $@
 
 distclean maintainer-clean:
+	-$(MAKE) -C port $@
 	-$(MAKE) -C backend $@
 	-$(MAKE) -C include $@
 	-$(MAKE) -C interfaces $@
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index f3d04c19273..a7370bcc848 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -1,5 +1,5 @@
 # -*-makefile-*-
-# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.151 2002/07/19 17:35:10 momjian Exp $
+# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.152 2002/07/27 20:10:04 petere Exp $
 
 #------------------------------------------------------------------------------
 # All PostgreSQL makefiles include this file and use the variables it sets,
@@ -294,6 +294,7 @@ ifeq ($(enable_rpath), yes)
 LDFLAGS += $(rpath)
 endif
 
+
 ##########################################################################
 #
 # Some variables needed to find some client interfaces
@@ -302,6 +303,14 @@ libpq_srcdir = $(top_srcdir)/src/interfaces/libpq
 libpq_builddir = $(top_builddir)/src/interfaces/libpq
 libpq = -L$(libpq_builddir) -lpq
 
+submake-libpq:
+	$(MAKE) -C $(libpq_builddir) all
+
+submake-libpgport:
+	$(MAKE) -C $(top_builddir)/src/port all
+
+.PHONY: submake-libpq submake-libpgport
+
 
 ##########################################################################
 #
@@ -346,23 +355,14 @@ endif
 #
 # substitute implementations of the C library
 
-GETHOSTNAME = @GETHOSTNAME@
-GETRUSAGE   = @GETRUSAGE@
-INET_ATON   = @INET_ATON@
-ISINF       = @ISINF@
-MEMCMP      = @MEMCMP@
-MISSING_RANDOM = @MISSING_RANDOM@
-QSORT       = @QSORT@
-SNPRINTF    = @SNPRINTF@
-SRANDOM     = @SRANDOM@
-STRCASECMP  = @STRCASECMP@
-STRDUP      = @STRDUP@
-STRERROR    = @STRERROR@
-STRTOL      = @STRTOL@
-STRTOUL     = @STRTOUL@
+LIBOBJS = @LIBOBJS@
+
+ifneq (,$(LIBOBJS))
+LIBS += -lpgport
+LDFLAGS := -L$(top_builddir)/src/port $(LDFLAGS)
+endif
 
 # Not really standard libc functions, used by the backend.
-DLLINIT     = @DLLINIT@
 TAS         = @TAS@
 
 
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index 8b4145b12a5..dc6933a1886 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -6,7 +6,7 @@
 # Copyright (c) 1998, Regents of the University of California
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.59 2002/07/16 05:46:35 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.60 2002/07/27 20:10:04 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -332,7 +332,7 @@ $(shlib) lib$(NAME).a: $(OBJS) $(DLLINIT)
 	$(DLLWRAP) -o $(shlib) --dllname $(shlib) --def $(NAME).def $(OBJS) $(DLLINIT) $(DLLLIBS) $(SHLIB_LINK)
 	$(DLLTOOL) --dllname $(shlib) --def $(NAME).def --output-lib lib$(NAME).a
 
-$(DLLINIT):
+$(DLLINIT): $(DLLINIT:%.o=%.c)
 	$(MAKE) -C $(@D) $(@F)
 
 endif # PORTNAME == win
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 925340c3b19..dcfa3cad39b 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.81 2002/07/18 02:02:29 ishii Exp $
+# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.82 2002/07/27 20:10:04 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -29,7 +29,7 @@ endif
 
 ##########################################################################
 
-all: postgres $(POSTGRES_IMP)
+all: submake-libpgport postgres $(POSTGRES_IMP)
 ifeq ($(enable_nls), yes)
 	$(MAKE) -C po all
 endif
@@ -41,13 +41,11 @@ postgres: $(OBJS)
 
 else # win
 
-# No points for style here. How about encapsulating some of these
-# commands into variables?
 postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a
-	dlltool --dllname $@$(X) --output-exp $@.exp --def postgres.def
-	gcc $(LDFLAGS) -g -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(DLLLIBS)
-	dlltool --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
-	gcc $(LDFLAGS) -g -o $@$(X) $@.exp $(OBJS) $(DLLLIBS)
+	$(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
+	$(CC) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(DLLLIBS)
+	$(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
+	$(CC) $(LDFLAGS) -o $@$(X) $@.exp $(OBJS) $(DLLLIBS)
 	rm $@.exp $@.base
 
 endif # win
@@ -73,7 +71,7 @@ libpostgres.a: $(OBJS) $(DLLINIT) postgres.def
 endif # MAKE_DLL
 
 
-$(DLLINIT):
+$(DLLINIT): $(DLLINIT:%.o=%.c)
 	$(MAKE) -C $(@D) $(@F)
 
 # The postgres.o target is needed by the rule in Makefile.global that
diff --git a/src/backend/port/Makefile b/src/backend/port/Makefile
index 2960526c5af..3a9a38af892 100644
--- a/src/backend/port/Makefile
+++ b/src/backend/port/Makefile
@@ -13,7 +13,7 @@
 # be converted to Method 2.  
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.17 2002/07/19 17:35:11 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.18 2002/07/27 20:10:05 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -21,14 +21,8 @@ subdir = src/backend/port
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-OBJS=$(GETHOSTNAME) $(GETRUSAGE) $(INET_ATON) $(ISINF) $(MEMCMP) \
-        $(MISSING_RANDOM) $(QSORT) $(SNPRINTF) $(SRANDOM) $(STRCASECMP) \
-	$(STRDUP) $(STRERROR) $(STRTOL) $(STRTOUL)
-
 OBJS+=dynloader.o pg_sema.o pg_shmem.o
 
-OBJS+=$(DLLINIT)
-
 OBJS+=$(TAS)
 
 ifeq ($(PORTNAME), qnx4)
@@ -65,7 +59,7 @@ tas.o: tas.s
 	$(CC) $(CFLAGS) -c $<
 
 # IPC test program
-ipc_test: ipc_test.o pg_sema.o pg_shmem.o $(MEMCMP) $(SNPRINTF) $(STRERROR)
+ipc_test: ipc_test.o pg_sema.o pg_shmem.o
 	$(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@
 
 distclean clean:
diff --git a/src/backend/port/inet_aton.c b/src/backend/port/inet_aton.c
deleted file mode 100644
index 8f7c4e255a9..00000000000
--- a/src/backend/port/inet_aton.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/* $Id: inet_aton.c,v 1.20 2001/10/25 05:49:40 momjian Exp $
- *
- *	This inet_aton() function was taken from the GNU C library and
- *	incorporated into Postgres for those systems which do not have this
- *	routine in their standard C libraries.
- *
- *	The function was been extracted whole from the file inet_aton.c in
- *	Release 5.3.12 of the Linux C library, which is derived from the
- *	GNU C library, by Bryan Henderson in October 1996.	The copyright
- *	notice from that file is below.
- */
-
-/*
- * Copyright (c) 1983, 1990, 1993
- *		The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *	  notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *	  notice, this list of conditions and the following disclaimer in the
- *	  documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *	  must display the following acknowledgement:
- *		This product includes software developed by the University of
- *		California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *	  may be used to endorse or promote products derived from this software
- *	  without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.	IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.  */
-
-#include "c.h"
-
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <ctype.h>
-
-/*
- * Check whether "cp" is a valid ascii representation
- * of an Internet address and convert to a binary address.
- * Returns 1 if the address is valid, 0 if not.
- * This replaces inet_addr, the return value from which
- * cannot distinguish between failure and a local broadcast address.
- */
-int
-inet_aton(const char *cp, struct in_addr * addr)
-{
-	unsigned int val;
-	int			base,
-				n;
-	char		c;
-	u_int		parts[4];
-	u_int	   *pp = parts;
-
-	for (;;)
-	{
-		/*
-		 * Collect number up to ``.''. Values are specified as for C:
-		 * 0x=hex, 0=octal, other=decimal.
-		 */
-		val = 0;
-		base = 10;
-		if (*cp == '0')
-		{
-			if (*++cp == 'x' || *cp == 'X')
-				base = 16, cp++;
-			else
-				base = 8;
-		}
-		while ((c = *cp) != '\0')
-		{
-			if (isdigit((unsigned char) c))
-			{
-				val = (val * base) + (c - '0');
-				cp++;
-				continue;
-			}
-			if (base == 16 && isxdigit((unsigned char) c))
-			{
-				val = (val << 4) +
-					(c + 10 - (islower((unsigned char) c) ? 'a' : 'A'));
-				cp++;
-				continue;
-			}
-			break;
-		}
-		if (*cp == '.')
-		{
-			/*
-			 * Internet format: a.b.c.d a.b.c	(with c treated as
-			 * 16-bits) a.b		(with b treated as 24 bits)
-			 */
-			if (pp >= parts + 3 || val > 0xff)
-				return 0;
-			*pp++ = val, cp++;
-		}
-		else
-			break;
-	}
-
-	/*
-	 * Check for trailing junk.
-	 */
-	while (*cp)
-		if (!isspace((unsigned char) *cp++))
-			return 0;
-
-	/*
-	 * Concoct the address according to the number of parts specified.
-	 */
-	n = pp - parts + 1;
-	switch (n)
-	{
-
-		case 1:			/* a -- 32 bits */
-			break;
-
-		case 2:			/* a.b -- 8.24 bits */
-			if (val > 0xffffff)
-				return 0;
-			val |= parts[0] << 24;
-			break;
-
-		case 3:			/* a.b.c -- 8.8.16 bits */
-			if (val > 0xffff)
-				return 0;
-			val |= (parts[0] << 24) | (parts[1] << 16);
-			break;
-
-		case 4:			/* a.b.c.d -- 8.8.8.8 bits */
-			if (val > 0xff)
-				return 0;
-			val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
-			break;
-	}
-	if (addr)
-		addr->s_addr = htonl(val);
-	return 1;
-}
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 1a19c71fc26..eff79981866 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.35 2002/07/15 21:34:05 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.36 2002/07/27 20:10:05 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -14,12 +14,11 @@ top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
 OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
-      pg_backup_files.o pg_backup_null.o pg_backup_tar.o sprompt.o \
-      $(STRDUP) $(STRTOUL)
+      pg_backup_files.o pg_backup_null.o pg_backup_tar.o sprompt.o
 
 override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
 
-all: submake pg_dump pg_restore pg_dumpall
+all: submake-libpq submake-libpgport pg_dump pg_restore pg_dumpall
 
 pg_dump: pg_dump.o common.o $(OBJS) $(libpq_builddir)/libpq.a 
 	$(CC) $(CFLAGS) pg_dump.o common.o $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@
@@ -34,10 +33,6 @@ pg_dumpall: pg_dumpall.sh
 	  $< >$@
 	chmod a+x $@
 
-.PHONY: submake
-submake:
-	$(MAKE) -C $(libpq_builddir) all
-
 install: all installdirs
 	$(INSTALL_PROGRAM) pg_dump$(X) $(DESTDIR)$(bindir)/pg_dump$(X)
 	$(INSTALL_PROGRAM) pg_restore$(X) $(DESTDIR)$(bindir)/pg_restore$(X)
@@ -49,12 +44,5 @@ installdirs:
 uninstall:
 	rm -f $(addprefix $(DESTDIR)$(bindir)/, pg_dump$(X) pg_restore$(X) pg_dumpall)
 
-depend dep:
-	$(CC) -MM $(CFLAGS) *.c >depend
-
 clean distclean maintainer-clean:
 	rm -f pg_dump$(X) pg_restore$(X) $(OBJS) pg_dump.o common.o pg_restore.o pg_dumpall
-
-ifeq (depend,$(wildcard depend))
-include depend
-endif
diff --git a/src/bin/pg_encoding/Makefile b/src/bin/pg_encoding/Makefile
index 94d3e08c5ae..a4ca9bb3a29 100644
--- a/src/bin/pg_encoding/Makefile
+++ b/src/bin/pg_encoding/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1998, PostgreSQL Global Development Group
 #
-# $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/Makefile,v 1.14 2001/03/23 05:46:05 ishii Exp $
+# $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/Makefile,v 1.15 2002/07/27 20:10:05 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -14,23 +14,11 @@ include $(top_builddir)/src/Makefile.global
 
 OBJS= pg_encoding.o
 
-all: submake pg_encoding
-
-ifdef STRTOUL
-OBJS+=$(top_builddir)/src/backend/port/strtoul.o
-
-$(top_builddir)/src/backend/port/strtoul.o:
-	$(MAKE) -C $(top_builddir)/src/backend/port strtoul.o
-endif
+all: submake-libpq submake-libpgport pg_encoding
 
 pg_encoding: $(OBJS)
 	$(CC) $(CFLAGS) $^ $(libpq) $(LDFLAGS) $(LIBS) -o $@
 
-.PHONY: submake
-
-submake:
-	$(MAKE) -C $(libpq_builddir) all
-
 install: all installdirs
 	$(INSTALL_PROGRAM) pg_encoding$(X) $(DESTDIR)$(bindir)/pg_encoding$(X)
 
@@ -40,12 +28,5 @@ installdirs:
 uninstall:
 	rm -f $(DESTDIR)$(bindir)/pg_encoding$(X)
 
-depend dep:
-	$(CC) -MM $(CFLAGS) *.c >depend
-
 clean distclean maintainer-clean:
 	rm -f pg_encoding$(X) pg_encoding.o
-
-ifeq (depend,$(wildcard depend))
-include depend
-endif
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index 5baa463bbc1..dbaa5836b48 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.34 2002/07/15 21:34:05 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.35 2002/07/27 20:10:05 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -19,12 +19,9 @@ override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
 
 OBJS=command.o common.o help.o input.o stringutils.o mainloop.o copy.o \
 	startup.o prompt.o variables.o large_obj.o print.o describe.o \
-	sprompt.o tab-complete.o mbprint.o $(SNPRINTF) $(STRDUP) \
-	$(STRERROR) $(STRTOUL)
+	sprompt.o tab-complete.o mbprint.o
 
-all: submake psql
-
-# End of hacks for picking up backend 'port' modules
+all: submake-libpq submake-libpgport psql
 
 psql: $(OBJS) $(libpq_builddir)/libpq.a
 	$(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@
@@ -39,11 +36,6 @@ $(srcdir)/sql_help.h:
 	@echo "*** Perl is needed to build psql help."
 endif
 
-.PHONY: submake
-
-submake:
-	$(MAKE) -C $(libpq_builddir) all
-
 distprep: $(srcdir)/sql_help.h
 
 install: all installdirs
@@ -55,15 +47,8 @@ installdirs:
 uninstall:
 	rm -f $(DESTDIR)$(bindir)/psql$(X)
 
-depend dep:
-	$(CC) -MM -MG $(CFLAGS) *.c >depend
-
 clean distclean:
 	rm -f psql$(X) $(OBJS)
 
 maintainer-clean: distclean
 	rm -f $(srcdir)/sql_help.h
-
-ifeq (depend,$(wildcard depend))
-include depend
-endif
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 212b3cc8a6a..0057c0010bf 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -1,4 +1,4 @@
-# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.84 2002/07/15 21:34:05 momjian Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.85 2002/07/27 20:10:05 petere Exp $
 
 subdir = src/interfaces/ecpg/preproc
 top_builddir = ../../../..
@@ -18,10 +18,9 @@ override CFLAGS += -Wno-error
 endif
 
 OBJS=preproc.o pgc.o type.o ecpg.o ecpg_keywords.o output.o\
-    keywords.o c_keywords.o ../lib/typename.o descriptor.o variable.o \
-    $(SNPRINTF) $(STRDUP)
+    keywords.o c_keywords.o ../lib/typename.o descriptor.o variable.o
 
-all: ecpg
+all: submake-libpgport ecpg
 
 ecpg: $(OBJS)
 	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
@@ -70,11 +69,3 @@ clean distclean:
 # inadequate tools.
 maintainer-clean: distclean
 	rm -f $(srcdir)/preproc.c $(srcdir)/preproc.h $(srcdir)/pgc.c
-
-
-depend dep: preproc.c pgc.c
-	$(CC) -MM $(CFLAGS) *.c >depend
-
-ifeq (depend,$(wildcard depend))
-include depend
-endif
diff --git a/src/interfaces/libpgtcl/Makefile b/src/interfaces/libpgtcl/Makefile
index 32b21685511..09fb7bca5ec 100644
--- a/src/interfaces/libpgtcl/Makefile
+++ b/src/interfaces/libpgtcl/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile,v 1.26 2001/05/11 01:46:33 momjian Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile,v 1.27 2002/07/27 20:10:05 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -27,11 +27,7 @@ SHLIB_LINK = $(libpq)
 # braindead; users of libpq should not need to know what it depends on.)
 SHLIB_LINK+= $(filter -L%, $(LDFLAGS)) $(filter -lcrypt, $(LIBS))
 
-all: submake all-lib
-
-.PHONY: submake
-submake:
-	$(MAKE) -C $(libpq_builddir) all
+all: submake-libpq all-lib
 
 # Shared library stuff
 include $(top_srcdir)/src/Makefile.shlib
diff --git a/src/interfaces/libpq++/examples/Makefile b/src/interfaces/libpq++/examples/Makefile
index d2e9b16a03e..5f4fa65f8bd 100644
--- a/src/interfaces/libpq++/examples/Makefile
+++ b/src/interfaces/libpq++/examples/Makefile
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/interfaces/libpq++/examples/Attic/Makefile,v 1.14 2002/06/20 20:29:54 momjian Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/libpq++/examples/Attic/Makefile,v 1.15 2002/07/27 20:10:05 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -31,8 +31,6 @@ all: $(PROGS)
 $(PROGS): % : %.cc
 	$(CXX) $(CXXFLAGS) -o $@ $@.cc $(LDFLAGS)
 
-.PHONY: submake
-
 clean: 
 	rm -f $(PROGS)
 
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 5700a95a773..804360f07b8 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.63 2002/07/18 03:59:49 momjian Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.64 2002/07/27 20:10:05 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -22,7 +22,7 @@ override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -DFRONTEND -DSYSCONFDIR='"$(sysconf
 
 OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
       pqexpbuffer.o dllist.o md5.o pqsignal.o fe-secure.o \
-      $(notdir $(INET_ATON)) $(notdir $(SNPRINTF)) $(notdir $(STRERROR))
+      $(filter inet_aton.o snprintf.o strerror.o, $(LIBOBJS))
 
 ifdef MULTIBYTE
 OBJS+= wchar.o encnames.o
@@ -54,20 +54,8 @@ md5.c: $(backend_src)/libpq/md5.c
 # symlink the source files in here and build our own object file.
 # this only gets done if configure finds system doesn't have inet_aton()
 
-ifdef INET_ATON
-$(basename $(notdir $(INET_ATON))).c: $(basename $(INET_ATON)).c
+inet_aton.c snprintf.c strerror.c: %.c : $(top_srcdir)/src/port/%.c
 	rm -f $@ && $(LN_S) $< .
-endif
-
-ifdef SNPRINTF
-$(basename $(notdir $(SNPRINTF))).c: $(basename $(SNPRINTF)).c
-	rm -f $@ && $(LN_S) $< .
-endif
-
-ifdef STRERROR
-$(basename $(notdir $(STRERROR))).c: $(basename $(STRERROR)).c
-	rm -f $@ && $(LN_S) $< .
-endif
 
 ifdef MULTIBYTE
 wchar.c : % : $(backend_src)/utils/mb/%
diff --git a/src/makefiles/Makefile.win b/src/makefiles/Makefile.win
index b9b0a7381d6..bcf1165f014 100644
--- a/src/makefiles/Makefile.win
+++ b/src/makefiles/Makefile.win
@@ -1,9 +1,10 @@
-# $Header: /cvsroot/pgsql/src/makefiles/Attic/Makefile.win,v 1.16 2002/07/16 05:46:35 momjian Exp $
+# $Header: /cvsroot/pgsql/src/makefiles/Attic/Makefile.win,v 1.17 2002/07/27 20:10:05 petere Exp $
 LDFLAGS+= -g
 DLLTOOL= dlltool
 DLLWRAP= dllwrap
 DLLLIBS= -lcygipc -lcrypt
 BE_DLLLIBS= -L$(top_builddir)/src/backend -lpostgres
+DLLINIT = $(top_builddir)/src/utils/dllinit.o
 MK_NO_LORDER=true
 MAKE_DLL=true
 #MAKE_DLL=false
diff --git a/src/port/Makefile b/src/port/Makefile
index b005143018a..04d9e049940 100644
--- a/src/port/Makefile
+++ b/src/port/Makefile
@@ -7,7 +7,7 @@
 # with broken/missing library files.
 
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/port/Makefile,v 1.2 2002/07/19 17:35:11 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/port/Makefile,v 1.3 2002/07/27 20:10:05 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -15,9 +15,12 @@ subdir = src/port
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
+ifdef LIBOBJS
+all: libpgport.a
+endif
 
-#
-# The backend/port directory removes these files.
-#
-#distclean clean:
-#	rm -f $(OBJS)
+libpgport.a: $(LIBOBJS)
+	$(AR) crs $@ $^
+
+clean distclean maintainer-clean:
+	rm -f libpgport.a $(LIBOBJS)
diff --git a/src/port/inet_aton.h b/src/port/inet_aton.h
deleted file mode 100644
index d965afc5c7c..00000000000
--- a/src/port/inet_aton.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* $Id: inet_aton.h,v 1.1 2002/07/18 04:13:59 momjian Exp $ */
-
-int			inet_aton(const char *cp, struct in_addr * addr);
diff --git a/src/utils/Makefile b/src/utils/Makefile
new file mode 100644
index 00000000000..26273cd4bd5
--- /dev/null
+++ b/src/utils/Makefile
@@ -0,0 +1,18 @@
+#-------------------------------------------------------------------------
+#
+# Makefile for utils
+#
+# $Header: /cvsroot/pgsql/src/utils/Attic/Makefile,v 1.14 2002/07/27 20:10:05 petere Exp $
+#
+# dllinit.o is only built on Win32 platform.
+#
+#-------------------------------------------------------------------------
+
+subdir = src/utils
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+
+all:
+
+clean distclean maintainer-clean:
+	rm -f dllinit.o
diff --git a/src/backend/port/dllinit.c b/src/utils/dllinit.c
similarity index 100%
rename from src/backend/port/dllinit.c
rename to src/utils/dllinit.c
-- 
GitLab