From 693018b6e926aa9ad49d5e3470b0c75f1188e501 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Sun, 25 Feb 1996 01:25:47 +0100
Subject: [PATCH] `+ optimization done

Rev: doc/builtin/gc:1.1
Rev: doc/simulated/implode:1.2
Rev: lib/master.lpc:1.4
Rev: src/add_efun.h:1.3
Rev: src/backend.c:1.4
Rev: src/backend.h:1.4
Rev: src/builtin_efuns.c:1.12
Rev: src/call_out.h:1.3
Rev: src/configure:1.2
Rev: src/configure.in:1.7
Rev: src/debug.c:1.3(DEAD)
Rev: src/debug.h:1.3(DEAD)
Rev: src/docode.c:1.4
Rev: src/gc.c:1.1
Rev: src/gc.h:1.1
Rev: src/language.y:1.10
Rev: src/las.c:1.5
Rev: src/las.h:1.5
Rev: src/lex.c:1.7
Rev: src/lpc_signal.c:1.8
Rev: src/machine.h.in:1.7
Rev: src/main.c:1.3
Rev: src/modules/files/configure.in:1.4
Rev: src/operators.c:1.3
Rev: src/rusage.c:1.4
Rev: src/test/create_testsuite:1.9
---
 doc/builtin/gc                 |   17 +
 doc/simulated/implode          |    5 +-
 lib/master.lpc                 |   10 +-
 src/add_efun.h                 |    2 +-
 src/backend.c                  |    6 +-
 src/backend.h                  |   18 +-
 src/builtin_efuns.c            |   15 +-
 src/call_out.h                 |   19 +-
 src/configure                  | 1549 +++++++++++++++++++-------------
 src/configure.in               |   50 +-
 src/docode.c                   |   39 +-
 src/gc.c                       |   89 ++
 src/gc.h                       |   30 +
 src/language.y                 |    2 +-
 src/las.c                      |   17 +-
 src/las.h                      |    2 +
 src/lex.c                      |   14 +-
 src/lpc_signal.c               |    9 +-
 src/machine.h.in               |    3 +
 src/main.c                     |   15 +-
 src/modules/files/configure.in |    6 +-
 src/operators.c                |   68 +-
 src/rusage.c                   |   18 +-
 src/test/create_testsuite      |    2 +-
 24 files changed, 1250 insertions(+), 755 deletions(-)
 create mode 100644 doc/builtin/gc
 create mode 100644 src/gc.c
 create mode 100644 src/gc.h

diff --git a/doc/builtin/gc b/doc/builtin/gc
new file mode 100644
index 0000000000..c3d21db790
--- /dev/null
+++ b/doc/builtin/gc
@@ -0,0 +1,17 @@
+NAME
+	gc - do garbage collection
+
+SYNTAX
+	int gc();
+
+DESCRIPTION
+	This function checks all the memory for cyclic structures such
+	as arrays containing themselves and frees them if approperiate.
+	It also frees up destructed objects. It then returns how many
+	arrays/objects/programs/etc. it managed	to free by doing this.
+	
+	Normally there is no need to call this function since uLPC will
+	call it by itself every now and then. (uLPC will try to predict
+	when 20% of all arrays/object/programs in memory is 'garbage'
+	and call this routine then.)
+
diff --git a/doc/simulated/implode b/doc/simulated/implode
index 9c603bae54..21cb7fc3c7 100644
--- a/doc/simulated/implode
+++ b/doc/simulated/implode
@@ -8,14 +8,11 @@ SYNTAX
 
 DESCRIPTION
 	This function is the inverse of explode. It contatenates all the
-	strings in a with a delimeter in between each. If no delimeter is
-	given, an empty string will be used.
+	strings in a with a delimeter in between each.
 
 EXAMPLES
 	> implode( ({ "foo","bar","gazonk"}), "-" );
 	Result: foo-bar-gazonk
-	> implode( ({ "f","o","o" }) );
-	Result: foo
 	> ({ "a","b","c" })*" and ";
 	Result: a and b and c
 	> 
diff --git a/lib/master.lpc b/lib/master.lpc
index 975afdbd8c..bf6d7b91e9 100644
--- a/lib/master.lpc
+++ b/lib/master.lpc
@@ -78,9 +78,9 @@ program handle_inherit(string pname, string current_file)
   string *tmp;
   p=cast_to_program(pname);
   if(p) return p;
-  tmp=explode(current_file,"/");
+  tmp=current_file/"/";
   tmp[-1]=pname;
-  return cast_to_program(implode(tmp,"/"));
+  return cast_to_program(tmp*"/");
 }
 
 mapping (string:object) objects=(["/master.lpc":this_object()]);
@@ -197,14 +197,14 @@ string handle_include(string f, string current_file)
   string *tmp, path;
 /*  perror("Handle include: "+f+"\n"); */
 
-  tmp=explode(current_file, "/");
+  tmp=current_file/"/";
   tmp[-1]=f;
-  path=combine_path(getcwd(),implode(tmp,"/"));
+  path=combine_path(getcwd(),tmp*"/");
   if(file_stat(path)) return path;
   
   if(path=getenv("LPC_INCLUDE_PATH"))
   {
-    foreach(explode(path,":"), path)
+    foreach(path/":", path)
     {
       path=combine_path(path,f);
       if(file_stat(path)) return path;
diff --git a/src/add_efun.h b/src/add_efun.h
index 2400328411..90191795f9 100644
--- a/src/add_efun.h
+++ b/src/add_efun.h
@@ -18,7 +18,7 @@ struct efun
 
 typedef void (*c_fun)(INT32);
 typedef int (*docode_fun)(node *n);
-typedef void (*optimize_fun)(node *n);
+typedef node *(*optimize_fun)(node *n);
 
 struct callable
 {
diff --git a/src/backend.c b/src/backend.c
index f8cb88b7af..0b07f66099 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -4,11 +4,9 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
+#include "backend.h"
 #include <errno.h>
 #include <sys/types.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
 #include <sys/param.h>
 #include <string.h>
 #include "interpret.h"
@@ -16,10 +14,8 @@
 #include "types.h"
 #include "error.h"
 #include "call_out.h"
-#include "backend.h"
 #include "fd_control.h"
 #include "main.h"
-#include "debug.h"
 #include "callback.h"
 
 #ifdef HAVE_SYS_SELECT_H
diff --git a/src/backend.h b/src/backend.h
index a80179d81d..0b556c8359 100644
--- a/src/backend.h
+++ b/src/backend.h
@@ -8,11 +8,23 @@
 
 #include "global.h"
 
-#ifdef HAVE_TIME_H
-#include <time.h>
-#undef HAVE_TIME_H
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  if HAVE_TIME_H
+#   include <time.h>
+#  endif
+# endif
 #endif
 
+#undef HAVE_SYS_TIME_H
+#undef HAVE_TIME_H
+#undef TIME_WITH_SYS_TIME
+
 extern time_t current_time;
 typedef void (*callback)(int,void *);
 
diff --git a/src/builtin_efuns.c b/src/builtin_efuns.c
index 18b85913a0..992553c9cf 100644
--- a/src/builtin_efuns.c
+++ b/src/builtin_efuns.c
@@ -23,9 +23,20 @@
 #include "call_out.h"
 #include "callback.h"
 #include "gc.h"
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  if HAVE_TIME_H
+#   include <time.h>
+#  endif
+# endif
 #endif
+
 #ifdef HAVE_CRYPT_H
 #include <crypt.h>
 #endif
diff --git a/src/call_out.h b/src/call_out.h
index 7f51b71373..d5b9882b21 100644
--- a/src/call_out.h
+++ b/src/call_out.h
@@ -8,12 +8,23 @@
 
 #include "types.h"
 
-#ifdef HAVE_TIME_H
-/* Needed for time_t */
-#include <time.h>
-#undef HAVE_TIME_H
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  if HAVE_TIME_H
+#   include <time.h>
+#  endif
+# endif
 #endif
 
+#undef HAVE_SYS_TIME_H
+#undef HAVE_TIME_H
+#undef TIME_WITH_SYS_TIME
+
 struct call_out_s
 {
   time_t time;
diff --git a/src/configure b/src/configure
index 6a2c705f86..6b0c0b7669 100755
--- a/src/configure
+++ b/src/configure
@@ -1,52 +1,16 @@
-#!/bin/sh
+#! /bin/sh
 
 # Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 1.119 
-# Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+# Generated automatically using autoconf version 2.7 
+# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
 #
-# This configure script is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as published
-# by the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This script is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
 
+# Defaults:
 ac_help=
-
-# Omit some internal or obsolete options to make the list less imposing.
-ac_usage="Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
-  --cache-file=FILE       cache test results in FILE
-  --help                  print this message
-  --no-create             do not create output files
-  --quiet, --silent       do not print \`checking...' messages
-  --version               print the version of autoconf that created configure
-Directory and file names:
-  --exec-prefix=PREFIX    install host dependent files in PREFIX [/usr/local]
-  --prefix=PREFIX         install host independent files in PREFIX [/usr/local]
-  --srcdir=DIR            find the sources in DIR [configure dir or ..]
-  --program-prefix=PREFIX prepend PREFIX to installed program names
-  --program-suffix=SUFFIX append SUFFIX to installed program names
-Host type:
-  --build=BUILD           configure for building on BUILD [BUILD=HOST]
-  --host=HOST             configure for HOST [guessed]
-  --target=TARGET         configure for TARGET [TARGET=HOST]
-Features and packages:
-  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
-  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --x-includes=DIR        X include files are in DIR
-  --x-libraries=DIR       X library files are in DIR
---enable and --with options recognized:$ac_help"
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
@@ -61,16 +25,30 @@ no_recursion=
 prefix=NONE
 program_prefix=NONE
 program_suffix=NONE
-program_transform_name=NONE
+program_transform_name=s,x,x,
 silent=
+site=
 srcdir=
 target=NONE
 verbose=
 x_includes=NONE
 x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
 
 # Initialize some other variables.
 subdirs=
+MFLAGS= MAKEFLAGS=
 
 ac_prev=
 for ac_option
@@ -92,9 +70,14 @@ do
 
   case "$ac_option" in
 
-  -build | --build | --buil | --bui | --bu | --b)
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir="$ac_optarg" ;;
+
+  -build | --build | --buil | --bui | --bu)
     ac_prev=build ;;
-  -build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*)
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
     build="$ac_optarg" ;;
 
   -cache-file | --cache-file | --cache-fil | --cache-fi \
@@ -104,6 +87,12 @@ do
   | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
     cache_file="$ac_optarg" ;;
 
+  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+  | --da=*)
+    datadir="$ac_optarg" ;;
+
   -disable-* | --disable-*)
     ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
     # Reject names that are not valid shell variable names.
@@ -140,9 +129,58 @@ do
     with_gas=yes ;;
 
   -help | --help | --hel | --he)
+    # Omit some internal or obsolete options to make the list less imposing.
+    # This message is too long to be a string in the A/UX 3.1 sh.
     cat << EOF
-$ac_usage
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+  --cache-file=FILE       cache test results in FILE
+  --help                  print this message
+  --no-create             do not create output files
+  --quiet, --silent       do not print \`checking...' messages
+  --version               print the version of autoconf that created configure
+Directory and file names:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [same as prefix]
+  --bindir=DIR            user executables in DIR [EPREFIX/bin]
+  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
+  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
+  --datadir=DIR           read-only architecture-independent data in DIR
+                          [PREFIX/share]
+  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
+                          [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
+  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
+  --includedir=DIR        C header files in DIR [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
+  --infodir=DIR           info documentation in DIR [PREFIX/info]
+  --mandir=DIR            man documentation in DIR [PREFIX/man]
+  --srcdir=DIR            find the sources in DIR [configure dir or ..]
+  --program-prefix=PREFIX prepend PREFIX to installed program names
+  --program-suffix=SUFFIX append SUFFIX to installed program names
+  --program-transform-name=PROGRAM
+                          run sed PROGRAM on installed program names
 EOF
+    cat << EOF
+Host type:
+  --build=BUILD           configure for building on BUILD [BUILD=HOST]
+  --host=HOST             configure for HOST [guessed]
+  --target=TARGET         configure for TARGET [TARGET=HOST]
+Features and packages:
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --x-includes=DIR        X include files are in DIR
+  --x-libraries=DIR       X library files are in DIR
+EOF
+    if test -n "$ac_help"; then
+      echo "--enable and --with options recognized:$ac_help"
+    fi
     exit 0 ;;
 
   -host | --host | --hos | --ho)
@@ -150,6 +188,44 @@ EOF
   -host=* | --host=* | --hos=* | --ho=*)
     host="$ac_optarg" ;;
 
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir="$ac_optarg" ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir="$ac_optarg" ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir="$ac_optarg" ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir="$ac_optarg" ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst \
+  | --locals | --local | --loca | --loc | --lo)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+    localstatedir="$ac_optarg" ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir="$ac_optarg" ;;
+
   -nfp | --nfp | --nf)
     # Obsolete; use --without-fp.
     with_fp=no ;;
@@ -162,6 +238,15 @@ EOF
   | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
     no_recursion=yes ;;
 
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir="$ac_optarg" ;;
+
   -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
     ac_prev=prefix ;;
   -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
@@ -202,11 +287,40 @@ EOF
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir="$ac_optarg" ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir="$ac_optarg" ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site="$ac_optarg" ;;
+
   -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
     ac_prev=srcdir ;;
   -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
     srcdir="$ac_optarg" ;;
 
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir="$ac_optarg" ;;
+
   -target | --target | --targe | --targ | --tar | --ta | --t)
     ac_prev=target ;;
   -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
@@ -216,7 +330,7 @@ EOF
     verbose=yes ;;
 
   -version | --version | --versio | --versi | --vers)
-    echo "configure generated by autoconf version 1.119"
+    echo "configure generated by autoconf version 2.7"
     exit 0 ;;
 
   -with-* | --with-*)
@@ -262,7 +376,7 @@ EOF
   -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
     ;;
 
-  *) 
+  *)
     if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
       echo "configure: warning: $ac_option: invalid host type" 1>&2
     fi
@@ -279,19 +393,20 @@ if test -n "$ac_prev"; then
   { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
 fi
 
-trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
 
 # File descriptor usage:
-# 0 unused; standard input
+# 0 standard input
 # 1 file creation
 # 2 errors and warnings
-# 3 unused; some systems may open it to /dev/tty
-# 4 checking for... messages and results
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
 # 5 compiler messages saved in config.log
 if test "$silent" = yes; then
-  exec 4>/dev/null
+  exec 6>/dev/null
 else
-  exec 4>&1
+  exec 6>&1
 fi
 exec 5>./config.log
 
@@ -353,17 +468,14 @@ if test ! -r $srcdir/$ac_unique_file; then
     { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
   fi
 fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
 
 # Prefer explicitly selected file to automatically selected ones.
 if test -z "$CONFIG_SITE"; then
   if test "x$prefix" != xNONE; then
-    CONFIG_SITE=$prefix/lib/config.site
+    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
   else
-    CONFIG_SITE=/usr/local/lib/config.site
-  fi
-  # System dependent files override system independent ones.
-  if test "x$exec_prefix" != xNONE && test "x$exec_prefix" != "x$prefix"; then
-    CONFIG_SITE="$CONFIG_SITE $exec_prefix/lib/config.site"
+    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
   fi
 fi
 for ac_site_file in $CONFIG_SITE; do
@@ -383,8 +495,12 @@ fi
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_link='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext -o conftest $LIBS 1>&5 2>&5'
+ac_cpp='echo $CPP $CPPFLAGS 1>&5;
+$CPP $CPPFLAGS'
+ac_compile='echo ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5;
+${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5'
+ac_link='echo ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5;
+${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5'
 
 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
@@ -401,9 +517,9 @@ fi
 
 # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_prog_CC'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -422,19 +538,19 @@ fi
 fi
 CC="$ac_cv_prog_CC"
 if test -n "$CC"; then
-  echo "$ac_t""$CC" 1>&4
+  echo "$ac_t""$CC" 1>&6
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 
 
-echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_prog_gcc'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.c <<EOF
 #ifdef __GNUC__
-  yes
+  yes;
 #endif
 EOF
 if ${CC-cc} -E conftest.c 2>&5 | egrep yes >/dev/null 2>&1; then
@@ -443,13 +559,14 @@ else
   ac_cv_prog_gcc=no
 fi
 fi
-echo "$ac_t""$ac_cv_prog_gcc" 1>&4
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
 if test $ac_cv_prog_gcc = yes; then
   GCC=yes
   if test "${CFLAGS+set}" != set; then
-    echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_prog_gcc_g'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+    echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_gcc_g'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   echo 'void f(){}' > conftest.c
 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
@@ -460,7 +577,8 @@ fi
 rm -f conftest*
 
 fi
-    echo "$ac_t""$ac_cv_prog_gcc_g" 1>&4
+
+echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6
     if test $ac_cv_prog_gcc_g = yes; then
       CFLAGS="-g -O"
     else
@@ -476,9 +594,9 @@ fi
 # We need some special hacks when running slowaris
 # Extract the first word of "uname", so it can be a program name with args.
 set dummy uname; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_path_uname_prog'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_path_uname_prog'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   case "$uname_prog" in
   /*)
@@ -500,14 +618,14 @@ esac
 fi
 uname_prog="$ac_cv_path_uname_prog"
 if test -n "$uname_prog"; then
-  echo "$ac_t""$uname_prog" 1>&4
+  echo "$ac_t""$uname_prog" 1>&6
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 
-echo $ac_n "checking operating system""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_sys_os'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking operating system""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_sys_os'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 if test "$uname_prog" != "no"; then
@@ -524,20 +642,20 @@ fi
 
 fi
 
-echo "$ac_t""$lpc_cv_sys_os" 1>&4
+echo "$ac_t""$lpc_cv_sys_os" 1>&6
 
 
 OLD_CFLAGS="$CFLAGS"
 OPTIMIZE="";
 
-echo $ac_n "checking -O""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_option_opt'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking -O""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_option_opt'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   CFLAGS="$OLD_CFLAGS -O"
   cat > conftest.$ac_ext <<EOF
-#line 541 "configure"
+#line 659 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -561,15 +679,54 @@ fi
 if test "$lpc_cv_option_opt" = "yes" ; then
   CFLAGS="$OLD_CFLAGS -O"
   OPTIMIZE="$OPTIMIZE -O"
-  echo "$ac_t""-O found" 1>&4
+  echo "$ac_t""-O found" 1>&6
 else
-  echo "$ac_t""-O not found" 1>&4
+  echo "$ac_t""-O not found" 1>&6
 fi
 
 CFLAGS="$OLD_CFLAGS"
 
 if test "$GCC" = "yes"; then
-  WARN="-g -pipe -W -Wunused -Wformat"
+  WARN="-g -W -Wunused -Wformat"
+
+  echo $ac_n "checking -pipe""... $ac_c" 1>&6
+  if eval "test \"`echo '$''{'lpc_cv_option_pipe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  
+    CFLAGS="$OLD_CFLAGS -pipe"
+    cat > conftest.$ac_ext <<EOF
+#line 700 "configure"
+#include "confdefs.h"
+
+int main() { return 0; }
+int t() {
+ exit(0); 
+; return 0; }
+EOF
+if eval $ac_link; then
+  rm -rf conftest*
+  lpc_cv_option_pipe=yes
+else
+  rm -rf conftest*
+  lpc_cv_option_pipe=no
+fi
+rm -f conftest*
+
+  
+fi
+
+
+  if test "$lpc_cv_option_pipe" = "yes" ; then
+    CFLAGS="$OLD_CFLAGS -pipe"
+    OPTIMIZE="$OPTIMIZE -pipe"
+    echo "$ac_t""-pipe found" 1>&6
+  else
+    echo "$ac_t""-pipe not found" 1>&6
+    CFLAGS="$OLD_CFLAGS"
+  fi
+
+
 else
   WARN=""
 #
@@ -579,7 +736,7 @@ else
     OLD_CC="${CC-cc}"
     CC="$CC -Aa -D_HPUX_SOURCE +Olibcalls"
     cat > conftest.$ac_ext <<EOF
-#line 583 "configure"
+#line 740 "configure"
 #include "confdefs.h"
 int foo(int bar);
 int main() { return 0; }
@@ -598,13 +755,13 @@ rm -f conftest*
   fi
 fi
 
-echo $ac_n "checking ansi prototype capability""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_sys_ansi_prototypes'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking ansi prototype capability""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_sys_ansi_prototypes'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 608 "configure"
+#line 765 "configure"
 #include "confdefs.h"
 int foo(int bar);
 int main() { return 0; }
@@ -626,9 +783,9 @@ fi
 
 
 if test "$lpc_cv_sys_ansi_prototypes" = "yes"; then
-  echo "$ac_t""yes" 1>&4
+  echo "$ac_t""yes" 1>&6
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
   exit 1
 fi
 
@@ -662,15 +819,16 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
-echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&4
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
 if test -z "$INSTALL"; then
-if eval "test \"`echo '${'ac_cv_path_install'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
     IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
   for ac_dir in $PATH; do
-    case "$ac_dir" in
-    ''|.|/etc|/usr/sbin|/usr/etc|/sbin|/usr/afsws/bin|/usr/ucb) ;;
+    # Account for people who put trailing slashes in PATH elements.
+    case "$ac_dir/" in
+    /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
     *)
       # OSF1 and SCO ODT 3.0 have their own names for install.
       for ac_prog in ginstall installbsd scoinst install; do
@@ -690,12 +848,19 @@ else
     esac
   done
   IFS="$ac_save_ifs"
-  # As a last resort, use the slow shell script.
-  test -z "$ac_cv_path_install" && ac_cv_path_install="$ac_install_sh"
+
 fi
-  INSTALL="$ac_cv_path_install"
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL="$ac_cv_path_install"
+  else
+    # As a last resort, use the slow shell script.  We don't cache a
+    # path for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the path is relative.
+    INSTALL="$ac_install_sh"
+  fi
 fi
-echo "$ac_t""$INSTALL" 1>&4
+echo "$ac_t""$INSTALL" 1>&6
 
 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
 # It thinks the first close brace ends the variable substitution.
@@ -707,9 +872,9 @@ for ac_prog in 'bison -y' byacc
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_prog_YACC'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$YACC"; then
   ac_cv_prog_YACC="$YACC" # Let the user override the test.
@@ -727,23 +892,23 @@ fi
 fi
 YACC="$ac_cv_prog_YACC"
 if test -n "$YACC"; then
-  echo "$ac_t""$YACC" 1>&4
+  echo "$ac_t""$YACC" 1>&6
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 
 test -n "$YACC" && break
 done
 test -n "$YACC" || YACC="yacc"
 
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&4
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
 fi
 if test -z "$CPP"; then
-if eval "test \"`echo '${'ac_cv_prog_CPP'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
     # This must be in double quotes, not single quotes, because CPP may get
   # substituted into the Makefile and "${CC-cc}" will confuse make.
@@ -751,9 +916,9 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 755 "configure"
+#line 920 "configure"
 #include "confdefs.h"
-#include <stdio.h>
+#include <assert.h>
 Syntax Error
 EOF
 eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
@@ -765,9 +930,9 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 769 "configure"
+#line 934 "configure"
 #include "confdefs.h"
-#include <stdio.h>
+#include <assert.h>
 Syntax Error
 EOF
 eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
@@ -784,15 +949,17 @@ fi
 rm -f conftest*
   ac_cv_prog_CPP="$CPP"
 fi
+  CPP="$ac_cv_prog_CPP"
+else
+  ac_cv_prog_CPP="$CPP"
 fi
-CPP="$ac_cv_prog_CPP"
-echo "$ac_t""$CPP" 1>&4
+echo "$ac_t""$CPP" 1>&6
 
 # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_prog_RANLIB'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
@@ -811,15 +978,15 @@ fi
 fi
 RANLIB="$ac_cv_prog_RANLIB"
 if test -n "$RANLIB"; then
-  echo "$ac_t""$RANLIB" 1>&4
+  echo "$ac_t""$RANLIB" 1>&6
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 
-echo $ac_n "checking whether ${MAKE-make} sets \$MAKE""... $ac_c" 1>&4
+echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
 set dummy ${MAKE-make}; ac_make=$2
-if eval "test \"`echo '${'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftestmake <<\EOF
 all:
@@ -835,17 +1002,17 @@ fi
 rm -f conftestmake
 fi
 if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
-  echo "$ac_t""yes" 1>&4
+  echo "$ac_t""yes" 1>&6
   SET_MAKE=
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
   SET_MAKE="MAKE=${MAKE-make}"
 fi
 
 
-echo $ac_n "checking first yacc define""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_yacc_first'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking first yacc define""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_yacc_first'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat >conftest.y <<\EOF
@@ -869,7 +1036,7 @@ fi
 
 fi
 
-echo "$ac_t""$lpc_cv_yacc_first" 1>&4
+echo "$ac_t""$lpc_cv_yacc_first" 1>&6
 cat >> confdefs.h <<EOF
 #define F_OFFSET $lpc_cv_yacc_first
 EOF
@@ -877,54 +1044,50 @@ EOF
 
 rm -rf conftest.y y.tab.c y.tab.h conftest.out
 
-for ac_hdr in sys/rusage.h sys/time.h unistd.h stdlib.h memory.h values.h \
- string.h fcntl.h sys/filio.h sys/sockio.h crypt.h locale.h sys/resource.h \
- sys/select.h netdb.h
-do
-ac_safe=`echo "$ac_hdr" | tr './' '__'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_header_$ac_safe'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 891 "configure"
+#line 1053 "configure"
 #include "confdefs.h"
-#include <$ac_hdr>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+int main() { return 0; }
+int t() {
+struct tm *tp;
+; return 0; }
 EOF
-eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
+if eval $ac_compile; then
   rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
+  ac_cv_header_time=yes
 else
-  echo "$ac_err" >&5
   rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
+  ac_cv_header_time=no
 fi
 rm -f conftest*
+
 fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
-  echo "$ac_t""yes" 1>&4
-    ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./' '[A-Z]__'`
-  cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
+
+echo "$ac_t""$ac_cv_header_time" 1>&6
+if test $ac_cv_header_time = yes; then
+  cat >> confdefs.h <<\EOF
+#define TIME_WITH_SYS_TIME 1
 EOF
- 
-else
-  echo "$ac_t""no" 1>&4
+
 fi
-done
 
 # If we cannot run a trivial program, we must be cross compiling.
-echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_c_cross'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$cross_compiling" = yes; then
-  ac_cv_cross=yes
+  ac_cv_c_cross=yes
 else
 cat > conftest.$ac_ext <<EOF
-#line 928 "configure"
+#line 1091 "configure"
 #include "confdefs.h"
 main(){return(0);}
 EOF
@@ -937,15 +1100,16 @@ fi
 fi
 rm -fr conftest*
 fi
+
+echo "$ac_t""$ac_cv_c_cross" 1>&6
 cross_compiling=$ac_cv_c_cross
-echo "$ac_t""$ac_cv_c_cross" 1>&4
 
-echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_header_stdc'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 949 "configure"
+#line 1113 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -967,7 +1131,7 @@ rm -f conftest*
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 971 "configure"
+#line 1135 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -985,7 +1149,7 @@ fi
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 989 "configure"
+#line 1153 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1003,10 +1167,10 @@ fi
 if test $ac_cv_header_stdc = yes; then
   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
 if test "$cross_compiling" = yes; then
-  ac_cv_header_stdc=no
+  :
 else
 cat > conftest.$ac_ext <<EOF
-#line 1010 "configure"
+#line 1174 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1027,7 +1191,8 @@ fi
 rm -fr conftest*
 fi
 fi
-echo "$ac_t""$ac_cv_header_stdc" 1>&4
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
 if test $ac_cv_header_stdc = yes; then
   cat >> confdefs.h <<\EOF
 #define STDC_HEADERS 1
@@ -1035,16 +1200,54 @@ EOF
 
 fi
 
+for ac_hdr in sys/rusage.h time.h sys/time.h unistd.h stdlib.h memory.h \
+values.h string.h fcntl.h sys/filio.h sys/sockio.h crypt.h locale.h \
+sys/resource.h sys/select.h netdb.h
+do
+ac_safe=`echo "$ac_hdr" | tr './\055' '___'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1214 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_hdr=HAVE_`echo $ac_hdr | tr 'abcdefghijklmnopqrstuvwxyz./\055' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ___'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+ 
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
 
-echo $ac_n "checking size of char *""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_sizeof_char_p'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking size of char *""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_sizeof_char_p'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 1048 "configure"
+#line 1251 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -1058,25 +1261,27 @@ EOF
 eval $ac_link
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
   ac_cv_sizeof_char_p=`cat conftestval`
+else
+  ac_cv_sizeof_char_p=0
 fi
 fi
 rm -fr conftest*
 fi
-echo "$ac_t""$ac_cv_sizeof_char_p" 1>&4
+echo "$ac_t""$ac_cv_sizeof_char_p" 1>&6
 cat >> confdefs.h <<EOF
 #define SIZEOF_CHAR_P $ac_cv_sizeof_char_p
 EOF
 
 
-echo $ac_n "checking size of long""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_sizeof_long'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking size of long""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 1080 "configure"
+#line 1285 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -1090,25 +1295,27 @@ EOF
 eval $ac_link
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
   ac_cv_sizeof_long=`cat conftestval`
+else
+  ac_cv_sizeof_long=0
 fi
 fi
 rm -fr conftest*
 fi
-echo "$ac_t""$ac_cv_sizeof_long" 1>&4
+echo "$ac_t""$ac_cv_sizeof_long" 1>&6
 cat >> confdefs.h <<EOF
 #define SIZEOF_LONG $ac_cv_sizeof_long
 EOF
 
 
-echo $ac_n "checking size of int""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_sizeof_int'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking size of int""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 1112 "configure"
+#line 1319 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -1122,25 +1329,27 @@ EOF
 eval $ac_link
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
   ac_cv_sizeof_int=`cat conftestval`
+else
+  ac_cv_sizeof_int=0
 fi
 fi
 rm -fr conftest*
 fi
-echo "$ac_t""$ac_cv_sizeof_int" 1>&4
+echo "$ac_t""$ac_cv_sizeof_int" 1>&6
 cat >> confdefs.h <<EOF
 #define SIZEOF_INT $ac_cv_sizeof_int
 EOF
 
 
-echo $ac_n "checking size of short""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_sizeof_short'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking size of short""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 1144 "configure"
+#line 1353 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -1154,25 +1363,27 @@ EOF
 eval $ac_link
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
   ac_cv_sizeof_short=`cat conftestval`
+else
+  ac_cv_sizeof_short=0
 fi
 fi
 rm -fr conftest*
 fi
-echo "$ac_t""$ac_cv_sizeof_short" 1>&4
+echo "$ac_t""$ac_cv_sizeof_short" 1>&6
 cat >> confdefs.h <<EOF
 #define SIZEOF_SHORT $ac_cv_sizeof_short
 EOF
 
 
-echo $ac_n "checking size of float""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_sizeof_float'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking size of float""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 1176 "configure"
+#line 1387 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -1186,25 +1397,27 @@ EOF
 eval $ac_link
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
   ac_cv_sizeof_float=`cat conftestval`
+else
+  ac_cv_sizeof_float=0
 fi
 fi
 rm -fr conftest*
 fi
-echo "$ac_t""$ac_cv_sizeof_float" 1>&4
+echo "$ac_t""$ac_cv_sizeof_float" 1>&6
 cat >> confdefs.h <<EOF
 #define SIZEOF_FLOAT $ac_cv_sizeof_float
 EOF
 
 
-echo $ac_n "checking size of double""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_sizeof_double'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking size of double""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 1208 "configure"
+#line 1421 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -1218,23 +1431,25 @@ EOF
 eval $ac_link
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
   ac_cv_sizeof_double=`cat conftestval`
+else
+  ac_cv_sizeof_double=0
 fi
 fi
 rm -fr conftest*
 fi
-echo "$ac_t""$ac_cv_sizeof_double" 1>&4
+echo "$ac_t""$ac_cv_sizeof_double" 1>&6
 cat >> confdefs.h <<EOF
 #define SIZEOF_DOUBLE $ac_cv_sizeof_double
 EOF
 
 
 
-echo $ac_n "checking for size_t""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_type_size_t'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for size_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1238 "configure"
+#line 1453 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1252,7 +1467,7 @@ fi
 rm -f conftest*
 
 fi
-echo "$ac_t""$ac_cv_type_size_t" 1>&4
+echo "$ac_t""$ac_cv_type_size_t" 1>&6
 if test $ac_cv_type_size_t = no; then
   cat >> confdefs.h <<\EOF
 #define size_t unsigned
@@ -1260,12 +1475,12 @@ EOF
 
 fi
 
-echo $ac_n "checking for pid_t""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_type_pid_t'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for pid_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1269 "configure"
+#line 1484 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1283,7 +1498,7 @@ fi
 rm -f conftest*
 
 fi
-echo "$ac_t""$ac_cv_type_pid_t" 1>&4
+echo "$ac_t""$ac_cv_type_pid_t" 1>&6
 if test $ac_cv_type_pid_t = no; then
   cat >> confdefs.h <<\EOF
 #define pid_t int
@@ -1291,12 +1506,12 @@ EOF
 
 fi
 
-echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_type_uid_t'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1300 "configure"
+#line 1515 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -1311,7 +1526,8 @@ fi
 rm -f conftest*
 
 fi
-echo "$ac_t""$ac_cv_type_uid_t" 1>&4
+
+echo "$ac_t""$ac_cv_type_uid_t" 1>&6
 if test $ac_cv_type_uid_t = no; then
   cat >> confdefs.h <<\EOF
 #define uid_t int
@@ -1323,25 +1539,30 @@ EOF
 
 fi
 
-echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_type_signal'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1332 "configure"
+#line 1548 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
 #ifdef signal
 #undef signal
 #endif
-extern void (*signal ()) ();
+#ifdef __cplusplus
+extern "C" void (*signal (int, void (*)(int)))(int);
+#else
+void (*signal ()) ();
+#endif
+
 int main() { return 0; }
 int t() {
 int i;
 ; return 0; }
 EOF
-if eval $ac_link; then
+if eval $ac_compile; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -1351,18 +1572,19 @@ fi
 rm -f conftest*
 
 fi
-echo "$ac_t""$ac_cv_type_signal" 1>&4
+
+echo "$ac_t""$ac_cv_type_signal" 1>&6
 cat >> confdefs.h <<EOF
 #define RETSIGTYPE $ac_cv_type_signal
 EOF
 
 
-echo $ac_n "checking for time_t""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_type_time_t'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for time_t""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_type_time_t'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1366 "configure"
+#line 1588 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1380,7 +1602,7 @@ fi
 rm -f conftest*
 
 fi
-echo "$ac_t""$ac_cv_type_time_t" 1>&4
+echo "$ac_t""$ac_cv_type_time_t" 1>&6
 if test $ac_cv_type_time_t = no; then
   cat >> confdefs.h <<\EOF
 #define time_t INT32
@@ -1389,14 +1611,15 @@ EOF
 fi
 
 
-echo $ac_n "checking for -lPW""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_lib_PW'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for -lPW""... $ac_c" 1>&6
+ac_lib_var=`echo PW | tr '.-/+' '___p'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="$LIBS -lPW "
+LIBS="-lPW  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1400 "configure"
+#line 1623 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1406,36 +1629,37 @@ alloca()
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_lib_PW=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_lib_PW=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
-if eval "test \"`echo '$ac_cv_lib_'PW`\" = yes"; then
-  echo "$ac_t""yes" 1>&4
-    ac_tr_lib=HAVE_LIB`echo PW | tr '[a-z]' '[A-Z]'`
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo PW | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
   cat >> confdefs.h <<EOF
 #define $ac_tr_lib 1
 EOF
 
-  LIBS="$LIBS -lPW"
+  LIBS="-lPW $LIBS"
 
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 
-echo $ac_n "checking for -lm""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_lib_m'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for -lm""... $ac_c" 1>&6
+ac_lib_var=`echo m | tr '.-/+' '___p'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="$LIBS -lm "
+LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1439 "configure"
+#line 1663 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1445,36 +1669,41 @@ floor()
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_lib_m=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_lib_m=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
-if eval "test \"`echo '$ac_cv_lib_'m`\" = yes"; then
-  echo "$ac_t""yes" 1>&4
-    ac_tr_lib=HAVE_LIB`echo m | tr '[a-z]' '[A-Z]'`
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo m | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
   cat >> confdefs.h <<EOF
 #define $ac_tr_lib 1
 EOF
 
-  LIBS="$LIBS -lm"
+  LIBS="-lm $LIBS"
 
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 
-echo $ac_n "checking for -lsocket""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_lib_socket'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+if test "${ac_cv_lib_m}" = "no" -a "${lpc_cv_sys_os}" = "Linux"; then
+  echo "configure: warning: I will compensate for this by adding -lc -lm" 1>&2
+  LIBS="${LIBS} -lc -lm"
+fi
+echo $ac_n "checking for -lsocket""... $ac_c" 1>&6
+ac_lib_var=`echo socket | tr '.-/+' '___p'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="$LIBS -lsocket "
+LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1478 "configure"
+#line 1707 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1484,36 +1713,37 @@ socket()
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_lib_socket=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_lib_socket=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
-if eval "test \"`echo '$ac_cv_lib_'socket`\" = yes"; then
-  echo "$ac_t""yes" 1>&4
-    ac_tr_lib=HAVE_LIB`echo socket | tr '[a-z]' '[A-Z]'`
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo socket | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
   cat >> confdefs.h <<EOF
 #define $ac_tr_lib 1
 EOF
 
-  LIBS="$LIBS -lsocket"
+  LIBS="-lsocket $LIBS"
 
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 
-echo $ac_n "checking for -lcrypt""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_lib_crypt'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for -lcrypt""... $ac_c" 1>&6
+ac_lib_var=`echo crypt | tr '.-/+' '___p'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="$LIBS -lcrypt "
+LIBS="-lcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1517 "configure"
+#line 1747 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1523,37 +1753,38 @@ crypt()
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_lib_crypt=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_lib_crypt=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
-if eval "test \"`echo '$ac_cv_lib_'crypt`\" = yes"; then
-  echo "$ac_t""yes" 1>&4
-    ac_tr_lib=HAVE_LIB`echo crypt | tr '[a-z]' '[A-Z]'`
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo crypt | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
   cat >> confdefs.h <<EOF
 #define $ac_tr_lib 1
 EOF
 
-  LIBS="$LIBS -lcrypt"
+  LIBS="-lcrypt $LIBS"
 
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 
 if test "$ac_cv_lib_socket" = yes -o "$ac_cv_lib_ucb"; then
- echo $ac_n "checking for -lnsl""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_lib_nsl'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+ echo $ac_n "checking for -lnsl""... $ac_c" 1>&6
+ac_lib_var=`echo nsl | tr '.-/+' '___p'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="$LIBS -lnsl "
+LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1557 "configure"
+#line 1788 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -1563,26 +1794,26 @@ main()
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_lib_nsl=yes"
+  eval "ac_cv_lib_$ac_lib_var=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_lib_nsl=no"
+  eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
-if eval "test \"`echo '$ac_cv_lib_'nsl`\" = yes"; then
-  echo "$ac_t""yes" 1>&4
-    ac_tr_lib=HAVE_LIB`echo nsl | tr '[a-z]' '[A-Z]'`
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo nsl | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
   cat >> confdefs.h <<EOF
 #define $ac_tr_lib 1
 EOF
 
-  LIBS="$LIBS -lnsl"
+  LIBS="-lnsl $LIBS"
 
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 
 fi
@@ -1590,15 +1821,15 @@ fi
 
 OLD_LIBOBJS="${LIBOBJS}"
 
-echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_func_memcmp'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_func_memcmp'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$cross_compiling" = yes; then
   ac_cv_func_memcmp=no
 else
 cat > conftest.$ac_ext <<EOF
-#line 1602 "configure"
+#line 1833 "configure"
 #include "confdefs.h"
 
 main()
@@ -1617,7 +1848,8 @@ fi
 fi
 rm -fr conftest*
 fi
-echo "$ac_t""$ac_cv_func_memcmp" 1>&4
+
+echo "$ac_t""$ac_cv_func_memcmp" 1>&6
 test $ac_cv_func_memcmp = no && LIBOBJS="$LIBOBJS memcmp.o"
 
 
@@ -1630,17 +1862,52 @@ fi
 
 LIBOBJS="${OLD_LIBOBJS}"
 
+echo $ac_n "checking for strcoll""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_func_strcoll'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_func_strcoll=no
+else
+cat > conftest.$ac_ext <<EOF
+#line 1874 "configure"
+#include "confdefs.h"
+#include <string.h>
+main ()
+{
+  exit (strcoll ("abc", "def") >= 0 ||
+	strcoll ("ABC", "DEF") >= 0 ||
+	strcoll ("123", "456") >= 0);
+}
+EOF
+eval $ac_link
+if test -s conftest && (./conftest; exit) 2>/dev/null; then
+  ac_cv_func_strcoll=yes
+else
+  ac_cv_func_strcoll=no
+fi
+fi
+rm -fr conftest*
+fi
+
+echo "$ac_t""$ac_cv_func_strcoll" 1>&6
+if test $ac_cv_func_strcoll = yes; then
+  cat >> confdefs.h <<\EOF
+#define HAVE_STRCOLL 1
+EOF
+
+fi
+
+
 for ac_func in _crypt \
  bcopy \
  bzero \
  clock \
  crypt \
  fchmod \
- getcwd \
  getenv \
  getrlimit \
  getrusage \
- getwd \
  index \
  memchr \
  memcpy \
@@ -1648,6 +1915,8 @@ for ac_func in _crypt \
  rindex \
  setlocale \
  setrlimit \
+ sigaction \
+ sigvec \
  strcasecmp \
  strchr \
  strcspn \
@@ -1658,16 +1927,24 @@ for ac_func in _crypt \
  times \
  vfprintf \
  vsprintf \
+ wait3 \
+ wait4 \
+ waitpid \
 
 do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_func_$ac_func'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1669 "configure"
+#line 1941 "configure"
 #include "confdefs.h"
-#include <ctype.h> /* Arbitrary system header to define __stub macros. */
+/* 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.  */
+char $ac_func();
+
 int main() { return 0; }
 int t() {
 
@@ -1677,8 +1954,7 @@ int t() {
 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
 choke me
 #else
-/* Override any gcc2 internal prototype to avoid an error.  */
-char $ac_func(); $ac_func();
+$ac_func();
 #endif
 
 ; return 0; }
@@ -1694,14 +1970,14 @@ rm -f conftest*
 
 fi
 if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
-  echo "$ac_t""yes" 1>&4
-    ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'`
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
   cat >> confdefs.h <<EOF
 #define $ac_tr_func 1
 EOF
  
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 done
 
@@ -1709,16 +1985,16 @@ done
 
 
 
- echo $ac_n "checking for strchr declaration""... $ac_c" 1>&4
- if eval "test \"`echo '${'lpc_cv_decl_strchr'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+ echo $ac_n "checking for strchr declaration""... $ac_c" 1>&6
+ if eval "test \"`echo '$''{'lpc_cv_decl_strchr'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
    lpc_cv_decl_strchr=nonexistant
    for a in string.h unistd.h stdlib.h
    do
      cat > conftest.$ac_ext <<EOF
-#line 1722 "configure"
+#line 1998 "configure"
 #include "confdefs.h"
 #include <$a>
 EOF
@@ -1733,7 +2009,7 @@ rm -f conftest*
  
 fi
 
- echo "$ac_t""$lpc_cv_decl_strchr" 1>&4
+ echo "$ac_t""$lpc_cv_decl_strchr" 1>&6
  if test "$lpc_cv_decl_strchr" = nonexistant; then
    cat >> confdefs.h <<\EOF
 #define STRCHR_DECL_MISSING 1
@@ -1742,16 +2018,16 @@ EOF
  fi
 
 
- echo $ac_n "checking for malloc declaration""... $ac_c" 1>&4
- if eval "test \"`echo '${'lpc_cv_decl_malloc'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+ echo $ac_n "checking for malloc declaration""... $ac_c" 1>&6
+ if eval "test \"`echo '$''{'lpc_cv_decl_malloc'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
    lpc_cv_decl_malloc=nonexistant
    for a in memory.h unistd.h stdlib.h
    do
      cat > conftest.$ac_ext <<EOF
-#line 1755 "configure"
+#line 2031 "configure"
 #include "confdefs.h"
 #include <$a>
 EOF
@@ -1766,7 +2042,7 @@ rm -f conftest*
  
 fi
 
- echo "$ac_t""$lpc_cv_decl_malloc" 1>&4
+ echo "$ac_t""$lpc_cv_decl_malloc" 1>&6
  if test "$lpc_cv_decl_malloc" = nonexistant; then
    cat >> confdefs.h <<\EOF
 #define MALLOC_DECL_MISSING 1
@@ -1775,16 +2051,16 @@ EOF
  fi
 
 
- echo $ac_n "checking for getpeername declaration""... $ac_c" 1>&4
- if eval "test \"`echo '${'lpc_cv_decl_getpeername'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+ echo $ac_n "checking for getpeername declaration""... $ac_c" 1>&6
+ if eval "test \"`echo '$''{'lpc_cv_decl_getpeername'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
    lpc_cv_decl_getpeername=nonexistant
    for a in sys/socket.h sys/socketvar.h sys/socketio.h
    do
      cat > conftest.$ac_ext <<EOF
-#line 1788 "configure"
+#line 2064 "configure"
 #include "confdefs.h"
 #include <$a>
 EOF
@@ -1799,7 +2075,7 @@ rm -f conftest*
  
 fi
 
- echo "$ac_t""$lpc_cv_decl_getpeername" 1>&4
+ echo "$ac_t""$lpc_cv_decl_getpeername" 1>&6
  if test "$lpc_cv_decl_getpeername" = nonexistant; then
    cat >> confdefs.h <<\EOF
 #define GETPEERNAME_DECL_MISSING 1
@@ -1808,16 +2084,16 @@ EOF
  fi
 
 
- echo $ac_n "checking for popen declaration""... $ac_c" 1>&4
- if eval "test \"`echo '${'lpc_cv_decl_popen'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+ echo $ac_n "checking for popen declaration""... $ac_c" 1>&6
+ if eval "test \"`echo '$''{'lpc_cv_decl_popen'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
    lpc_cv_decl_popen=nonexistant
    for a in stdio.h unistd.h
    do
      cat > conftest.$ac_ext <<EOF
-#line 1821 "configure"
+#line 2097 "configure"
 #include "confdefs.h"
 #include <$a>
 EOF
@@ -1832,7 +2108,7 @@ rm -f conftest*
  
 fi
 
- echo "$ac_t""$lpc_cv_decl_popen" 1>&4
+ echo "$ac_t""$lpc_cv_decl_popen" 1>&6
  if test "$lpc_cv_decl_popen" = nonexistant; then
    cat >> confdefs.h <<\EOF
 #define POPEN_DECL_MISSING 1
@@ -1841,16 +2117,16 @@ EOF
  fi
 
 
- echo $ac_n "checking for getenv declaration""... $ac_c" 1>&4
- if eval "test \"`echo '${'lpc_cv_decl_getenv'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+ echo $ac_n "checking for getenv declaration""... $ac_c" 1>&6
+ if eval "test \"`echo '$''{'lpc_cv_decl_getenv'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
    lpc_cv_decl_getenv=nonexistant
    for a in unistd.h stdlib.h
    do
      cat > conftest.$ac_ext <<EOF
-#line 1854 "configure"
+#line 2130 "configure"
 #include "confdefs.h"
 #include <$a>
 EOF
@@ -1865,7 +2141,7 @@ rm -f conftest*
  
 fi
 
- echo "$ac_t""$lpc_cv_decl_getenv" 1>&4
+ echo "$ac_t""$lpc_cv_decl_getenv" 1>&6
  if test "$lpc_cv_decl_getenv" = nonexistant; then
    cat >> confdefs.h <<\EOF
 #define GETENV_DECL_MISSING 1
@@ -1874,16 +2150,16 @@ EOF
  fi
 
 
- echo $ac_n "checking for gethostname declaration""... $ac_c" 1>&4
- if eval "test \"`echo '${'lpc_cv_decl_gethostname'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+ echo $ac_n "checking for gethostname declaration""... $ac_c" 1>&6
+ if eval "test \"`echo '$''{'lpc_cv_decl_gethostname'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
    lpc_cv_decl_gethostname=nonexistant
    for a in unistd.h
    do
      cat > conftest.$ac_ext <<EOF
-#line 1887 "configure"
+#line 2163 "configure"
 #include "confdefs.h"
 #include <$a>
 EOF
@@ -1898,7 +2174,7 @@ rm -f conftest*
  
 fi
 
- echo "$ac_t""$lpc_cv_decl_gethostname" 1>&4
+ echo "$ac_t""$lpc_cv_decl_gethostname" 1>&6
  if test "$lpc_cv_decl_gethostname" = nonexistant; then
    cat >> confdefs.h <<\EOF
 #define GETHOSTNAME_DECL_MISSING 1
@@ -1907,12 +2183,12 @@ EOF
  fi
 
 
-echo $ac_n "checking return type of free""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_sys_free_return'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking return type of free""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_sys_free_return'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1916 "configure"
+#line 2192 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_STDLIB_H
@@ -1954,18 +2230,18 @@ if test "$lpc_cv_sys_free_return" = void; then
 #define FREE_RETURNS_VOID 1
 EOF
 
-  echo "$ac_t""void" 1>&4;
+  echo "$ac_t""void" 1>&6;
 else
-  echo "$ac_t""not void" 1>&4
+  echo "$ac_t""not void" 1>&6
 fi
 
-echo $ac_n "checking void* or char* from malloc""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_sys_malloc_return'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking void* or char* from malloc""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_sys_malloc_return'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 1969 "configure"
+#line 2245 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -2011,7 +2287,7 @@ rm -f conftest*
 fi
 
 
-echo "$ac_t""$lpc_cv_sys_malloc_return" 1>&4
+echo "$ac_t""$lpc_cv_sys_malloc_return" 1>&6
 cat >> confdefs.h <<EOF
 #define POINTER $lpc_cv_sys_malloc_return
 EOF
@@ -2020,12 +2296,12 @@ EOF
 
 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
-echo $ac_n "checking for working alloca.h""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_header_alloca_h'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2029 "configure"
+#line 2305 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() { return 0; }
@@ -2043,7 +2319,8 @@ fi
 rm -f conftest*
 
 fi
-echo "$ac_t""$ac_cv_header_alloca_h" 1>&4
+
+echo "$ac_t""$ac_cv_header_alloca_h" 1>&6
 if test $ac_cv_header_alloca_h = yes; then
   cat >> confdefs.h <<\EOF
 #define HAVE_ALLOCA_H 1
@@ -2051,12 +2328,12 @@ EOF
 
 fi
 
-echo $ac_n "checking for alloca""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_func_alloca'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for alloca""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_func_alloca'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2060 "configure"
+#line 2337 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -2090,7 +2367,8 @@ fi
 rm -f conftest*
 
 fi
-echo "$ac_t""$ac_cv_func_alloca" 1>&4
+
+echo "$ac_t""$ac_cv_func_alloca" 1>&6
 if test $ac_cv_func_alloca = yes; then
   cat >> confdefs.h <<\EOF
 #define HAVE_ALLOCA 1
@@ -2109,12 +2387,12 @@ if test $ac_cv_func_alloca = no; then
 EOF
 
 
-echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_os_cray'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2118 "configure"
+#line 2396 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -2134,148 +2412,70 @@ fi
 rm -f conftest*
 
 fi
-echo "$ac_t""$ac_cv_os_cray" 1>&4
+
+echo "$ac_t""$ac_cv_os_cray" 1>&6
 if test $ac_cv_os_cray = yes; then
-echo $ac_n "checking for _getb67""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_func__getb67'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+for ac_func in _getb67 GETB67 getb67; do
+  echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2145 "configure"
+#line 2425 "configure"
 #include "confdefs.h"
-#include <ctype.h> /* Arbitrary system header to define __stub macros. */
-int main() { return 0; }
-int t() {
-
-/* 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__getb67) || defined (__stub____getb67)
-choke me
-#else
+/* 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.  */
-char _getb67(); _getb67();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
-  rm -rf conftest*
-  eval "ac_cv_func__getb67=yes"
-else
-  rm -rf conftest*
-  eval "ac_cv_func__getb67=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'_getb67`\" = yes"; then
-  echo "$ac_t""yes" 1>&4
-  cat >> confdefs.h <<\EOF
-#define CRAY_STACKSEG_END _getb67
-EOF
+char $ac_func();
 
-else
-  echo "$ac_t""no" 1>&4
-echo $ac_n "checking for GETB67""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_func_GETB67'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
-else
-  cat > conftest.$ac_ext <<EOF
-#line 2186 "configure"
-#include "confdefs.h"
-#include <ctype.h> /* Arbitrary system header to define __stub macros. */
 int main() { return 0; }
 int t() {
 
 /* 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_GETB67) || defined (__stub___GETB67)
-choke me
-#else
-/* Override any gcc2 internal prototype to avoid an error.  */
-char GETB67(); GETB67();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
-  rm -rf conftest*
-  eval "ac_cv_func_GETB67=yes"
-else
-  rm -rf conftest*
-  eval "ac_cv_func_GETB67=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'GETB67`\" = yes"; then
-  echo "$ac_t""yes" 1>&4
-  cat >> confdefs.h <<\EOF
-#define CRAY_STACKSEG_END GETB67
-EOF
-
-else
-  echo "$ac_t""no" 1>&4
-echo $ac_n "checking for getb67""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_func_getb67'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
-else
-  cat > conftest.$ac_ext <<EOF
-#line 2227 "configure"
-#include "confdefs.h"
-#include <ctype.h> /* Arbitrary system header to define __stub macros. */
-int main() { return 0; }
-int t() {
-
-/* 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_getb67) || defined (__stub___getb67)
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
 choke me
 #else
-/* Override any gcc2 internal prototype to avoid an error.  */
-char getb67(); getb67();
+$ac_func();
 #endif
 
 ; return 0; }
 EOF
 if eval $ac_link; then
   rm -rf conftest*
-  eval "ac_cv_func_getb67=yes"
+  eval "ac_cv_func_$ac_func=yes"
 else
   rm -rf conftest*
-  eval "ac_cv_func_getb67=no"
+  eval "ac_cv_func_$ac_func=no"
 fi
 rm -f conftest*
 
 fi
-if eval "test \"`echo '$ac_cv_func_'getb67`\" = yes"; then
-  echo "$ac_t""yes" 1>&4
-  cat >> confdefs.h <<\EOF
-#define CRAY_STACKSEG_END getb67
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  cat >> confdefs.h <<EOF
+#define CRAY_STACKSEG_END $ac_func
 EOF
 
+  break
 else
-  echo "$ac_t""no" 1>&4
-fi
-
-fi
-
+  echo "$ac_t""no" 1>&6
 fi
 
+done
 fi
 
-echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_c_stack_direction'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test "$cross_compiling" = yes; then
   ac_cv_c_stack_direction=0
 else
 cat > conftest.$ac_ext <<EOF
-#line 2279 "configure"
+#line 2479 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -2303,7 +2503,8 @@ fi
 fi
 rm -fr conftest*
 fi
-echo "$ac_t""$ac_cv_c_stack_direction" 1>&4
+
+echo "$ac_t""$ac_cv_c_stack_direction" 1>&6
 cat >> confdefs.h <<EOF
 #define STACK_DIRECTION $ac_cv_c_stack_direction
 EOF
@@ -2311,12 +2512,12 @@ EOF
 fi
 
 
-echo $ac_n "checking for working const""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_c_const'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for working const""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2320 "configure"
+#line 2521 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -2327,6 +2528,9 @@ typedef int charset[2]; const charset x;
 /* SunOS 4.1.1 cc rejects this.  */
 char const *const *ccp;
 char **p;
+/* NEC SVR4.0.2 mips cc rejects this.  */
+struct point {int x, y;};
+static struct point const zero = {0,0};
 /* AIX XL C 1.02.0.0 rejects this.
    It does not let you subtract one const X* pointer from another in an arm
    of an if-expression whose if-part is not a constant expression */
@@ -2363,7 +2567,7 @@ ccp = (char const *const *) p;
 
 ; return 0; }
 EOF
-if eval $ac_link; then
+if eval $ac_compile; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -2373,7 +2577,8 @@ fi
 rm -f conftest*
 
 fi
-echo "$ac_t""$ac_cv_c_const" 1>&4
+
+echo "$ac_t""$ac_cv_c_const" 1>&6
 if test $ac_cv_c_const = no; then
   cat >> confdefs.h <<\EOF
 #define const 
@@ -2381,52 +2586,60 @@ EOF
 
 fi
 
-echo $ac_n "checking for inline""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_c_inline'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for inline""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
-  if test "$GCC" = yes; then
-cat > conftest.$ac_ext <<EOF
-#line 2391 "configure"
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat > conftest.$ac_ext <<EOF
+#line 2597 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
 int t() {
-} inline foo() {
+} $ac_kw foo() {
 ; return 0; }
 EOF
-if eval $ac_link; then
+if eval $ac_compile; then
   rm -rf conftest*
-  ac_cv_c_inline=yes
-else
-  rm -rf conftest*
-  ac_cv_c_inline=no
+  ac_cv_c_inline=$ac_kw; break
 fi
 rm -f conftest*
 
-else
-  ac_cv_c_inline=no
-fi
-fi
-echo "$ac_t""$ac_cv_c_inline" 1>&4
-if test $ac_cv_c_inline = no; then
-  cat >> confdefs.h <<\EOF
-#define inline __inline
-EOF
+done
 
 fi
 
+echo "$ac_t""$ac_cv_c_inline" 1>&6
+case "$ac_cv_c_inline" in
+  inline | yes) ;;
+  no) cat >> confdefs.h <<\EOF
+#define inline 
+EOF
+ ;;
+  *)  cat >> confdefs.h <<EOF
+#define inline $ac_cv_c_inline
+EOF
+ ;;
+esac
+
 
 for ac_func in ualarm
 do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&4
-if eval "test \"`echo '${'ac_cv_func_$ac_func'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2428 "configure"
+#line 2636 "configure"
 #include "confdefs.h"
-#include <ctype.h> /* Arbitrary system header to define __stub macros. */
+/* 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.  */
+char $ac_func();
+
 int main() { return 0; }
 int t() {
 
@@ -2436,8 +2649,7 @@ int t() {
 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
 choke me
 #else
-/* Override any gcc2 internal prototype to avoid an error.  */
-char $ac_func(); $ac_func();
+$ac_func();
 #endif
 
 ; return 0; }
@@ -2453,10 +2665,10 @@ rm -f conftest*
 
 fi
 if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
-  echo "$ac_t""yes" 1>&4
+  echo "$ac_t""yes" 1>&6
   :
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 LIBOBJS="$LIBOBJS ${ac_func}.o"
 fi
 
@@ -2473,16 +2685,16 @@ EOF
   ;;
 esac
 
-echo $ac_n "checking byteorder""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_hardware_byteorder'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking byteorder""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_hardware_byteorder'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 2486 "configure"
+#line 2698 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -2525,22 +2737,22 @@ rm -fr conftest*
 fi
 
 
-echo "$ac_t""$lpc_cv_hardware_byteorder" 1>&4
+echo "$ac_t""$lpc_cv_hardware_byteorder" 1>&6
 cat >> confdefs.h <<EOF
 #define BYTEORDER $lpc_cv_hardware_byteorder
 EOF
 
 
-echo $ac_n "checking for working memmem""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_func_memmem'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for working memmem""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_func_memmem'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 2544 "configure"
+#line 2756 "configure"
 #include "confdefs.h"
 
 #include <string.h>
@@ -2572,118 +2784,117 @@ fi
 
 
 if test "$lpc_cv_func_memmem" = yes; then
-  echo "$ac_t""yes" 1>&4
+  echo "$ac_t""yes" 1>&6
   cat >> confdefs.h <<\EOF
 #define HAVE_MEMMEM 1
 EOF
 
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 
-echo $ac_n "checking for working strcoll""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_func_strcoll'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for working memmove""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_func_memmove'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 2594 "configure"
+#line 2806 "configure"
 #include "confdefs.h"
 
 #include <string.h>
+char buf[100];
 int main()
 {
-  if(strcoll("a","b")< 0 &&
-     strcoll("a","a")==0 &&
-     strcoll("b","a")> 0)
-    exit(0);
-  exit(1);
+  strcpy(buf,"foo bar gazonk elefantsnabel.");
+  if(strcmp(buf,"foo bar gazonk elefantsnabel.")) exit(1);
+  memmove(buf,buf+1,7);
+  if(strcmp(buf,"oo bar  gazonk elefantsnabel.")) exit(1);
+  memmove(buf+1,buf+1,9);
+  if(strcmp(buf,"oo bar  gazonk elefantsnabel.")) exit(1);
+  memmove(buf+1,buf,11);
+  if(strcmp(buf,"ooo bar  gaznk elefantsnabel.")) exit(1);
+  exit(0);
 }
 
 EOF
 eval $ac_link
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
-  lpc_cv_func_strcoll=yes
+  lpc_cv_func_memmove=yes
 else
-  lpc_cv_func_strcoll=no
+  lpc_cv_func_memmove=no
 fi
 fi
 rm -fr conftest*
 fi
 
 
-if test "$lpc_cv_func_strcoll" = yes; then
-  echo "$ac_t""yes" 1>&4
+if test "$lpc_cv_func_memmove" = yes; then
+  echo "$ac_t""yes" 1>&6
   cat >> confdefs.h <<\EOF
-#define HAVE_STRCOLL 1
+#define HAVE_MEMMOVE 1
 EOF
 
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 
-echo $ac_n "checking for working memmove""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_func_memmove'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking how to extract an unsigned char""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_method_extract_uchar'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 2638 "configure"
+#line 2855 "configure"
 #include "confdefs.h"
 
-#include <string.h>
-char buf[100];
 int main()
 {
-  strcpy(buf,"foo bar gazonk elefantsnabel.");
-  if(strcmp(buf,"foo bar gazonk elefantsnabel.")) exit(1);
-  memmove(buf,buf+1,7);
-  if(strcmp(buf,"oo bar  gazonk elefantsnabel.")) exit(1);
-  memmove(buf+1,buf+1,9);
-  if(strcmp(buf,"oo bar  gazonk elefantsnabel.")) exit(1);
-  memmove(buf+1,buf,11);
-  if(strcmp(buf,"ooo bar  gaznk elefantsnabel.")) exit(1);
+  char i,*p;
+  i=-10;
+  p=&i;
+  if(*(unsigned char *)(p)!= 0x100 - 10) exit(1);
   exit(0);
 }
 
 EOF
 eval $ac_link
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
-  lpc_cv_func_memmove=yes
+  lpc_cv_method_extract_uchar=by_cast
 else
-  lpc_cv_func_memmove=no
+  lpc_cv_method_extract_uchar=not_by_cast
 fi
 fi
 rm -fr conftest*
 fi
 
 
-if test "$lpc_cv_func_memmove" = yes; then
-  echo "$ac_t""yes" 1>&4
+if test "$lpc_cv_method_extract_uchar" = by_cast; then
+  echo "$ac_t""by cast" 1>&6
   cat >> confdefs.h <<\EOF
-#define HAVE_MEMMOVE 1
+#define EXTRACT_UCHAR_BY_CAST 1
 EOF
 
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""not by cast" 1>&6
 fi
 
-echo $ac_n "checking how to extract an unsigned char""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_method_extract_uchar'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking how to extract a signed char""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_method_extract_char'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 2687 "configure"
+#line 2898 "configure"
 #include "confdefs.h"
 
 int main()
@@ -2691,85 +2902,122 @@ int main()
   char i,*p;
   i=-10;
   p=&i;
-  if(*(unsigned char *)(p)!= 0x100 - 10) exit(1);
+  if(*(signed char *)(p)!= -10) exit(1);
   exit(0);
 }
 
 EOF
 eval $ac_link
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
-  lpc_cv_method_extract_uchar=by_cast
+  lpc_cv_method_extract_char=by_cast
 else
-  lpc_cv_method_extract_uchar=not_by_cast
+  lpc_cv_method_extract_char=not_by_cast
 fi
 fi
 rm -fr conftest*
 fi
 
 
-if test "$lpc_cv_method_extract_uchar" = by_cast; then
-  echo "$ac_t""by cast" 1>&4
+if test "$lpc_cv_method_extract_char" = by_cast; then
+  echo "$ac_t""by cast" 1>&6
   cat >> confdefs.h <<\EOF
-#define EXTRACT_UCHAR_BY_CAST 1
+#define EXTRACT_CHAR_BY_CAST 1
 EOF
 
 else
-  echo "$ac_t""not by cast" 1>&4
+  echo "$ac_t""not by cast" 1>&6
 fi
 
-echo $ac_n "checking how to extract a signed char""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_method_extract_char'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+
+echo $ac_n "checking if signal handlers reset automatically""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_sys_signal_oneshot'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 2730 "configure"
+#line 2942 "configure"
 #include "confdefs.h"
 
+#include <signal.h>
+char sigrun=0;
+RETSIGTYPE func(int sig) { sigrun=1; }
+
 int main()
 {
-  char i,*p;
-  i=-10;
-  p=&i;
-  if(*(signed char *)(p)!= -10) exit(1);
+#define sig SIGSEGV
+
+#ifdef HAVE_SIGACTION
+  {
+    struct sigaction action;
+    action.sa_handler= func;
+    sigfillset(&action.sa_mask);
+#ifdef SA_INTERRUPT
+    action.sa_flags=SA_INTERRUPT;
+#endif
+    sigaction(sig,&action,0);
+  }
+#else
+#ifdef HAVE_SIGVEC
+  {
+    struct sigvec action;
+    action.sv_handler= func;
+    action.sv_mask=-1;
+#ifdef SV_INTERRUPT
+    action.sv_flags=SV_INTERRUPT;
+#endif
+    sigvec(sig,&action,0);
+  }
+#else
+  signal(sig, func);
+#endif
+#endif
+
+  kill(getpid(), sig);
+  while(!sigrun) sleep(1);
+  sigrun=0;
+  kill(getpid(), sig);
+  while(!sigrun) sleep(1);
+  sigrun=0;
   exit(0);
 }
 
 EOF
 eval $ac_link
 if test -s conftest && (./conftest; exit) 2>/dev/null; then
-  lpc_cv_method_extract_char=by_cast
+  lpc_cv_sys_signal_oneshot=no
 else
-  lpc_cv_method_extract_char=not_by_cast
+  lpc_cv_sys_signal_oneshot=yes
 fi
 fi
 rm -fr conftest*
 fi
 
 
-if test "$lpc_cv_method_extract_char" = by_cast; then
-  echo "$ac_t""by cast" 1>&4
+if test "$lpc_cv_sys_signal_oneshot" = yes; then
+  echo "$ac_t""yes" 1>&6
   cat >> confdefs.h <<\EOF
-#define EXTRACT_CHAR_BY_CAST 1
+#define SIGNAL_ONESHOT 1
 EOF
 
 else
-  echo "$ac_t""not by cast" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 
-echo $ac_n "checking available file descriptors""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_max_open_fd'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+
+
+echo $ac_n "checking available file descriptors""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_max_open_fd'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 2773 "configure"
+#line 3021 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -2832,20 +3080,20 @@ fi
 rm -fr conftest*
 fi
 
-echo "$ac_t""$lpc_cv_max_open_fd" 1>&4
+echo "$ac_t""$lpc_cv_max_open_fd" 1>&6
 cat >> confdefs.h <<EOF
 #define MAX_OPEN_FILEDESCRIPTORS $lpc_cv_max_open_fd
 EOF
 
 
 if test "$ac_cv_func_getrusage" = "yes"; then
-echo $ac_n "checking full availability of struct rusage members""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_func_getrusage_full'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking full availability of struct rusage members""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_func_getrusage_full'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 2849 "configure"
+#line 3097 "configure"
 #include "confdefs.h"
 
 #include <sys/time.h>
@@ -2895,9 +3143,9 @@ fi
 
 
 if test "$lpc_cv_func_getrusage_full" = yes; then
-  echo "$ac_t""all there" 1>&4
+  echo "$ac_t""all there" 1>&6
 else
-  echo "$ac_t""getrusage is restricted" 1>&4
+  echo "$ac_t""getrusage is restricted" 1>&6
   cat >> confdefs.h <<\EOF
 #define GETRUSAGE_RESTRICTED 1
 EOF
@@ -2906,13 +3154,13 @@ fi
 
 else
 
-echo $ac_n "checking getrusage() through procfs""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_getrusage_procfs'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking getrusage() through procfs""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_getrusage_procfs'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 2916 "configure"
+#line 3164 "configure"
 #include "confdefs.h"
 
 #include <sys/procfs.h>
@@ -2943,23 +3191,23 @@ fi
 
 
 if test "$lpc_cv_getrusage_procfs" = yes; then
-  echo "$ac_t""yes" 1>&4
+  echo "$ac_t""yes" 1>&6
   cat >> confdefs.h <<\EOF
 #define GETRUSAGE_THROUGH_PROCFS 1
 EOF
 
 else
-  echo "$ac_t""no" 1>&4
+  echo "$ac_t""no" 1>&6
 fi
 fi
 
-echo $ac_n "checking checking for volatile""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_volatile'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking checking for volatile""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_volatile'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
  cat > conftest.$ac_ext <<EOF
-#line 2963 "configure"
+#line 3211 "configure"
 #include "confdefs.h"
 
 int main() { return 0; }
@@ -2981,29 +3229,29 @@ fi
 
 
 if test "$lpc_cv_volatile" = yes; then
- echo "$ac_t""yes" 1>&4
+ echo "$ac_t""yes" 1>&6
  cat >> confdefs.h <<\EOF
 #define VOLATILE volatile
 EOF
 
 else
- echo "$ac_t""no" 1>&4
+ echo "$ac_t""no" 1>&6
  cat >> confdefs.h <<\EOF
 #define VOLATILE 
 EOF
 
 fi
 
-echo $ac_n "checking for gcc function attributes""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_gcc_attributes'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking for gcc function attributes""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_gcc_attributes'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 3007 "configure"
+#line 3255 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -3035,7 +3283,7 @@ rm -fr conftest*
 fi
 
 
-echo "$ac_t""$lpc_cv_gcc_attributes" 1>&4
+echo "$ac_t""$lpc_cv_gcc_attributes" 1>&6
 if test "$lpc_cv_gcc_attributes" = yes; then
  cat >> confdefs.h <<\EOF
 #define HAVE_FUNCTION_ATTRIBUTES 1
@@ -3043,16 +3291,16 @@ EOF
 
 fi
 
-echo $ac_n "checking how to set things nonblocking""... $ac_c" 1>&4
-if eval "test \"`echo '${'lpc_cv_sys_nonblock'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&4
+echo $ac_n "checking how to set things nonblocking""... $ac_c" 1>&6
+if eval "test \"`echo '$''{'lpc_cv_sys_nonblock'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 3056 "configure"
+#line 3304 "configure"
 #include "confdefs.h"
 
 #define TESTING
@@ -3068,7 +3316,7 @@ else
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 3072 "configure"
+#line 3320 "configure"
 #include "confdefs.h"
 
 #define TESTING
@@ -3084,7 +3332,7 @@ else
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 3088 "configure"
+#line 3336 "configure"
 #include "confdefs.h"
 
 #define TESTING
@@ -3100,7 +3348,7 @@ else
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
 cat > conftest.$ac_ext <<EOF
-#line 3104 "configure"
+#line 3352 "configure"
 #include "confdefs.h"
 
 #define TESTING
@@ -3130,9 +3378,9 @@ fi
 
 
 if test "${lpc_cv_sys_nonblock}" = ""; then
-  echo "$ac_t""none found" 1>&4
+  echo "$ac_t""none found" 1>&6
 else
- echo "$ac_t""$lpc_cv_sys_nonblock" 1>&4
+ echo "$ac_t""$lpc_cv_sys_nonblock" 1>&6
  cat >> confdefs.h <<EOF
 #define $lpc_cv_sys_nonblock 1
 EOF
@@ -3158,6 +3406,7 @@ done
 
 LIBDIR=`(cd $srcdir/../lib ; pwd)`
 BINDIR=`(cd $srcdir/../bin ; pwd)`
+DOCDIR=`(cd $srcdir/../doc ; pwd)`
 BUILDDIR=`pwd`
 
 subdirs="$dirs"
@@ -3173,10 +3422,9 @@ subdirs="$dirs"
 
 
 
+
 trap '' 1 2 15
-if test -w $cache_file; then
-echo "updating cache $cache_file"
-cat > $cache_file <<\EOF
+cat > confcache <<\EOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
 # scripts and configure runs.  It is not useful on other systems.
@@ -3192,17 +3440,26 @@ cat > $cache_file <<\EOF
 # --recheck option to rerun configure.
 #
 EOF
-# Ultrix sh set writes to stderr and can't be redirected directly.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
 (set) 2>&1 |
-  sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/: \${\1='\2'}/p" \
-  >> $cache_file
+  sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1='\2'}/p" \
+  >> confcache
+if cmp -s $cache_file confcache; then
+  :
 else
-echo "not updating unwritable cache $cache_file"
+  if test -w $cache_file; then
+    echo "updating cache $cache_file"
+    cat confcache > $cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  fi
 fi
+rm -f confcache
 
-trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
 
-test "x$prefix" = xNONE && prefix=/usr/local
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
 # Let make expand exec_prefix.
 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
 
@@ -3223,7 +3480,7 @@ DEFS=-DHAVE_CONFIG_H
 echo creating $CONFIG_STATUS
 rm -f $CONFIG_STATUS
 cat > $CONFIG_STATUS <<EOF
-#!/bin/sh
+#! /bin/sh
 # Generated automatically by configure.
 # Run this file to recreate the current configuration.
 # This directory was configured as follows,
@@ -3242,7 +3499,7 @@ do
     echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 1.119"
+    echo "$CONFIG_STATUS generated by autoconf version 2.7"
     exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "\$ac_cs_usage"; exit 0 ;;
@@ -3253,11 +3510,13 @@ done
 ac_given_srcdir=$srcdir
 ac_given_INSTALL="$INSTALL"
 
-trap 'rm -fr Makefile machine.h conftest*; exit 1' 1 2 15
+trap 'rm -fr `echo "Makefile machine.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
 
-# Protect against being on the right side of a sed subst in config.status. 
-sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g; 
- s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
 $ac_vpsub
 $extrasub
 s%@CFLAGS@%$CFLAGS%g
@@ -3268,6 +3527,19 @@ s%@LDFLAGS@%$LDFLAGS%g
 s%@LIBS@%$LIBS%g
 s%@exec_prefix@%$exec_prefix%g
 s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
 s%@CC@%$CC%g
 s%@uname_prog@%$uname_prog%g
 s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
@@ -3287,6 +3559,7 @@ s%@EXTRA_OBJS@%$EXTRA_OBJS%g
 s%@LIBDIR@%$LIBDIR%g
 s%@BINDIR@%$BINDIR%g
 s%@BUILDDIR@%$BUILDDIR%g
+s%@DOCDIR@%$DOCDIR%g
 
 CEOF
 EOF
@@ -3310,7 +3583,7 @@ for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
   if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
     # The file is in a subdirectory.
     test ! -d "$ac_dir" && mkdir "$ac_dir"
-    ac_dir_suffix="/$ac_dir"
+    ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
     # A "../" for each directory in $ac_dir_suffix.
     ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
   else
@@ -3385,7 +3658,7 @@ EOF
 
 # Transform confdefs.h into a sed script conftest.vals that substitutes
 # the proper values into config.h.in to produce config.h.  And first:
-# Protect against being on the right side of a sed subst in config.status. 
+# Protect against being on the right side of a sed subst in config.status.
 # Protect against being in an unquoted here document in config.status.
 rm -f conftest.vals
 cat > conftest.hdr <<\EOF
@@ -3456,7 +3729,7 @@ if test ! -d ./modules ; then
   mkdir modules
 fi
 
-echo "$ac_t""creating modlist.h" 1>&4
+echo "$ac_t""creating modlist.h" 1>&6
 echo "void init_main_efuns(void);" >modlist.h
 echo "void init_main_programs(void);" >>modlist.h
 echo "void exit_main(void);" >>modlist.h
@@ -3482,7 +3755,7 @@ exit 0
 EOF
 chmod +x $CONFIG_STATUS
 rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
 
 if test "$no_recursion" != yes; then
 
@@ -3556,12 +3829,16 @@ if test "$no_recursion" != yes; then
 
       # Make the cache file name correct relative to the subdirectory.
       # A "../" for each directory in /$ac_config_dir.
-      ac_dots=`echo /$ac_config_dir|sed 's%/[^/]*%../%g'`
+      ac_dots=`echo $ac_config_dir|sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'`
       case "$cache_file" in
       /*) ac_sub_cache_file=$cache_file ;;
       *) # Relative path.
         ac_sub_cache_file="$ac_dots$cache_file" ;;
       esac
+  case "$ac_given_INSTALL" in
+        [/$]*) INSTALL="$ac_given_INSTALL" ;;
+        *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+        esac
 
       echo "running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir"
       # The eval makes quoting arguments work.
diff --git a/src/configure.in b/src/configure.in
index beda26cdae..38d063c1d0 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -132,10 +132,11 @@ AC_DEFINE_UNQUOTED(F_OFFSET,$lpc_cv_yacc_first)
 
 rm -rf conftest.y y.tab.c y.tab.h conftest.out
 
-AC_HAVE_HEADERS(sys/rusage.h time.h sys/time.h unistd.h stdlib.h memory.h values.h \
- string.h fcntl.h sys/filio.h sys/sockio.h crypt.h locale.h sys/resource.h \
- sys/select.h netdb.h)
-AC_STDC_HEADERS
+AC_HEADER_TIME
+AC_HEADER_STDC
+AC_CHECK_HEADERS(sys/rusage.h time.h sys/time.h unistd.h stdlib.h memory.h \
+values.h string.h fcntl.h sys/filio.h sys/sockio.h crypt.h locale.h \
+sys/resource.h sys/select.h netdb.h)
 
 AC_SIZEOF_TYPE(char *)
 AC_SIZEOF_TYPE(long)
@@ -144,10 +145,10 @@ AC_SIZEOF_TYPE(short)
 AC_SIZEOF_TYPE(float)
 AC_SIZEOF_TYPE(double)
 
-AC_SIZE_T
-AC_PID_T
-AC_UID_T
-AC_RETSIGTYPE
+AC_TYPE_SIZE_T
+AC_TYPE_PID_T
+AC_TYPE_UID_T
+AC_TYPE_SIGNAL
 AC_CHECK_TYPE(time_t,INT32)
 
 AC_CHECK_LIB(PW, alloca)
@@ -173,7 +174,9 @@ fi
 
 LIBOBJS="${OLD_LIBOBJS}"
 
-AC_HAVE_FUNCS(
+AC_FUNC_STRCOLL
+
+AC_CHECK_FUNCS(
  _crypt \
  bcopy \
  bzero \
@@ -202,6 +205,7 @@ AC_HAVE_FUNCS(
  times \
  vfprintf \
  vsprintf \
+ wait3 \
  wait4 \
  waitpid \
 )
@@ -214,7 +218,7 @@ define(MY_CHECK_HEADERS,
    lpc_cv_decl_$1=nonexistant
    for a in $2
    do
-     AC_HEADER_EGREP($1,$a,lpc_cv_decl_$1=existant; break)
+     AC_EGREP_HEADER($1,$a,lpc_cv_decl_$1=existant; break)
    done
  ])
  AC_MSG_RESULT($lpc_cv_decl_$1)
@@ -301,8 +305,8 @@ AC_DEFINE_UNQUOTED(POINTER,$lpc_cv_sys_malloc_return)
 
 AC_ALLOCA
 
-AC_CONST
-AC_INLINE
+AC_C_CONST
+AC_C_INLINE
 
 AC_REPLACE_FUNCS(ualarm)
 
@@ -379,28 +383,6 @@ else
   AC_MSG_RESULT(no)
 fi
 
-AC_MSG_CHECKING(for working strcoll)
-AC_CACHE_VAL(lpc_cv_func_strcoll,
-[
-AC_TRY_RUN([
-#include <string.h>
-int main()
-{
-  if(strcoll("a","b")< 0 &&
-     strcoll("a","a")==0 &&
-     strcoll("b","a")> 0)
-    exit(0);
-  exit(1);
-}
-],lpc_cv_func_strcoll=yes,lpc_cv_func_strcoll=no)])
-
-if test "$lpc_cv_func_strcoll" = yes; then
-  AC_MSG_RESULT(yes)
-  AC_DEFINE(HAVE_STRCOLL)
-else
-  AC_MSG_RESULT(no)
-fi
-
 AC_MSG_CHECKING(for working memmove)
 AC_CACHE_VAL(lpc_cv_func_memmove,
 [
diff --git a/src/docode.c b/src/docode.c
index 3eab7112dd..5e1c52e3f8 100644
--- a/src/docode.c
+++ b/src/docode.c
@@ -676,18 +676,6 @@ static int do_docode2(node *n,int flags)
 
   case F_EQ:
   case F_NE:
-    if(flags & DO_POP)
-    {
-      do_pop(do_docode(CAR(n),DO_NOT_COPY|DO_POP)+
-	     do_docode(CDR(n),DO_NOT_COPY|DO_POP));
-      return 0;
-    }
-    tmp1=do_docode(CAR(n),0);
-    if(do_docode(CDR(n),0)!=1)
-      fatal("Compiler internal error (gnng!).\n");
-    ins_f_byte(n->token);
-    return tmp1;
-
   case F_ADD:
   case F_LT:
   case F_LE:
@@ -702,17 +690,10 @@ static int do_docode2(node *n,int flags)
   case F_XOR:
   case F_OR:
   case F_AND:
-    if(flags & DO_POP)
-    {
-      do_pop(do_docode(CAR(n),DO_NOT_COPY|DO_POP)+
-	     do_docode(CDR(n),DO_NOT_COPY|DO_POP));
-      return 0;
-    }
-    tmp1=do_docode(CAR(n),DO_NOT_COPY);
-    if(do_docode(CDR(n),DO_NOT_COPY)!=1)
-      fatal("Compiler internal error.\n");
-    ins_f_byte(n->token);
-    return tmp1;
+  case F_NOT:
+  case F_COMPL:
+  case F_NEGATE:
+    fatal("Optimizer errror.\n");
 
   case F_RANGE:
     tmp1=do_docode(CAR(n),DO_NOT_COPY);
@@ -754,18 +735,6 @@ static int do_docode2(node *n,int flags)
       return 1;
     }
 
-  case F_NOT:
-  case F_COMPL:
-  case F_NEGATE:
-    tmp1=do_docode(CAR(n),DO_NOT_COPY | (flags & ~DO_LVALUE));
-    if(flags & DO_POP)
-    {
-      do_pop(tmp1);
-      return 0;
-    }
-    ins_f_byte(n->token);
-    return tmp1;
-
   case F_FOR:
   {
     struct jump_list brk,cnt;
diff --git a/src/gc.c b/src/gc.c
new file mode 100644
index 0000000000..d4f1cf812d
--- /dev/null
+++ b/src/gc.c
@@ -0,0 +1,89 @@
+/*\
+||| This file a part of uLPC, and is copyright by Fredrik Hubinette
+||| uLPC is distributed as GPL (General Public License)
+||| See the files COPYING and DISCLAIMER for more information.
+\*/
+
+#include "global.h"
+
+#ifdef GC2
+#include "gc.h"
+#include "main.h"
+
+/* Run garbage collect approximate every time we have
+ * 20 percent of all arrays, objects and programs is
+ * garbage.
+ */
+
+#define GC_CONST 20
+#define MIN_ALLOC_THRESHOLD 1000
+#define MULTIPLIER 0.9
+
+void *gc_ptr;
+INT32 gc_refs;
+INT32 num_objects;
+INT32 num_allocs;
+INT32 alloc_threshold = MIN_ALLOC_THRESHOLD;
+
+static double objects_alloced;
+static double objects_freed;
+
+void do_gc()
+{
+  double tmp;
+  INT32 tmp2;
+
+  tmp2=num_objects;
+
+#ifdef DEBUG
+  if(t_flag)
+    fprintf(stderr,"Garbage collecting ... ");
+#endif
+
+  objects_alloced*=MULTIPLIER;
+  objects_alloced += (double) num_allocs;
+  
+  objects_freed*=MULTIPLIER;
+  objects_freed += (double) num_objects;
+  
+  gc_clear_array_marks();
+  gc_clear_object_marks();
+  gc_clear_program_marks();
+  
+  gc_check_all_arrays();
+  gc_check_all_programs();
+  gc_check_all_objects();
+  
+  objects_freed -= (double) num_objects;
+
+  tmp=(double)num_objects;
+  tmp=tmp * GC_CONST/100.0 * (objects_alloced+1.0) / (objects_freed+1.0);
+  
+  if((int)tmp < alloc_threshold + num_allocs)
+  {
+    alloc_threshold=(int)tmp;
+  }else{
+    alloc_threshold+=num_allocs;
+  }
+
+  if(alloc_threshold < MIN_ALLOC_THRESHOLD)
+    alloc_threshold = MIN_ALLOC_THRESHOLD;
+  num_allocs=0;
+
+#ifdef DEBUG
+  if(t_flag)
+    fprintf(stderr,"done (freed %ld of %ld objects).\n",
+	    (long)(tmp2-num_objects),(long)tmp2);
+#endif
+}
+#endif
+
+
+
+
+
+
+
+
+
+
diff --git a/src/gc.h b/src/gc.h
new file mode 100644
index 0000000000..96746616ea
--- /dev/null
+++ b/src/gc.h
@@ -0,0 +1,30 @@
+#ifndef GC_H
+#define GC_H
+
+#ifdef GC2
+
+#include "types.h"
+
+extern void *gc_ptr;
+extern INT32 gc_refs;
+extern INT32 num_objects;
+extern INT32 num_allocs;
+extern INT32 alloc_threshold;
+
+#define GC_ALLOC() do{ num_objects++; if(++num_allocs > alloc_threshold) do_gc(); } while(0);
+#define GC_FREE() num_objects--
+#define GC_MARK 1
+
+#else
+
+#define GC_ALLOC()
+#define GC_FREE()
+#define do_gc()
+
+#endif
+
+/* Prototypes begin here */
+void do_gc();
+/* Prototypes end here */
+
+#endif
diff --git a/src/language.y b/src/language.y
index fc5266f752..528e4714a8 100644
--- a/src/language.y
+++ b/src/language.y
@@ -905,7 +905,7 @@ expr2: expr3
      }
      | F_INC expr4       { $$=mknode(F_INC,$2,0); }
      | F_DEC expr4       { $$=mknode(F_DEC,$2,0); }
-     | F_NOT expr2        { $$=mknode(F_NOT,$2,0); }
+     | F_NOT expr2        { $$=mkopernode("`!",$2,0); }
      | '~' expr2          { $$=mkopernode("`~",$2,0); }
      | '-' expr2          { $$=mkopernode("`-",$2,0); }
      ;
diff --git a/src/las.c b/src/las.c
index 9f3165bdcf..4a34df8a89 100644
--- a/src/las.c
+++ b/src/las.c
@@ -519,7 +519,7 @@ int node_is_false(node *n)
   }
 }
 
-static node **last_cmd(node **a)
+node **last_cmd(node **a)
 {
   node **n;
   if(!a || !*a) return (node **)NULL;
@@ -563,7 +563,7 @@ static node **low_get_arg(node **a,int *nr)
   return 0;
 }
 
-/* static node **my_get_arg(node **a,int n) { return low_get_arg(a,&n); } */
+node **my_get_arg(node **a,int n) { return low_get_arg(a,&n); }
 /* static node **first_arg(node **a) { return my_get_arg(a,0); } */
 
 static void low_print_tree(node *foo,int needlval)
@@ -1163,6 +1163,17 @@ static void optimize(node *n)
 
     switch(n->token)
     {
+    case F_APPLY:
+      if(CAR(n)->token == F_CONSTANT &&
+	 CAR(n)->u.sval.type == T_FUNCTION &&
+	 CAR(n)->u.sval.subtype == -1 && /* driver fun? */
+	 CAR(n)->u.sval.u.efun->optimize)
+      {
+	if(tmp1=CAR(n)->u.sval.u.efun->optimize(n))
+	  goto use_tmp1;
+      }
+      break;
+
     case F_ARG_LIST:
     case F_LVALUE_LIST:
       if(!CAR(n)) goto use_cdr;
@@ -1372,7 +1383,7 @@ static void optimize(node *n)
 	if(inc)
 	{
 	  if(CAR(n)->token==F_LE)
-	    tmp3=mknode(F_ADD,CDAR(n),mkintnode(1));
+	    tmp3=mkopernode("`+",CDAR(n),mkintnode(1));
 	  else if(CAR(n)->token==F_LT)
 	    tmp3=CDAR(n);
 	  else
diff --git a/src/las.h b/src/las.h
index 3d99b7328a..7dd1433ead 100644
--- a/src/las.h
+++ b/src/las.h
@@ -98,6 +98,8 @@ int is_const(node *n);
 int node_is_tossable(node *n);
 int node_is_true(node *n);
 int node_is_false(node *n);
+node **last_cmd(node **a);
+node **my_get_arg(node **a,int n);
 void print_tree(node *n);
 struct used_vars;
 void fix_type_field(node *n);
diff --git a/src/lex.c b/src/lex.c
index 173b4655d5..a1ad1fdb7e 100644
--- a/src/lex.c
+++ b/src/lex.c
@@ -27,8 +27,18 @@
 #include <math.h>
 #include <fcntl.h>
 #include <errno.h>
-#ifdef HAVE_TIME_H
-#include <time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  if HAVE_TIME_H
+#   include <time.h>
+#  endif
+# endif
 #endif
 
 #define LEXDEBUG 0
diff --git a/src/lpc_signal.c b/src/lpc_signal.c
index fdbb2fea86..1195d0388f 100644
--- a/src/lpc_signal.c
+++ b/src/lpc_signal.c
@@ -186,15 +186,20 @@ static int my_signal(int sig, sigfunctype fun)
 
 static RETSIGTYPE sig_child(int arg)
 {
+  /* We carefully reap what we saw */
 #ifdef HAVE_WAITPID
-  waitpid(-1,0,WNOHANG);
+  while(waitpid(-1,0,WNOHANG) > 0); 
 #else
 #ifdef HAVE_WAIT3
-  wait3(-1,0,WNOHANG);
+  while( wait3(0,WNOHANG,0) > 0);
+#else
+#ifdef HAVE_WAIT4
+  while( wait4(-1,0,WNOHANG,0) > 0);
 #else
 
   /* Leave'em hanging */
 
+#endif /* HAVE_WAIT4 */
 #endif /* HAVE_WAIT3 */
 #endif /* HAVE_WAITPID */
 
diff --git a/src/machine.h.in b/src/machine.h.in
index 7340070012..8dd95675d5 100644
--- a/src/machine.h.in
+++ b/src/machine.h.in
@@ -40,6 +40,9 @@
 /* Define if you have the <time.h> header file.  */
 #undef HAVE_TIME_H
 
+/* Define if we may include both time.h and sys/time.h */
+#undef TIME_WITH_SYS_TIME
+
 /* Define if you have the <sys/select.h> header file. */
 #undef HAVE_SYS_SELECT_H
 
diff --git a/src/main.c b/src/main.c
index a5c0b77ef3..c2cb32d47a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -22,9 +22,20 @@
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
 #endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  if HAVE_TIME_H
+#   include <time.h>
+#  endif
+# endif
 #endif
+
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
diff --git a/src/modules/files/configure.in b/src/modules/files/configure.in
index 0a088d195a..0fbedbdda8 100644
--- a/src/modules/files/configure.in
+++ b/src/modules/files/configure.in
@@ -72,11 +72,15 @@ int sig_child(int arg)
   waitpid(-1,0,WNOHANG);
 #else
 #ifdef HAVE_WAIT3
-  wait3(-1,0,WNOHANG);
+  wait3(0,WNOHANG,0);
+#else
+#ifdef HAVE_WAIT4
+  wait3(-1,0,WNOHANG,0);
 #else
 
   /* Leave'em hanging */
 
+#endif /* HAVE_WAIT4 */
 #endif /* HAVE_WAIT3 */
 #endif /* HAVE_WAITPID */
 
diff --git a/src/operators.c b/src/operators.c
index ae7a11c3da..ca9bdbce40 100644
--- a/src/operators.c
+++ b/src/operators.c
@@ -21,7 +21,7 @@
 
 #define COMPARISON(ID,NAME,EXPR) \
 void ID(INT32 args) \
-{\
+{ \
   int i; \
   if(args > 2) \
     pop_n_elems(args-2); \
@@ -218,6 +218,58 @@ static int generate_sum(node *n)
   }
 }
 
+static node *optimize_binary(node *n)
+{
+  node **first_arg, **second_arg, *ret;
+  if(count_args(CDR(n))==2)
+  {
+    first_arg=my_get_arg(&CDR(n), 0);
+    second_arg=my_get_arg(&CDR(n), 1);
+
+#ifdef DEBUG
+    if(!first_arg || !second_arg)
+      fatal("Couldn't find argument!\n");
+#endif
+
+    if((*second_arg)->type == (*first_arg)->type)
+    {
+      if((*first_arg)->token == F_APPLY &&
+	 CAR(*first_arg)->token == F_CONSTANT &&
+	 is_eq(& CAR(*first_arg)->u.sval, & CAR(n)->u.sval))
+      {
+	ret=mknode(F_APPLY,
+		   CAR(n),
+		   mknode(F_ARG_LIST,
+			  CDR(*first_arg),
+			  *second_arg));
+	CAR(n)=0;
+	CDR(*first_arg)=0;
+	*second_arg=0;
+	
+	return ret;
+      }
+      
+      if((*second_arg)->token == F_APPLY &&
+	 CAR(*second_arg)->token == F_CONSTANT &&
+	 is_eq(& CAR(*second_arg)->u.sval, & CAR(n)->u.sval))
+      {
+	ret=mknode(F_APPLY,
+		   CAR(n),
+		   mknode(F_ARG_LIST,
+			  *first_arg,
+			  CDR(*second_arg)));
+	CAR(n)=0;
+	*first_arg=0;
+	CDR(*second_arg)=0;
+	
+	return ret;
+      }
+    }
+  }
+  return 0;
+}
+
+
 static int generate_comparison(node *n)
 {
   if(count_args(CDR(n))==2)
@@ -650,7 +702,7 @@ void f_multiply(INT32 args)
   case 0: error("Too few arguments to `*\n");
   case 1: return;
   case 2: o_multiply(); return;
-  case 3: while(--args > 0) o_multiply(); 
+  default: while(--args > 0) o_multiply(); 
   }
 }
 
@@ -902,8 +954,6 @@ void o_range()
 
 void init_operators()
 {
-  
-
   add_efun2("`==",f_eq,"function(mixed,mixed:int)",0,0,generate_comparison);
   add_efun2("`!=",f_ne,"function(mixed,mixed:int)",0,0,generate_comparison);
   add_efun2("`<", f_lt,"function(int,int:int)|function(float,float:int)|function(string,string:int)",0,0,generate_comparison);
@@ -911,20 +961,20 @@ void init_operators()
   add_efun2("`>", f_gt,"function(int,int:int)|function(float,float:int)|function(string,string:int)",0,0,generate_comparison);
   add_efun2("`>=",f_ge,"function(int,int:int)|function(float,float:int)|function(string,string:int)",0,0,generate_comparison);
 
-  add_efun2("`+",f_add,"function(int ...:int)|function(float ...:float)|function(string,string|int|float ...:string)|function(string,string|int|float ...:string)|function(int|float,string,string|int|float:string)|function(array ...:array)|function(mapping ...:mapping)|function(list...:list)",0,0,generate_sum);
+  add_efun2("`+",f_add,"function(int ...:int)|function(float ...:float)|function(string,string|int|float ...:string)|function(string,string|int|float ...:string)|function(int|float,string,string|int|float:string)|function(array ...:array)|function(mapping ...:mapping)|function(list...:list)",0,optimize_binary,generate_sum);
 
   add_efun2("`-",f_minus,"function(int:int)|function(float:float)|function(array,array:array)|function(mapping,mapping:mapping)|function(list,list:list)|function(float,float:float)|function(int,int:int)|function(string,string:string)",0,0,generate_minus);
 
-  add_efun2("`&",f_and,"function(int...:int)|function(mapping...:mapping)|function(list...:list)|function(array...:array)",0,0,generate_and);
+  add_efun2("`&",f_and,"function(int...:int)|function(mapping...:mapping)|function(list...:list)|function(array...:array)",0,optimize_binary,generate_and);
 
-  add_efun2("`|",f_and,"function(int...:int)|function(mapping...:mapping)|function(list...:list)|function(array...:array)",0,0,generate_or);
+  add_efun2("`|",f_and,"function(int...:int)|function(mapping...:mapping)|function(list...:list)|function(array...:array)",0,optimize_binary,generate_or);
 
-  add_efun2("`^",f_and,"function(int...:int)|function(mapping...:mapping)|function(list...:list)|function(array...:array)",0,0,generate_xor);
+  add_efun2("`^",f_and,"function(int...:int)|function(mapping...:mapping)|function(list...:list)|function(array...:array)",0,optimize_binary,generate_xor);
 
   add_efun2("`<<",f_lsh,"function(int,int:int)",0,0,generate_lsh);
   add_efun2("`>>",f_rsh,"function(int,int:int)",0,0,generate_rsh);
 
-  add_efun2("`*",f_multiply,"function(int...:int)|function(float...:float)|function(string*,string:string)",0,0,generate_multiply);
+  add_efun2("`*",f_multiply,"function(int...:int)|function(float...:float)|function(string*,string:string)",0,optimize_binary,generate_multiply);
 
   add_efun2("`/",f_divide,"function(int,int:int)|function(float,float:float)|function(string,string:string*)",0,0,generate_divide);
 
diff --git a/src/rusage.c b/src/rusage.c
index 0a93495239..9bfa61195c 100644
--- a/src/rusage.c
+++ b/src/rusage.c
@@ -6,13 +6,21 @@
 #include "global.h"
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  if HAVE_TIME_H
+#   include <time.h>
+#  endif
+# endif
 #endif
+
 #include <fcntl.h>
-#ifdef HAVE_TIME_H
-#include <time.h>
-#endif
 #include <errno.h>
 #include "types.h"
 #include "rusage.h"
diff --git a/src/test/create_testsuite b/src/test/create_testsuite
index 5dbe7f6a33..e4b46c229d 100755
--- a/src/test/create_testsuite
+++ b/src/test/create_testsuite
@@ -1414,7 +1414,7 @@ test_eq([[implode(explode("foo","o"),"o")]],"foo")
 test_eq([[implode(({"foo","bar"}),"-")]],"foo-bar")
 test_eq([[implode(({"foo",0,"bar"}),"-")]],"foo-bar")
 test_eq([[implode(({1.0,"foo",0,"bar",this_object(),([])}),"-")]],"foo-bar")
-test_eq([[implode(({"f","o","o"}))]],"foo")
+test_eq([[implode(({"f","o","o"}),"")]],"foo")
 
 // - indices
 test_equal(indices("foo"),({0,1,2}))
-- 
GitLab