[commons-daemon] 42/52: Imported Upstream version 1.0.15

Tony Mancill tmancill at moszumanska.debian.org
Wed Nov 12 05:31:32 UTC 2014


This is an automated email from the git hooks/post-receive script.

tmancill pushed a commit to branch master
in repository commons-daemon.

commit 3e249c65af4bb59e6a13a9bee17119ffb88dd596
Author: tony mancill <tmancill at debian.org>
Date:   Fri Nov 7 07:59:38 2014 -0800

    Imported Upstream version 1.0.15
---
 NOTICE.txt                                         |    2 +-
 RELEASE-NOTES.txt                                  |   20 +-
 build.xml                                          |    6 +-
 pom.xml                                            |    4 +-
 .../daemon/support/DaemonConfiguration.java        |    4 +-
 .../commons/daemon/support/DaemonWrapper.java      |   11 +-
 src/native/unix/configure                          |  130 +-
 src/native/unix/configure.in                       |    8 +-
 src/native/unix/native/arguments.c                 |   13 +-
 src/native/unix/native/arguments.h                 |    4 +-
 src/native/unix/native/help.c                      |    6 +-
 src/native/unix/native/home.c                      |    8 +-
 src/native/unix/native/jsvc-unix.c                 |   87 +-
 src/native/unix/native/location.c                  |   14 +-
 src/native/unix/native/version.h                   |    4 +-
 src/native/unix/support/apsupport.m4               |  126 +-
 src/native/unix/support/buildconf.sh               |    2 +-
 src/native/unix/support/config.guess               | 1380 +++++++++++---------
 src/native/unix/support/config.sub                 |  143 +-
 src/native/windows/apps/prunmgr/prunmgr.c          |   36 +-
 src/native/windows/apps/prunmgr/prunmgr.h          |    2 +-
 src/native/windows/apps/prunmgr/prunmgr.manifest   |    8 +
 src/native/windows/apps/prunmgr/prunmgr.rc         |   12 +-
 src/native/windows/apps/prunsrv/Makefile           |    7 -
 src/native/windows/apps/prunsrv/prunsrv.c          |  155 ++-
 src/native/windows/apps/prunsrv/prunsrv.h          |    2 +-
 .../prunmgr.manifest => prunsrv/prunsrv.manifest}  |   12 +-
 src/native/windows/apps/prunsrv/prunsrv.rc         |    7 +-
 src/native/windows/include/javajni.h               |    7 +-
 src/native/windows/include/log.h                   |   10 +
 src/native/windows/src/javajni.c                   |  105 +-
 src/native/windows/src/log.c                       |   32 +-
 src/native/windows/src/rprocess.c                  |    6 +
 src/samples/ProcrunServiceRemove.cmd               |   84 +-
 src/site/xdoc/binaries.xml                         |   25 +-
 src/site/xdoc/download_daemon.xml                  |   52 +-
 src/site/xdoc/jsvc.xml                             |    2 +
 37 files changed, 1573 insertions(+), 963 deletions(-)

diff --git a/NOTICE.txt b/NOTICE.txt
index ec34bbc..8f329d0 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -1,5 +1,5 @@
 Apache Commons Daemon
-Copyright 1999-2012 The Apache Software Foundation
+Copyright 1999-2013 The Apache Software Foundation
 
 This product includes software developed by
 The Apache Software Foundation (http://www.apache.org/).
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 8dcd917..b1942a4 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -1,5 +1,5 @@
             Apache Commons Daemon
-               Version 1.0.10
+               Version 1.0.15
                Release Notes
 
 
@@ -30,6 +30,11 @@ Commons DAEMON 1.0.3 requires a minimum of JDK 1.3
 
 NEW FEATURES:
 
+* DAEMON-269: Support privilege escalation on Windows UAC for procmgr (1.0.12)
+* DAEMON-264: Add -cwd to jsvc so that user can specify working
+              directory. It defaults to /. (1.0.11)
+* DAEMON-262: Automatically refresh manager application (1.0.11)
+* DAEMON-245: Support privilege escalation on Windows UAC (1.0.11)
 * DAEMON-221: Add -umask to jsvc so that users don't have to
               recompile the jsvc if different umask is desired (1.0.8)
 * DAEMON-209: Add --LibraryPath to procrun for setting the
@@ -79,6 +84,19 @@ NEW FEATURES:
 
 BUG FIXES:
 
+1.0.15: DAEMON-288, DAEMON-289, DAEMON-291, DAEMON-292
+
+1.0.14: DAEMON-278, DAEMON-280, DAEMON-281, DAEMON-283, DAEMON-284, DAEMON-286,
+        DAEMON-287
+
+1.0.13: DAEMON-275, DAEMON-276
+
+1.0.12: DAEMON-268, DAEMON-272, DAEMON-274
+
+1.0.11: DAEMON-244, DAEMON-246, DAEMON-247, DAEMON-252, DAEMON-253, DAEMON-254,
+        DAEMON-255, DAEMON-257, DAEMON-261, DAEMON-263, DAEMON-265, DAEMON-266,
+        DAEMON-267
+
 1.0.10: DAEMON-241, DAEMON-242
 
 1.0.9: DAEMON-232, DAEMON-233, DAEMON-234, DAEMON-237, DAEMON-240
diff --git a/build.xml b/build.xml
index 3127393..697562d 100644
--- a/build.xml
+++ b/build.xml
@@ -19,7 +19,7 @@
 
 <!--
         "Daemon" component of the Apache Commons Subproject
-        $Id: build.xml 1292700 2012-02-23 08:28:00Z mturk $
+        $Id: build.xml 1457753 2013-03-18 13:21:31Z mturk $
 -->
 
 
@@ -59,7 +59,7 @@
   <property name="component.title"         value="Java Daemons"/>
 
   <!-- The current version number of this component -->
-  <property name="component.version"       value="1.0.10"/>
+  <property name="component.version"       value="1.0.15"/>
 
   <!-- The base directory for compilation targets -->
   <property name="build.home"              value="target"/>
@@ -214,7 +214,7 @@
                 version="true"
                doctitle="<h1>${component.title}</h1>"
             windowtitle="${component.title} (Version ${component.version})"
-                 bottom="Copyright (c) 2002-2012 - Apache Software Foundation">
+                 bottom="Copyright (c) 2002-2013 - Apache Software Foundation">
       <classpath refid="compile.classpath"/>
       <classpath location="${ant.lib}/ant.jar"/>
     </javadoc>
diff --git a/pom.xml b/pom.xml
index 99c48d5..4f7cbdf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>commons-daemon</groupId>
   <artifactId>commons-daemon</artifactId>
-  <version>1.0.10</version>
+  <version>1.0.15</version>
   <name>Commons Daemon</name>
   <!-- Daemon started in Commons in 2002 with an import of code from Tomcat,
        which is why the NOTICE file has an earlier date than the inceptionYear -->
@@ -92,7 +92,7 @@
     <maven.compile.source>1.3</maven.compile.source>
     <maven.compile.target>1.3</maven.compile.target>
     <commons.componentid>daemon</commons.componentid>
-    <commons.release.version>1.0.10</commons.release.version>
+    <commons.release.version>1.0.15</commons.release.version>
     <commons.jira.id>DAEMON</commons.jira.id>
     <commons.jira.pid>12310468</commons.jira.pid>
   </properties>
diff --git a/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java b/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
index 014b0c0..009521e 100644
--- a/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
+++ b/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
@@ -45,7 +45,7 @@ import java.text.ParseException;
  * value will be <code>${foo}</code>.
  * </p>
  *
- * @version $Id: DaemonConfiguration.java 1204010 2011-11-19 16:15:23Z ggregory $
+ * @version $Id: DaemonConfiguration.java 1299939 2012-03-13 01:02:23Z sebb $
  * @author Mladen Turk
  */
 public final class DaemonConfiguration
@@ -173,7 +173,7 @@ public final class DaemonConfiguration
     /**
      * Gets the configuration property array.
      * <p>
-     * Property array is constructed form the lsit of properties
+     * Property array is constructed form the list of properties
      * which end with <code>[index]</code>
      * </p>
      * <pre>
diff --git a/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java b/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java
index 6ee4291..8eaf852 100644
--- a/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java
+++ b/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java
@@ -15,11 +15,12 @@
  *  limitations under the License.
  */
 
-/* @version $Id: DaemonWrapper.java 1204007 2011-11-19 16:10:29Z ggregory $ */
+/* @version $Id: DaemonWrapper.java 1453245 2013-03-06 09:54:38Z mturk $ */
 
 package org.apache.commons.daemon.support;
 
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Arrays;
 import org.apache.commons.daemon.Daemon;
@@ -31,7 +32,7 @@ import org.apache.commons.daemon.DaemonContext;
  * The applications must have the mechanism to manage
  * the application lifecycle.
  *
- * @version $Id: DaemonWrapper.java 1204007 2011-11-19 16:10:29Z ggregory $
+ * @version $Id: DaemonWrapper.java 1453245 2013-03-06 09:54:38Z mturk $
  * @author Mladen Turk
  */
 public class DaemonWrapper implements Daemon
@@ -226,7 +227,11 @@ public class DaemonWrapper implements Daemon
                 System.exit(0);
             }
             else {
-                Object obj   = main.newInstance();
+                Object obj   = null;
+                if ((inst.getModifiers() & Modifier.STATIC) == 0) {
+                    // We only need object instance for non-static methods.
+                    obj = main.newInstance();
+                }
                 Object arg[] = new Object[1];
 
                 arg[0] = args;
diff --git a/src/native/unix/configure b/src/native/unix/configure
index 824bf31..1638fbe 100755
--- a/src/native/unix/configure
+++ b/src/native/unix/configure
@@ -2573,11 +2573,13 @@ echo $ECHO_N "checking C flags dependant on host system type... $ECHO_C" >&6
   sysv)
     CFLAGS="$CFLAGS -DOS_SYSV -DDSO_DLFCN"
     LIBS="$LIBS -ldl"
+    supported_os="sysv"
     ;;
   sysv4)
     CFLAGS="$CFLAGS -DOS_SYSV -DDSO_DLFCN -Kthread"
     LDFLAGS="-Kthread $LDFLAGS"
     LIBS="$LIBS -ldl"
+    supported_os="sysv4"
     ;;
   freebsd*)
     CFLAGS="$CFLAGS -DOS_FREEBSD -DDSO_DLFCN -D_THREAD_SAFE -pthread"
@@ -2587,16 +2589,17 @@ echo $ECHO_N "checking C flags dependant on host system type... $ECHO_C" >&6
   osf5*)
     CFLAGS="$CFLAGS -pthread -DOS_TRU64 -DDSO_DLFCN -D_XOPEN_SOURCE_EXTENDED"
     LDFLAGS="$LDFLAGS -pthread"
+    supported_os="osf5"
     ;;
   hpux*)
-    CFLAGS="$CFLAGS -pthread -DOS_HPUX -DDSO_DLFCN"
-    LDFLAGS="$LDFLAGS -pthread"
-    LIBS="$LIBS -lpthread"
+    CFLAGS="$CFLAGS -DOS_HPUX -DDSO_DLFCN"
     supported_os="hp-ux"
+    host_os="hpux"
     ;;
   aix5*)
     CFLAGS="$CFLAGS -DOS_AIX -DDSO_DLFCN"
     LDFLAGS="$LDFLAGS -ldl"
+    supported_os="aix5"
     ;;
   *)
     echo "$as_me:$LINENO: result: failed" >&5
@@ -2609,59 +2612,76 @@ echo "$as_me: error: Unsupported operating system \"$host_os\"" >&2;}
   case $host_cpu in
   powerpc)
     CFLAGS="$CFLAGS -DCPU=\\\"$host_cpu\\\""
-    HOST_CPU=$host_cpu;;
+    HOST_CPU=$host_cpu
+    ;;
   sparc*)
     CFLAGS="$CFLAGS -DCPU=\\\"$host_cpu\\\""
-    HOST_CPU=$host_cpu;;
+    HOST_CPU=$host_cpu
+    ;;
   i?86|x86)
     CFLAGS="$CFLAGS -DCPU=\\\"i386\\\""
-    HOST_CPU=i386;;
+    HOST_CPU=i386
+    ;;
   x86_64 | amd64)
     CFLAGS="$CFLAGS -DCPU=\\\"amd64\\\""
-    HOST_CPU=amd64;;
+    HOST_CPU=amd64
+    ;;
   bs2000)
     CFLAGS="$CFLAGS -DCPU=\\\"osd\\\" -DCHARSET_EBCDIC -DOSD_POSIX"
     supported_os="osd"
     LDFLAGS="-Kno_link_stdlibs -B llm4"
     LIBS="$LIBS -lBLSLIB"
     LDCMD="/opt/C/bin/cc"
-    HOST_CPU=osd;;
+    HOST_CPU=osd
+    ;;
   mips)
     CFLAGS="$CFLAGS -DCPU=\\\"mips\\\""
     supported_os="mips"
-    HOST_CPU=mips;;
+    HOST_CPU=mips
+    ;;
   alpha*)
     CFLAGS="$CFLAGS -DCPU=\\\"alpha\\\""
     supported_os="alpha"
-    HOST_CPU=alpha;;
+    HOST_CPU=alpha
+    ;;
   hppa2.0w|hppa64)
     CFLAGS="$CFLAGS -DCPU=\\\"PA_RISC2.0W\\\" -DSO_EXT=\\\"sl\\\""
-    HOST_CPU=PA_RISC2.0W;;
-  hppa2.0n)
+    host_cpu=hppa2.0w
+    HOST_CPU=PA_RISC2.0W
+    ;;
+  hppa2.0n|hppa32)
     CFLAGS="$CFLAGS -DCPU=\\\"PA_RISC2.0N\\\" -DSO_EXT=\\\"sl\\\""
-    HOST_CPU=PA_RISC2.0N;;
+    HOST_CPU=PA_RISC2.0N
+    ;;
   hppa2.0)
-    CFLAGS="$CFLAGS -DCPU=\\\"PA_RISC2.0\\\" -DSO_EXT=\\\"sl\\\""
-    HOST_CPU=PA_RISC2.0;;
+    if test "$host_os" = "hpux"
+    then
+        host_cpu=hppa2.0w
+        HOST_CPU=PA_RISC2.0W
+    else
+        HOST_CPU=PA_RISC2.0
+    fi
+    CFLAGS="$CFLAGS -DCPU=\\\"$HOST_CPU\\\" -DSO_EXT=\\\"sl\\\""
+    ;;
   mipsel)
     CFLAGS="$CFLAGS -DCPU=\\\"mipsel\\\""
     supported_os="mipsel"
-    HOST_CPU=mipsel;;
+    HOST_CPU=mipsel
+    ;;
   ia64w)
-    if test "$supported_os" = "hp-ux"
-    then
-        CFLAGS="$CFLAGS -mlp64 -DCPU=\\\"IA64W\\\" -DSO_EXT=\\\"so\\\""
-        LDFLAGS="$LDFLAGS -mlp64"
-    else
-        CFLAGS="$CFLAGS -DCPU=\\\"ia64\\\""
-    fi
-    HOST_CPU=ia64;;
-  ia64|ia64n)
-    if test "$supported_os" = "hp-ux"
+    CFLAGS="$CFLAGS -DCPU=\\\"IA64W\\\" -DSO_EXT=\\\"so\\\""
+    HOST_CPU=IA64W
+    ;;
+  ia64n)
+    CFLAGS="$CFLAGS -DCPU=\\\"IA64N\\\" -DSO_EXT=\\\"so\\\""
+    HOST_CPU=IA64N
+    ;;
+  ia64)
+    if test "$host_os" = "hpux"
     then
-        CFLAGS="$CFLAGS -milp32 -DCPU=\\\"IA64N\\\" -DSO_EXT=\\\"so\\\""
-        LDFLAGS="$LDFLAGS -milp32"
-        HOST_CPU=IA64N
+        CFLAGS="$CFLAGS -DCPU=\\\"IA64W\\\" -DSO_EXT=\\\"so\\\""
+        host_cpu=ia64w
+        HOST_CPU=IA64W
     else
         CFLAGS="$CFLAGS -DCPU=\\\"ia64\\\""
         HOST_CPU=ia64
@@ -2670,11 +2690,13 @@ echo "$as_me: error: Unsupported operating system \"$host_os\"" >&2;}
   s390)
     CFLAGS="$CFLAGS -DCPU=\\\"s390\\\""
     supported_os="s390"
-    HOST_CPU=s390;;
+    HOST_CPU=s390
+    ;;
   arm*)
     CFLAGS="$CFLAGS -DCPU=\\\"arm\\\""
     supported_os="arm"
-    HOST_CPU=arm;;
+    HOST_CPU=arm
+    ;;
   *)
     echo "$as_me:$LINENO: result: failed" >&5
 echo "${ECHO_T}failed" >&6
@@ -2683,6 +2705,46 @@ echo "$as_me: error: Unsupported CPU architecture \"$host_cpu\"" >&2;}
    { (exit 1); exit 1; }; };;
   esac
 
+  if test "x$GCC" = "xyes"
+  then
+    case $host_os-$host_cpu in
+    hpux-ia64n)
+        CFLAGS="-milp32 -pthread $CFLAGS"
+        LDFLAGS="-milp32 -pthread $LDFLAGS"
+        LIBS="$LIBS -lpthread"
+    ;;
+    hpux-ia64w)
+        CFLAGS="-mlp64 -pthread $CFLAGS"
+        LDFLAGS="-mlp64 -pthread $LDFLAGS"
+        LIBS="$LIBS -lpthread"
+    ;;
+    hpux-*)
+        CFLAGS="-pthread $CFLAGS"
+        LDFLAGS="-pthread $LDFLAGS"
+        LIBS="$LIBS -lpthread"
+    ;;
+    *)
+    ;;
+    esac
+  else
+    case $host_os-$host_cpu in
+    hpux-ia64n|hpux-hppa2.0n)
+        CFLAGS="+DD32 -mt $CFLAGS"
+        LDFLAGS="+DD32 -mt $LDFLAGS"
+    ;;
+    hpux-ia64w|hpux-hppa2.0w)
+        CFLAGS="+DD64 -mt $CFLAGS"
+        LDFLAGS="+DD64 -mt $LDFLAGS"
+    ;;
+    hpux-*)
+        CFLAGS="-mt $CFLAGS"
+        LDFLAGS="-mt $LDFLAGS"
+    ;;
+    *)
+    ;;
+    esac
+  fi
+
   echo "$as_me:$LINENO: result: ok" >&5
 echo "${ECHO_T}ok" >&6
 
@@ -2690,8 +2752,12 @@ echo "${ECHO_T}ok" >&6
 
 if test "$supported_os" = "darwin"
 then
+  if test -z "$JAVA_HOME" -a -x /usr/libexec/java_home
+  then
+    JAVA_HOME="`/usr/libexec/java_home 2>dev/null`"
+  fi
   if test -z "$JAVA_HOME" -a -d /System/Library/Frameworks/JavaVM.framework/Home; then
-  	JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
+    JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
   fi
 
   _prevdir=`/bin/pwd`
diff --git a/src/native/unix/configure.in b/src/native/unix/configure.in
index 2ec623d..a8a15b4 100644
--- a/src/native/unix/configure.in
+++ b/src/native/unix/configure.in
@@ -17,7 +17,7 @@ dnl
 
 dnl -------------------------------------------------------------------------
 dnl Author  Pier Fumagalli <mailto:pier.fumagalli at eng.sun.com>
-dnl Version $Id: configure.in 1292683 2012-02-23 07:37:10Z mturk $
+dnl Version $Id: configure.in 1411560 2012-11-20 06:30:13Z mturk $
 dnl -------------------------------------------------------------------------
 
 dnl -------------------------------------------------------------------------
@@ -59,8 +59,12 @@ AP_MSG_HEADER([Host support])
 AP_SUPPORTED_HOST()
 if test "$supported_os" = "darwin"
 then
+  if test -z "$JAVA_HOME" -a -x /usr/libexec/java_home
+  then
+    JAVA_HOME="`/usr/libexec/java_home 2>dev/null`"
+  fi
   if test -z "$JAVA_HOME" -a -d /System/Library/Frameworks/JavaVM.framework/Home; then
-  	JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
+    JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
   fi
 
   _prevdir=`/bin/pwd`
diff --git a/src/native/unix/native/arguments.c b/src/native/unix/native/arguments.c
index 35c5afe..760f64f 100644
--- a/src/native/unix/native/arguments.c
+++ b/src/native/unix/native/arguments.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-/* @version $Id: arguments.c 1196468 2011-11-02 06:24:11Z mturk $ */
+/* @version $Id: arguments.c 1453280 2013-03-06 10:45:30Z mturk $ */
 #include "jsvc.h"
 #include <limits.h>
 #include <glob.h>
@@ -167,6 +167,7 @@ static arg_data *parse(int argc, char *argv[])
     args->onum    = 0;            /* Zero arguments, but let's have some room */
     args->clas    = NULL;         /* No class predefined */
     args->anum    = 0;            /* Zero class specific arguments but make room*/
+    args->cwd     = "/";           /* Use root as default */
     args->outfile = "/dev/null";   /* Swallow by default */
     args->errfile = "/dev/null";   /* Swallow by default */
     args->redirectstdin = true;    /* Redirect stdin to /dev/null by default */
@@ -237,6 +238,13 @@ static arg_data *parse(int argc, char *argv[])
                 return NULL;
             }
         }
+        else if (!strcmp(argv[x], "-cwd")) {
+            args->cwd = optional(argc, argv, x++);
+            if (args->cwd == NULL) {
+                log_error("Invalid working directory specified");
+                return NULL;
+            }
+        }
         else if (!strcmp(argv[x], "-version")) {
             args->vers = true;
             args->dtch = false;
@@ -273,7 +281,8 @@ static arg_data *parse(int argc, char *argv[])
                 log_error("Invalid umask specified");
                 return NULL;
             }
-            args->umask = atoi(temp);
+            /* Parameter must be in octal */
+            args->umask = (int)strtol(temp, NULL, 8);
             if (args->umask < 02) {
                 log_error("Invalid umask specified (min=02)");
                 return NULL;
diff --git a/src/native/unix/native/arguments.h b/src/native/unix/native/arguments.h
index fc6ea56..8bacf1c 100644
--- a/src/native/unix/native/arguments.h
+++ b/src/native/unix/native/arguments.h
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-/* @version $Id: arguments.h 1196265 2011-11-01 20:43:52Z mturk $ */
+/* @version $Id: arguments.h 1412037 2012-11-21 10:01:22Z mturk $ */
 #ifndef __JSVC_ARGUMENTS_H__
 #define __JSVC_ARGUMENTS_H__
 
@@ -35,6 +35,8 @@ typedef struct {
     char *name;
     /** The JDK or JRE installation path (JAVA_HOME). */
     char *home;
+    /** Working directory (defaults to /). */
+    char *cwd;
     /** Options used to invoke the JVM. */
     char **opts;
     /** Number of JVM options. */
diff --git a/src/native/unix/native/help.c b/src/native/unix/native/help.c
index 0e7021c..21356ce 100644
--- a/src/native/unix/native/help.c
+++ b/src/native/unix/native/help.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-/* @version $Id: help.c 1196265 2011-11-01 20:43:52Z mturk $ */
+/* @version $Id: help.c 1430766 2013-01-09 10:23:01Z mturk $ */
 #include "jsvc.h"
 
 void help(home_data *data)
@@ -60,6 +60,8 @@ void help(home_data *data)
     printf("        user used to run the daemon (defaults to current user)\n");
     printf("    -verbose[:class|gc|jni]\n");
     printf("        enable verbose output\n");
+    printf("    -cwd </full/path>\n");
+    printf("        set working directory to given location (defaults to /)\n");
     printf("    -outfile </full/path/to/file>\n");
     printf("        Location for output from stdout (defaults to /dev/null)\n");
     printf("        Use the value '&2' to simulate '1>&2'\n");
@@ -99,7 +101,7 @@ void help(home_data *data)
     printf("    -keepstdin\n");
     printf("        does not redirect stdin to /dev/null\n");
     printf("\njsvc (Apache Commons Daemon) " JSVC_VERSION_STRING "\n");
-    printf("Copyright (c) 1999-2011 Apache Software Foundation.\n");
+    printf("Copyright (c) 1999-2013 Apache Software Foundation.\n");
 
     printf("\n");
 }
diff --git a/src/native/unix/native/home.c b/src/native/unix/native/home.c
index 8a411fe..8adcd4d 100644
--- a/src/native/unix/native/home.c
+++ b/src/native/unix/native/home.c
@@ -14,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 */
-/* @version $Id: home.c 1000002 2010-09-22 14:48:37Z mturk $ */
+/* @version $Id: home.c 1416921 2012-12-04 13:09:44Z mturk $ */
 #include "jsvc.h"
 
 /* Check if a path is a directory */
@@ -212,9 +212,13 @@ static home_data *find(char *path)
     home_data *data = NULL;
     int x = 0;
 
-    if (path == NULL) {
+    if (path == NULL || *path == '\0' || strcmp(path, "/") == 0) {
         log_debug("Home not specified on command line, using environment");
         path = getenv("JAVA_HOME");
+        if (path == NULL || *path == '\0' || strcmp(path, "/") == 0) {
+            /* guard against empty JAVA_HOME */
+            path = NULL;
+        }
     }
 
     if (path == NULL) {
diff --git a/src/native/unix/native/jsvc-unix.c b/src/native/unix/native/jsvc-unix.c
index 835f075..c1a9d0d 100644
--- a/src/native/unix/native/jsvc-unix.c
+++ b/src/native/unix/native/jsvc-unix.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-/* @version $Id: jsvc-unix.c 1293002 2012-02-23 22:48:24Z mturk $ */
+/* @version $Id: jsvc-unix.c 1460687 2013-03-25 14:44:32Z mturk $ */
 #include "jsvc.h"
 
 #include <signal.h>
@@ -247,12 +247,23 @@ static fd_cap_set_flag fp_cap_set_flag;
 static fd_cap_set_proc fp_cap_set_proc;
 
 static const char *libcap_locs[] = {
+#ifdef __LP64__
+    "/lib64/libcap.so.2",
+    "/lib64/libcap.so.1",
+    "/lib64/libcap.so",
+    "/usr/lib64/libcap.so.2",
+    "/usr/lib64/libcap.so.1",
+    "/usr/lib64/libcap.so",
+#endif
     "/lib/libcap.so.2",
     "/lib/libcap.so.1",
     "/lib/libcap.so",
     "/usr/lib/libcap.so.2",
     "/usr/lib/libcap.so.1",
     "/usr/lib/libcap.so",
+    "libcap.so.2",
+    "libcap.so.1",
+    "libcap.so",
     NULL
 };
 
@@ -487,6 +498,56 @@ static sighandler_t signal_set(int sig, sighandler_t newHandler)
     return hand;
 }
 
+static int mkdir0(const char *name, int perms)
+{
+    if (mkdir(name, perms) == 0)
+        return 0;
+    else
+        return errno;
+}
+
+static int mkdir1(char *name, int perms)
+{
+    int rc;
+
+    rc = mkdir0(name, perms);
+    if (rc == EEXIST)
+        return 0;
+    if (rc == ENOENT) {  /* Missing an intermediate dir */
+        char *pos;
+        if ((pos = strrchr(name, '/'))) {
+            *pos = '\0';
+            if (*name) {
+                if (!(rc = mkdir1(name, perms))) {
+                    /* Try again, now with parents created
+                     */
+                    *pos = '/';
+                    rc = mkdir0(name, perms);
+                }
+            }
+            *pos = '/';
+        }
+    }
+    return rc;
+}
+
+static int mkdir2(const char *name, int perms)
+{
+    int rc = 0;
+    char *pos;
+    char *dir = strdup(name);
+
+    if (!dir)
+        return ENOMEM;
+    if ((pos = strrchr(dir, '/'))) {
+        *pos = '\0';
+        if (*dir)
+            rc = mkdir1(dir, perms);
+    }
+    free(dir);
+    return rc;
+}
+
 /*
  * Check pid and if still running
  */
@@ -498,9 +559,16 @@ static int check_pid(arg_data *args)
     char buff[80];
     pid_t pidn = getpid();
     int i, pid;
+    int once = 0;
 
-    fd = open(args->pidf, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+retry:
+    fd = open(args->pidf, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
     if (fd < 0) {
+        if (once == 0 && (errno == ENOTDIR || errno == ENOENT)) {
+            once = 1;
+            if (mkdir2(args->pidf, S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH) == 0)
+                goto retry;
+        }
         log_error("Cannot open PID file %s, PID is %d", args->pidf, pidn);
         return -1;
     }
@@ -847,6 +915,7 @@ static FILE *loc_freopen(char *outfile, char *mode, FILE * stream)
 {
     FILE *ftest;
 
+    mkdir2(outfile, S_IRWXU);
     ftest = fopen(outfile, mode);
     if (ftest == NULL) {
         fprintf(stderr, "Unable to redirect to %s\n", outfile);
@@ -1090,6 +1159,16 @@ int main(int argc, char *argv[])
         char *p1  = NULL;
         char *p2  = NULL;
 
+        /* We don't want to use a form of exec() that searches the
+         * PATH, so require that argv[0] be either an absolute or
+         * relative path.  Error out if this isn't the case.
+         */
+        tmp = strchr(argv[0], '/');
+        if (tmp == NULL) {
+            log_error("JSVC re-exec requires execution with an absolute or relative path");
+            return 1;
+        }
+
         /*
          * There is no need to change LD_LIBRARY_PATH
          * if we were not able to find a path to libjvm.so
@@ -1154,6 +1233,10 @@ int main(int argc, char *argv[])
 #endif
     }
 
+    if (chdir(args->cwd)) {
+        log_error("ERROR: jsvc was unable to "
+                  "change directory to: %s", args->cwd);
+    }
     /*
      * umask() uses inverse logic; bits are CLEAR for allowed access.
      */
diff --git a/src/native/unix/native/location.c b/src/native/unix/native/location.c
index 67784f2..2dea04d 100644
--- a/src/native/unix/native/location.c
+++ b/src/native/unix/native/location.c
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-/* @version $Id: location.c 1199195 2011-11-08 11:30:20Z mturk $ */
+/* @version $Id: location.c 1453272 2013-03-06 10:34:31Z mturk $ */
 #include "jsvc.h"
 
 /* Locations of various JVM files. We have to deal with all this madness since
@@ -33,10 +33,20 @@ char *location_home[] = {
     "/System/Library/Frameworks/JavaVM.framework/Home",
     "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/",
 #elif defined(OS_LINUX) || defined(OS_SOLARIS) || defined(OS_BSD)
+    "/usr/java/default",
     "/usr/java",
     "/usr/local/java",
+    "/usr/lib/jvm/default-java",
+    "/usr/lib/jvm/java",
     "/etc/alternatives/java_sdk",
+    "/etc/alternatives/java_sdk_openjdk",
     "/etc/alternatives/jre",
+#if defined(__LP64__)
+    "/lib64/jvm/java",
+    "/lib64/jvm/java-openjdk",
+#endif
+    "/lib/jvm/java",
+    "/lib/jvm/java-openjdk",
 #elif defined(OS_CYGWIN)
     "/cygdrive/c/WINNT/system32/java",
 #elif defined(OS_SYSV)
@@ -74,6 +84,8 @@ char *location_jvm_cfg[] = {
 char *location_jvm_default[] = {
 #if defined(OS_DARWIN)
     "$JAVA_HOME/../Libraries/libjvm.dylib",
+    "$JAVA_HOME/jre/lib/server/libjvm.dylib",
+    "$JAVA_HOME/jre/lib/client/libjvm.dylib",
 #elif defined(OS_CYGWIN)
     "$JAVA_HOME/jre/bin/classic/jvm.dll",               /* Sun JDK 1.3 */
     "$JAVA_HOME/jre/bin/client/jvm.dll",                /* Sun JDK 1.4 */
diff --git a/src/native/unix/native/version.h b/src/native/unix/native/version.h
index 35f9778..023ab14 100644
--- a/src/native/unix/native/version.h
+++ b/src/native/unix/native/version.h
@@ -31,13 +31,13 @@
 #define JSVC_MINOR_VERSION      0
 
 /** patch level */
-#define JSVC_PATCH_VERSION     10
+#define JSVC_PATCH_VERSION     15
 
 /**
  *  This symbol is defined for internal, "development" copies of JSVC.
  *  This symbol will be #undef'd for releases.
  */
-#define JSVC_IS_DEV_VERSION     0
+#define JSVC_IS_DEV_VERSION     1
 
 /** Properly quote a value as a string in the C preprocessor */
 #define JSVC_STRINGIFY(n) JSVC_STRINGIFY_HELPER(n)
diff --git a/src/native/unix/support/apsupport.m4 b/src/native/unix/support/apsupport.m4
index 8caf4ad..42d6e21 100644
--- a/src/native/unix/support/apsupport.m4
+++ b/src/native/unix/support/apsupport.m4
@@ -17,7 +17,7 @@ dnl
 
 dnl -------------------------------------------------------------------------
 dnl Author  Pier Fumagalli <mailto:pier.fumagalli at eng.sun.com>
-dnl Version $Id: apsupport.m4 1199663 2011-11-09 08:59:08Z mturk $
+dnl Version $Id: apsupport.m4 1461438 2013-03-27 08:09:02Z mturk $
 dnl -------------------------------------------------------------------------
 
 AC_DEFUN(AP_SUPPORTED_HOST,[
@@ -45,11 +45,13 @@ AC_DEFUN(AP_SUPPORTED_HOST,[
   sysv)
     CFLAGS="$CFLAGS -DOS_SYSV -DDSO_DLFCN"
     LIBS="$LIBS -ldl"
+    supported_os="sysv"
     ;;
   sysv4)
     CFLAGS="$CFLAGS -DOS_SYSV -DDSO_DLFCN -Kthread"
     LDFLAGS="-Kthread $LDFLAGS"
     LIBS="$LIBS -ldl"
+    supported_os="sysv4"
     ;;
   freebsd*)
     CFLAGS="$CFLAGS -DOS_FREEBSD -DDSO_DLFCN -D_THREAD_SAFE -pthread"
@@ -59,16 +61,17 @@ AC_DEFUN(AP_SUPPORTED_HOST,[
   osf5*)
     CFLAGS="$CFLAGS -pthread -DOS_TRU64 -DDSO_DLFCN -D_XOPEN_SOURCE_EXTENDED"
     LDFLAGS="$LDFLAGS -pthread"
+    supported_os="osf5"
     ;;
   hpux*)
-    CFLAGS="$CFLAGS -pthread -DOS_HPUX -DDSO_DLFCN"
-    LDFLAGS="$LDFLAGS -pthread"
-    LIBS="$LIBS -lpthread"
+    CFLAGS="$CFLAGS -DOS_HPUX -DDSO_DLFCN"
     supported_os="hp-ux"
+    host_os="hpux"
     ;;
   aix5*)
     CFLAGS="$CFLAGS -DOS_AIX -DDSO_DLFCN"
     LDFLAGS="$LDFLAGS -ldl"
+    supported_os="aix5"
     ;;
   *)
     AC_MSG_RESULT([failed])
@@ -78,59 +81,76 @@ AC_DEFUN(AP_SUPPORTED_HOST,[
   case $host_cpu in
   powerpc)
     CFLAGS="$CFLAGS -DCPU=\\\"$host_cpu\\\""
-    HOST_CPU=$host_cpu;;
+    HOST_CPU=$host_cpu
+    ;;
   sparc*)
     CFLAGS="$CFLAGS -DCPU=\\\"$host_cpu\\\""
-    HOST_CPU=$host_cpu;;
+    HOST_CPU=$host_cpu
+    ;;
   i?86|x86)
     CFLAGS="$CFLAGS -DCPU=\\\"i386\\\""
-    HOST_CPU=i386;;
+    HOST_CPU=i386
+    ;;
   x86_64 | amd64)
     CFLAGS="$CFLAGS -DCPU=\\\"amd64\\\""
-    HOST_CPU=amd64;;
+    HOST_CPU=amd64
+    ;;
   bs2000)
     CFLAGS="$CFLAGS -DCPU=\\\"osd\\\" -DCHARSET_EBCDIC -DOSD_POSIX"
     supported_os="osd"
     LDFLAGS="-Kno_link_stdlibs -B llm4"
     LIBS="$LIBS -lBLSLIB"
     LDCMD="/opt/C/bin/cc"
-    HOST_CPU=osd;;
+    HOST_CPU=osd
+    ;;
   mips)
     CFLAGS="$CFLAGS -DCPU=\\\"mips\\\""
     supported_os="mips"
-    HOST_CPU=mips;;
+    HOST_CPU=mips
+    ;;
   alpha*)
     CFLAGS="$CFLAGS -DCPU=\\\"alpha\\\""
     supported_os="alpha"
-    HOST_CPU=alpha;;
+    HOST_CPU=alpha
+    ;;
   hppa2.0w|hppa64)
     CFLAGS="$CFLAGS -DCPU=\\\"PA_RISC2.0W\\\" -DSO_EXT=\\\"sl\\\""
-    HOST_CPU=PA_RISC2.0W;;
-  hppa2.0n)
+    host_cpu=hppa2.0w
+    HOST_CPU=PA_RISC2.0W
+    ;;
+  hppa2.0n|hppa32)
     CFLAGS="$CFLAGS -DCPU=\\\"PA_RISC2.0N\\\" -DSO_EXT=\\\"sl\\\""
-    HOST_CPU=PA_RISC2.0N;;
+    HOST_CPU=PA_RISC2.0N
+    ;;
   hppa2.0)
-    CFLAGS="$CFLAGS -DCPU=\\\"PA_RISC2.0\\\" -DSO_EXT=\\\"sl\\\""
-    HOST_CPU=PA_RISC2.0;;
+    if test "$host_os" = "hpux"
+    then
+        host_cpu=hppa2.0w
+        HOST_CPU=PA_RISC2.0W
+    else
+        HOST_CPU=PA_RISC2.0
+    fi
+    CFLAGS="$CFLAGS -DCPU=\\\"$HOST_CPU\\\" -DSO_EXT=\\\"sl\\\""
+    ;;
   mipsel)
     CFLAGS="$CFLAGS -DCPU=\\\"mipsel\\\""
     supported_os="mipsel"
-    HOST_CPU=mipsel;;
+    HOST_CPU=mipsel
+    ;;
   ia64w)
-    if test "$supported_os" = "hp-ux"
-    then
-        CFLAGS="$CFLAGS -mlp64 -DCPU=\\\"IA64W\\\" -DSO_EXT=\\\"so\\\""
-        LDFLAGS="$LDFLAGS -mlp64"
-    else
-        CFLAGS="$CFLAGS -DCPU=\\\"ia64\\\""
-    fi
-    HOST_CPU=ia64;;
-  ia64|ia64n)
-    if test "$supported_os" = "hp-ux"
+    CFLAGS="$CFLAGS -DCPU=\\\"IA64W\\\" -DSO_EXT=\\\"so\\\""
+    HOST_CPU=IA64W
+    ;;
+  ia64n)
+    CFLAGS="$CFLAGS -DCPU=\\\"IA64N\\\" -DSO_EXT=\\\"so\\\""
+    HOST_CPU=IA64N
+    ;;
+  ia64)
+    if test "$host_os" = "hpux"
     then
-        CFLAGS="$CFLAGS -milp32 -DCPU=\\\"IA64N\\\" -DSO_EXT=\\\"so\\\""
-        LDFLAGS="$LDFLAGS -milp32"
-        HOST_CPU=IA64N
+        CFLAGS="$CFLAGS -DCPU=\\\"IA64W\\\" -DSO_EXT=\\\"so\\\""
+        host_cpu=ia64w
+        HOST_CPU=IA64W
     else
         CFLAGS="$CFLAGS -DCPU=\\\"ia64\\\""
         HOST_CPU=ia64
@@ -139,16 +159,58 @@ AC_DEFUN(AP_SUPPORTED_HOST,[
   s390)
     CFLAGS="$CFLAGS -DCPU=\\\"s390\\\""
     supported_os="s390"
-    HOST_CPU=s390;;
+    HOST_CPU=s390
+    ;;
   arm*)
     CFLAGS="$CFLAGS -DCPU=\\\"arm\\\""
     supported_os="arm"
-    HOST_CPU=arm;;
+    HOST_CPU=arm
+    ;;
   *)
     AC_MSG_RESULT([failed])
     AC_MSG_ERROR([Unsupported CPU architecture "$host_cpu"]);;
   esac
 
+  if test "x$GCC" = "xyes"
+  then
+    case $host_os-$host_cpu in
+    hpux-ia64n)
+        CFLAGS="-milp32 -pthread $CFLAGS"
+        LDFLAGS="-milp32 -pthread $LDFLAGS"
+        LIBS="$LIBS -lpthread"
+    ;;
+    hpux-ia64w)
+        CFLAGS="-mlp64 -pthread $CFLAGS"
+        LDFLAGS="-mlp64 -pthread $LDFLAGS"
+        LIBS="$LIBS -lpthread"
+    ;;
+    hpux-*)
+        CFLAGS="-pthread $CFLAGS"
+        LDFLAGS="-pthread $LDFLAGS"
+        LIBS="$LIBS -lpthread"
+    ;;
+    *)
+    ;;
+    esac
+  else
+    case $host_os-$host_cpu in
+    hpux-ia64n|hpux-hppa2.0n)
+        CFLAGS="+DD32 -mt $CFLAGS"
+        LDFLAGS="+DD32 -mt $LDFLAGS"
+    ;;
+    hpux-ia64w|hpux-hppa2.0w)
+        CFLAGS="+DD64 -mt $CFLAGS"
+        LDFLAGS="+DD64 -mt $LDFLAGS"
+    ;;
+    hpux-*)
+        CFLAGS="-mt $CFLAGS"
+        LDFLAGS="-mt $LDFLAGS"
+    ;;
+    *)
+    ;;
+    esac
+  fi
+
   AC_MSG_RESULT([ok])
   AC_SUBST(CFLAGS)
   AC_SUBST(LDFLAGS)
diff --git a/src/native/unix/support/buildconf.sh b/src/native/unix/support/buildconf.sh
index 81aae6b..ba273cc 100755
--- a/src/native/unix/support/buildconf.sh
+++ b/src/native/unix/support/buildconf.sh
@@ -16,7 +16,7 @@
 # limitations under the License.
 
 # @author  Pier Fumagalli <mailto:pier.fumagalli at eng.sun.com>
-# @version $Id: buildconf.sh 480475 2006-11-29 08:31:47Z bayard $
+# @version $Id: buildconf.sh 1433971 2013-01-16 15:08:47Z sebb $
 
 # The cache of automake always brings problems when changing *.m4 files.
 rm -rf autom4te.cache
diff --git a/src/native/unix/support/config.guess b/src/native/unix/support/config.guess
old mode 100644
new mode 100755
index ba66165..6ea3454
--- a/src/native/unix/support/config.guess
+++ b/src/native/unix/support/config.guess
@@ -1,13 +1,12 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
-#   Free Software Foundation, Inc.
+#   Copyright 1992-2013 Free Software Foundation, Inc.
 
-timestamp='2001-04-20'
+timestamp='2013-02-04'
 
 # This file 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 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
@@ -16,23 +15,22 @@ timestamp='2001-04-20'
 # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# Written by Per Bothner <bothner at cygnus.com>.
-# Please send patches to <config-patches at gnu.org>.
+# the same distribution terms that you use for the rest of that
+# program.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+#
+# Originally written by Per Bothner.
 #
-# This script attempts to guess a canonical system name similar to
-# config.sub.  If it succeeds, it prints the system name on stdout, and
-# exits with 0.  Otherwise, it exits with 1.
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
 #
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
+# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+
 
 me=`echo "$0" | sed -e 's,.*/,,'`
 
@@ -52,8 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
-Free Software Foundation, Inc.
+Copyright 1992-2013 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -65,11 +62,11 @@ Try \`$me --help' for more information."
 while test $# -gt 0 ; do
   case $1 in
     --time-stamp | --time* | -t )
-       echo "$timestamp" ; exit 0 ;;
+       echo "$timestamp" ; exit ;;
     --version | -v )
-       echo "$version" ; exit 0 ;;
+       echo "$version" ; exit ;;
     --help | --h* | -h )
-       echo "$usage"; exit 0 ;;
+       echo "$usage"; exit ;;
     -- )     # Stop option processing
        shift; break ;;
     - )	# Use stdin as input.
@@ -87,33 +84,45 @@ if test $# != 0; then
   exit 1
 fi
 
+trap 'exit 1' 1 2 15
 
-dummy=dummy-$$
-trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
 
-# CC_FOR_BUILD -- compiler used by this script.
 # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
 # use `HOST_CC' if defined, but it is deprecated.
 
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
 case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,)    echo "int dummy(){}" > $dummy.c
-	for c in cc gcc c89 ; do
-	  ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1
-	  if test $? = 0 ; then
-	     CC_FOR_BUILD="$c"; break
-	  fi
-	done
-	rm -f $dummy.c $dummy.o $dummy.rel
+ ,,)    echo "int x;" > $dummy.c ;
+	for c in cc gcc c89 c99 ; do
+	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+	     CC_FOR_BUILD="$c"; break ;
+	  fi ;
+	done ;
 	if test x"$CC_FOR_BUILD" = x ; then
-	  CC_FOR_BUILD=no_compiler_found
+	  CC_FOR_BUILD=no_compiler_found ;
 	fi
 	;;
  ,,*)   CC_FOR_BUILD=$CC ;;
  ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
-esac
+esac ; set_cc_for_build= ;'
 
 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi at noc.rutgers.edu 8/24/94.)
+# (ghazi at noc.rutgers.edu 1994-08-24)
 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
 	PATH=$PATH:/.attbin ; export PATH
 fi
@@ -127,31 +136,34 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:NetBSD:*:*)
-	# Netbsd (nbsd) targets should (where applicable) match one or
-	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# NetBSD (nbsd) targets should (where applicable) match one or
+	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
 	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
 	# switched to ELF, *-*-netbsd* would select the old
 	# object file format.  This provides both forward
 	# compatibility and a consistent mechanism for selecting the
 	# object file format.
-	# Determine the machine/vendor (is the vendor relevant).
-	case "${UNAME_MACHINE}" in
-	    amiga) machine=m68k-unknown ;;
-	    arm32) machine=arm-unknown ;;
-	    atari*) machine=m68k-atari ;;
-	    sun3*) machine=m68k-sun ;;
-	    mac68k) machine=m68k-apple ;;
-	    macppc) machine=powerpc-apple ;;
-	    hp3[0-9][05]) machine=m68k-hp ;;
-	    ibmrt|romp-ibm) machine=romp-ibm ;;
-	    *) machine=${UNAME_MACHINE}-unknown ;;
+	#
+	# Note: NetBSD doesn't particularly care about the vendor
+	# portion of the name.  We always set it to "unknown".
+	sysctl="sysctl -n hw.machine_arch"
+	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+	case "${UNAME_MACHINE_ARCH}" in
+	    armeb) machine=armeb-unknown ;;
+	    arm*) machine=arm-unknown ;;
+	    sh3el) machine=shl-unknown ;;
+	    sh3eb) machine=sh-unknown ;;
+	    sh5el) machine=sh5le-unknown ;;
+	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
 	esac
 	# The Operating System including object format, if it has switched
 	# to ELF recently, or will in the future.
-	case "${UNAME_MACHINE}" in
-	    i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
+	case "${UNAME_MACHINE_ARCH}" in
+	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+		eval $set_cc_for_build
 		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
-			| grep __ELF__ >/dev/null
+			| grep -q __ELF__
 		then
 		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
 		    # Return netbsd for either.  FIX?
@@ -161,120 +173,139 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 		fi
 		;;
 	    *)
-	        os=netbsd
+		os=netbsd
 		;;
 	esac
 	# The OS release
-	release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+	# Debian GNU/NetBSD machines have a different userland, and
+	# thus, need a distinct triplet. However, they do not need
+	# kernel version information, so it can be replaced with a
+	# suitable tag, in the style of linux-gnu.
+	case "${UNAME_VERSION}" in
+	    Debian*)
+		release='-gnu'
+		;;
+	    *)
+		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+		;;
+	esac
 	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
 	# contains redundant information, the shorter form:
 	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
 	echo "${machine}-${os}${release}"
-	exit 0 ;;
+	exit ;;
+    *:Bitrig:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+	echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
+	exit ;;
+    *:OpenBSD:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+	exit ;;
+    *:ekkoBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+	exit ;;
+    *:SolidBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+	exit ;;
+    macppc:MirBSD:*:*)
+	echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+	exit ;;
+    *:MirBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+	exit ;;
     alpha:OSF1:*:*)
-	if test $UNAME_RELEASE = "V4.0"; then
+	case $UNAME_RELEASE in
+	*4.0)
 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
-	fi
+		;;
+	*5.*)
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+		;;
+	esac
+	# According to Compaq, /usr/sbin/psrinfo has been available on
+	# OSF/1 and Tru64 systems produced since 1995.  I hope that
+	# covers most systems running today.  This code pipes the CPU
+	# types through head -n 1, so we only detect the type of CPU 0.
+	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+	case "$ALPHA_CPU_TYPE" in
+	    "EV4 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV4.5 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "LCA4 (21066/21068)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV5 (21164)")
+		UNAME_MACHINE="alphaev5" ;;
+	    "EV5.6 (21164A)")
+		UNAME_MACHINE="alphaev56" ;;
+	    "EV5.6 (21164PC)")
+		UNAME_MACHINE="alphapca56" ;;
+	    "EV5.7 (21164PC)")
+		UNAME_MACHINE="alphapca57" ;;
+	    "EV6 (21264)")
+		UNAME_MACHINE="alphaev6" ;;
+	    "EV6.7 (21264A)")
+		UNAME_MACHINE="alphaev67" ;;
+	    "EV6.8CB (21264C)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8AL (21264B)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8CX (21264D)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.9A (21264/EV69A)")
+		UNAME_MACHINE="alphaev69" ;;
+	    "EV7 (21364)")
+		UNAME_MACHINE="alphaev7" ;;
+	    "EV7.9 (21364A)")
+		UNAME_MACHINE="alphaev79" ;;
+	esac
+	# A Pn.n version is a patched version.
 	# A Vn.n version is a released version.
 	# A Tn.n version is a released field test version.
 	# A Xn.n version is an unreleased experimental baselevel.
 	# 1.2 uses "1.2" for uname -r.
-	cat <<EOF >$dummy.s
-	.data
-\$Lformat:
-	.byte 37,100,45,37,120,10,0	# "%d-%x\n"
-
-	.text
-	.globl main
-	.align 4
-	.ent main
-main:
-	.frame \$30,16,\$26,0
-	ldgp \$29,0(\$27)
-	.prologue 1
-	.long 0x47e03d80 # implver \$0
-	lda \$2,-1
-	.long 0x47e20c21 # amask \$2,\$1
-	lda \$16,\$Lformat
-	mov \$0,\$17
-	not \$1,\$18
-	jsr \$26,printf
-	ldgp \$29,0(\$26)
-	mov 0,\$16
-	jsr \$26,exit
-	.end main
-EOF
-	$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
-	if test "$?" = 0 ; then
-		case `./$dummy` in
-			0-0)
-				UNAME_MACHINE="alpha"
-				;;
-			1-0)
-				UNAME_MACHINE="alphaev5"
-				;;
-			1-1)
-				UNAME_MACHINE="alphaev56"
-				;;
-			1-101)
-				UNAME_MACHINE="alphapca56"
-				;;
-			2-303)
-				UNAME_MACHINE="alphaev6"
-				;;
-			2-307)
-				UNAME_MACHINE="alphaev67"
-				;;
-		esac
-	fi
-	rm -f $dummy.s $dummy
-	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-	exit 0 ;;
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+	exitcode=$?
+	trap '' 0
+	exit $exitcode ;;
     Alpha\ *:Windows_NT*:*)
 	# How do we know it's Interix rather than the generic POSIX subsystem?
 	# Should we change UNAME_MACHINE based on the output of uname instead
 	# of the specific Alpha model?
 	echo alpha-pc-interix
-	exit 0 ;;
+	exit ;;
     21064:Windows_NT:50:3)
 	echo alpha-dec-winnt3.5
-	exit 0 ;;
+	exit ;;
     Amiga*:UNIX_System_V:4.0:*)
 	echo m68k-unknown-sysv4
-	exit 0;;
-    amiga:OpenBSD:*:*)
-	echo m68k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     *:[Aa]miga[Oo][Ss]:*:*)
 	echo ${UNAME_MACHINE}-unknown-amigaos
-	exit 0 ;;
-    arc64:OpenBSD:*:*)
-	echo mips64el-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    arc:OpenBSD:*:*)
-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    hkmips:OpenBSD:*:*)
-	echo mips-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    pmax:OpenBSD:*:*)
-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    sgi:OpenBSD:*:*)
-	echo mips-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    wgrisc:OpenBSD:*:*)
-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-morphos
+	exit ;;
     *:OS/390:*:*)
 	echo i370-ibm-openedition
-	exit 0 ;;
+	exit ;;
+    *:z/VM:*:*)
+	echo s390-ibm-zvmoe
+	exit ;;
+    *:OS400:*:*)
+	echo powerpc-ibm-os400
+	exit ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
-	exit 0;;
+	exit ;;
+    arm*:riscos:*:*|arm*:RISCOS:*:*)
+	echo arm-unknown-riscos
+	exit ;;
     SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
 	echo hppa1.1-hitachi-hiuxmpp
-	exit 0;;
+	exit ;;
     Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
 	# akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
 	if test "`(/bin/universe) 2>/dev/null`" = att ; then
@@ -282,25 +313,51 @@ EOF
 	else
 		echo pyramid-pyramid-bsd
 	fi
-	exit 0 ;;
+	exit ;;
     NILE*:*:*:dcosx)
 	echo pyramid-pyramid-svr4
-	exit 0 ;;
+	exit ;;
+    DRS?6000:unix:4.0:6*)
+	echo sparc-icl-nx6
+	exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+	case `/usr/bin/uname -p` in
+	    sparc) echo sparc-icl-nx7; exit ;;
+	esac ;;
+    s390x:SunOS:*:*)
+	echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
     sun4H:SunOS:5.*:*)
 	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit 0 ;;
+	exit ;;
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
 	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit 0 ;;
-    i86pc:SunOS:5.*:*)
-	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit 0 ;;
+	exit ;;
+    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+	echo i386-pc-auroraux${UNAME_RELEASE}
+	exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+	eval $set_cc_for_build
+	SUN_ARCH="i386"
+	# If there is a compiler, see if it is configured for 64-bit objects.
+	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+	# This test works for both compilers.
+	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		grep IS_64BIT_ARCH >/dev/null
+	    then
+		SUN_ARCH="x86_64"
+	    fi
+	fi
+	echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
     sun4*:SunOS:6*:*)
 	# According to config.sub, this is the proper way to canonicalize
 	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
 	# it's likely to be more like Solaris than SunOS4.
 	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit 0 ;;
+	exit ;;
     sun4*:SunOS:*:*)
 	case "`/usr/bin/arch -k`" in
 	    Series*|S4*)
@@ -309,12 +366,12 @@ EOF
 	esac
 	# Japanese Language versions have a version number like `4.1.3-JL'.
 	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
-	exit 0 ;;
+	exit ;;
     sun3*:SunOS:*:*)
 	echo m68k-sun-sunos${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     sun*:*:4.2BSD:*)
-	UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
 	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
 	case "`/bin/arch`" in
 	    sun3)
@@ -324,13 +381,10 @@ EOF
 		echo sparc-sun-sunos${UNAME_RELEASE}
 		;;
 	esac
-	exit 0 ;;
+	exit ;;
     aushp:SunOS:*:*)
 	echo sparc-auspex-sunos${UNAME_RELEASE}
-	exit 0 ;;
-    atari*:OpenBSD:*:*)
-	echo m68k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     # The situation for MiNT is a little confusing.  The machine name
     # can be virtually everything (everything which is not
     # "atarist" or "atariste" at least should have a processor
@@ -340,51 +394,43 @@ EOF
     # MiNT.  But MiNT is downward compatible to TOS, so this should
     # be no problem.
     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
-	exit 0 ;;
+	echo m68k-atari-mint${UNAME_RELEASE}
+	exit ;;
     atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
 	echo m68k-atari-mint${UNAME_RELEASE}
-        exit 0 ;;
+	exit ;;
     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
-	exit 0 ;;
+	echo m68k-atari-mint${UNAME_RELEASE}
+	exit ;;
     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-        echo m68k-milan-mint${UNAME_RELEASE}
-        exit 0 ;;
+	echo m68k-milan-mint${UNAME_RELEASE}
+	exit ;;
     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-        echo m68k-hades-mint${UNAME_RELEASE}
-        exit 0 ;;
+	echo m68k-hades-mint${UNAME_RELEASE}
+	exit ;;
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-        echo m68k-unknown-mint${UNAME_RELEASE}
-        exit 0 ;;
-    sun3*:OpenBSD:*:*)
-	echo m68k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    mac68k:OpenBSD:*:*)
-	echo m68k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    mvme68k:OpenBSD:*:*)
-	echo m68k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    mvme88k:OpenBSD:*:*)
-	echo m88k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
+	echo m68k-unknown-mint${UNAME_RELEASE}
+	exit ;;
+    m68k:machten:*:*)
+	echo m68k-apple-machten${UNAME_RELEASE}
+	exit ;;
     powerpc:machten:*:*)
 	echo powerpc-apple-machten${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     RISC*:Mach:*:*)
 	echo mips-dec-mach_bsd4.3
-	exit 0 ;;
+	exit ;;
     RISC*:ULTRIX:*:*)
 	echo mips-dec-ultrix${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     VAX*:ULTRIX*:*:*)
 	echo vax-dec-ultrix${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     2020:CLIX:*:* | 2430:CLIX:*:*)
 	echo clipper-intergraph-clix${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     mips:*:*:UMIPS | mips:*:*:RISCos)
+	eval $set_cc_for_build
 	sed 's/^	//' << EOF >$dummy.c
 #ifdef __cplusplus
 #include <stdio.h>  /* for printf() prototype */
@@ -406,30 +452,36 @@ EOF
 	  exit (-1);
 	}
 EOF
-	$CC_FOR_BUILD $dummy.c -o $dummy \
-	  && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
-	  && rm -f $dummy.c $dummy && exit 0
-	rm -f $dummy.c $dummy
+	$CC_FOR_BUILD -o $dummy $dummy.c &&
+	  dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+	  SYSTEM_NAME=`$dummy $dummyarg` &&
+	    { echo "$SYSTEM_NAME"; exit; }
 	echo mips-mips-riscos${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     Motorola:PowerMAX_OS:*:*)
 	echo powerpc-motorola-powermax
-	exit 0 ;;
+	exit ;;
+    Motorola:*:4.3:PL8-*)
+	echo powerpc-harris-powermax
+	exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+	echo powerpc-harris-powermax
+	exit ;;
     Night_Hawk:Power_UNIX:*:*)
 	echo powerpc-harris-powerunix
-	exit 0 ;;
+	exit ;;
     m88k:CX/UX:7*:*)
 	echo m88k-harris-cxux7
-	exit 0 ;;
+	exit ;;
     m88k:*:4*:R4*)
 	echo m88k-motorola-sysv4
-	exit 0 ;;
+	exit ;;
     m88k:*:3*:R3*)
 	echo m88k-motorola-sysv3
-	exit 0 ;;
+	exit ;;
     AViiON:dgux:*:*)
-        # DG/UX returns AViiON for all architectures
-        UNAME_PROCESSOR=`/usr/bin/uname -p`
+	# DG/UX returns AViiON for all architectures
+	UNAME_PROCESSOR=`/usr/bin/uname -p`
 	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
 	then
 	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
@@ -442,29 +494,29 @@ EOF
 	else
 	    echo i586-dg-dgux${UNAME_RELEASE}
 	fi
- 	exit 0 ;;
+	exit ;;
     M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
 	echo m88k-dolphin-sysv3
-	exit 0 ;;
+	exit ;;
     M88*:*:R3*:*)
 	# Delta 88k system running SVR3
 	echo m88k-motorola-sysv3
-	exit 0 ;;
+	exit ;;
     XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
 	echo m88k-tektronix-sysv3
-	exit 0 ;;
+	exit ;;
     Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
 	echo m68k-tektronix-bsd
-	exit 0 ;;
+	exit ;;
     *:IRIX*:*:*)
 	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
-	exit 0 ;;
+	exit ;;
     ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
-	echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
-	exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
+	echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+	exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
     i*86:AIX:*:*)
 	echo i386-ibm-aix
-	exit 0 ;;
+	exit ;;
     ia64:AIX:*:*)
 	if [ -x /usr/bin/oslevel ] ; then
 		IBM_REV=`/usr/bin/oslevel`
@@ -472,9 +524,10 @@ EOF
 		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
 	fi
 	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
-	exit 0 ;;
+	exit ;;
     *:AIX:2:3)
 	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+		eval $set_cc_for_build
 		sed 's/^		//' << EOF >$dummy.c
 		#include <sys/systemcfg.h>
 
@@ -486,17 +539,20 @@ EOF
 			exit(0);
 			}
 EOF
-		$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
-		rm -f $dummy.c $dummy
-		echo rs6000-ibm-aix3.2.5
+		if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+		then
+			echo "$SYSTEM_NAME"
+		else
+			echo rs6000-ibm-aix3.2.5
+		fi
 	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
 		echo rs6000-ibm-aix3.2.4
 	else
 		echo rs6000-ibm-aix3.2
 	fi
-	exit 0 ;;
-    *:AIX:*:[45])
-	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+	exit ;;
+    *:AIX:*:[4567])
+	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
 	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
 		IBM_ARCH=rs6000
 	else
@@ -508,96 +564,116 @@ EOF
 		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
 	fi
 	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
-	exit 0 ;;
+	exit ;;
     *:AIX:*:*)
 	echo rs6000-ibm-aix
-	exit 0 ;;
+	exit ;;
     ibmrt:4.4BSD:*|romp-ibm:BSD:*)
 	echo romp-ibm-bsd4.4
-	exit 0 ;;
+	exit ;;
     ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
 	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
-	exit 0 ;;                           # report: romp-ibm BSD 4.3
+	exit ;;                             # report: romp-ibm BSD 4.3
     *:BOSX:*:*)
 	echo rs6000-bull-bosx
-	exit 0 ;;
+	exit ;;
     DPX/2?00:B.O.S.:*:*)
 	echo m68k-bull-sysv3
-	exit 0 ;;
+	exit ;;
     9000/[34]??:4.3bsd:1.*:*)
 	echo m68k-hp-bsd
-	exit 0 ;;
+	exit ;;
     hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
 	echo m68k-hp-bsd4.4
-	exit 0 ;;
+	exit ;;
     9000/[34678]??:HP-UX:*:*)
 	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
 	case "${UNAME_MACHINE}" in
 	    9000/31? )            HP_ARCH=m68000 ;;
 	    9000/[34]?? )         HP_ARCH=m68k ;;
 	    9000/[678][0-9][0-9])
-              case "${HPUX_REV}" in
-                11.[0-9][0-9])
-                  if [ -x /usr/bin/getconf ]; then
-                    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
-                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-                    case "${sc_cpu_version}" in
-                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
-                      532)                      # CPU_PA_RISC2_0
-                        case "${sc_kernel_bits}" in
-                          32) HP_ARCH="hppa2.0n" ;;
-                          64) HP_ARCH="hppa2.0w" ;;
-                        esac ;;
-                    esac
-                  fi ;;
-              esac
-              if [ "${HP_ARCH}" = "" ]; then
-              sed 's/^              //' << EOF >$dummy.c
+		if [ -x /usr/bin/getconf ]; then
+		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+		    case "${sc_cpu_version}" in
+		      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+		      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+		      532)                      # CPU_PA_RISC2_0
+			case "${sc_kernel_bits}" in
+			  32) HP_ARCH="hppa2.0n" ;;
+			  64) HP_ARCH="hppa2.0w" ;;
+			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+			esac ;;
+		    esac
+		fi
+		if [ "${HP_ARCH}" = "" ]; then
+		    eval $set_cc_for_build
+		    sed 's/^		//' << EOF >$dummy.c
 
-              #define _HPUX_SOURCE
-              #include <stdlib.h>
-              #include <unistd.h>
+		#define _HPUX_SOURCE
+		#include <stdlib.h>
+		#include <unistd.h>
 
-              int main ()
-              {
-              #if defined(_SC_KERNEL_BITS)
-                  long bits = sysconf(_SC_KERNEL_BITS);
-              #endif
-                  long cpu  = sysconf (_SC_CPU_VERSION);
+		int main ()
+		{
+		#if defined(_SC_KERNEL_BITS)
+		    long bits = sysconf(_SC_KERNEL_BITS);
+		#endif
+		    long cpu  = sysconf (_SC_CPU_VERSION);
 
-                  switch (cpu)
-              	{
-              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
-              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
-              	case CPU_PA_RISC2_0:
-              #if defined(_SC_KERNEL_BITS)
-              	    switch (bits)
-              		{
-              		case 64: puts ("hppa2.0w"); break;
-              		case 32: puts ("hppa2.0n"); break;
-              		default: puts ("hppa2.0"); break;
-              		} break;
-              #else  /* !defined(_SC_KERNEL_BITS) */
-              	    puts ("hppa2.0"); break;
-              #endif
-              	default: puts ("hppa1.0"); break;
-              	}
-                  exit (0);
-              }
+		    switch (cpu)
+			{
+			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+			case CPU_PA_RISC2_0:
+		#if defined(_SC_KERNEL_BITS)
+			    switch (bits)
+				{
+				case 64: puts ("hppa2.0w"); break;
+				case 32: puts ("hppa2.0n"); break;
+				default: puts ("hppa2.0"); break;
+				} break;
+		#else  /* !defined(_SC_KERNEL_BITS) */
+			    puts ("hppa2.0"); break;
+		#endif
+			default: puts ("hppa1.0"); break;
+			}
+		    exit (0);
+		}
 EOF
-	(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
-	if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
-	rm -f $dummy.c $dummy
-	fi ;;
+		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+		    test -z "$HP_ARCH" && HP_ARCH=hppa
+		fi ;;
 	esac
+	if [ ${HP_ARCH} = "hppa2.0w" ]
+	then
+	    eval $set_cc_for_build
+
+	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+	    # generating 64-bit code.  GNU and HP use different nomenclature:
+	    #
+	    # $ CC_FOR_BUILD=cc ./config.guess
+	    # => hppa2.0w-hp-hpux11.23
+	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+	    # => hppa64-hp-hpux11.23
+
+	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+		grep -q __LP64__
+	    then
+		HP_ARCH="hppa2.0w"
+	    else
+		HP_ARCH="hppa64"
+	    fi
+	fi
 	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
-	exit 0 ;;
+	exit ;;
     ia64:HP-UX:*:*)
 	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
 	echo ia64-hp-hpux${HPUX_REV}
-	exit 0 ;;
+	exit ;;
     3050*:HI-UX:*:*)
+	eval $set_cc_for_build
 	sed 's/^	//' << EOF >$dummy.c
 	#include <unistd.h>
 	int
@@ -623,239 +699,269 @@ EOF
 	  exit (0);
 	}
 EOF
-	$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
-	rm -f $dummy.c $dummy
+	$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+		{ echo "$SYSTEM_NAME"; exit; }
 	echo unknown-hitachi-hiuxwe2
-	exit 0 ;;
+	exit ;;
     9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
 	echo hppa1.1-hp-bsd
-	exit 0 ;;
+	exit ;;
     9000/8??:4.3bsd:*:*)
 	echo hppa1.0-hp-bsd
-	exit 0 ;;
-    *9??*:MPE/iX:*:*)
+	exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
 	echo hppa1.0-hp-mpeix
-	exit 0 ;;
+	exit ;;
     hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
 	echo hppa1.1-hp-osf
-	exit 0 ;;
+	exit ;;
     hp8??:OSF1:*:*)
 	echo hppa1.0-hp-osf
-	exit 0 ;;
+	exit ;;
     i*86:OSF1:*:*)
 	if [ -x /usr/sbin/sysversion ] ; then
 	    echo ${UNAME_MACHINE}-unknown-osf1mk
 	else
 	    echo ${UNAME_MACHINE}-unknown-osf1
 	fi
-	exit 0 ;;
+	exit ;;
     parisc*:Lites*:*:*)
 	echo hppa1.1-hp-lites
-	exit 0 ;;
-    hppa*:OpenBSD:*:*)
-	echo hppa-unknown-openbsd
-	exit 0 ;;
+	exit ;;
     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
 	echo c1-convex-bsd
-        exit 0 ;;
+	exit ;;
     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
 	if getsysinfo -f scalar_acc
 	then echo c32-convex-bsd
 	else echo c2-convex-bsd
 	fi
-        exit 0 ;;
+	exit ;;
     C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
 	echo c34-convex-bsd
-        exit 0 ;;
+	exit ;;
     C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
 	echo c38-convex-bsd
-        exit 0 ;;
+	exit ;;
     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
 	echo c4-convex-bsd
-        exit 0 ;;
-    CRAY*X-MP:*:*:*)
-	echo xmp-cray-unicos
-        exit 0 ;;
+	exit ;;
     CRAY*Y-MP:*:*:*)
-	echo ymp-cray-unicos${UNAME_RELEASE}
-	exit 0 ;;
+	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
     CRAY*[A-Z]90:*:*:*)
 	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
 	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
-	exit 0 ;;
+	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+	      -e 's/\.[^.]*$/.X/'
+	exit ;;
     CRAY*TS:*:*:*)
 	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit 0 ;;
-    CRAY*T3D:*:*:*)
-	echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit 0 ;;
+	exit ;;
     CRAY*T3E:*:*:*)
 	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit 0 ;;
+	exit ;;
     CRAY*SV1:*:*:*)
 	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit 0 ;;
-    CRAY-2:*:*:*)
-	echo cray2-cray-unicos
-        exit 0 ;;
+	exit ;;
+    *:UNICOS/mp:*:*)
+	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
 	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-        exit 0 ;;
-    hp300:OpenBSD:*:*)
-	echo m68k-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
+	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+	FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+	echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	exit ;;
+    5000:UNIX_System_V:4.*:*)
+	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+	FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+	echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	exit ;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
 	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     sparc*:BSD/OS:*:*)
 	echo sparc-unknown-bsdi${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     *:BSD/OS:*:*)
 	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     *:FreeBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
-	exit 0 ;;
-    *:OpenBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-	exit 0 ;;
+	UNAME_PROCESSOR=`/usr/bin/uname -p`
+	case ${UNAME_PROCESSOR} in
+	    amd64)
+		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    *)
+		echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	esac
+	exit ;;
     i*:CYGWIN*:*)
 	echo ${UNAME_MACHINE}-pc-cygwin
-	exit 0 ;;
-    i*:MINGW*:*)
+	exit ;;
+    *:MINGW64*:*)
+	echo ${UNAME_MACHINE}-pc-mingw64
+	exit ;;
+    *:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
-	exit 0 ;;
+	exit ;;
+    i*:MSYS*:*)
+	echo ${UNAME_MACHINE}-pc-msys
+	exit ;;
+    i*:windows32*:*)
+	# uname -m includes "-pc" on this system.
+	echo ${UNAME_MACHINE}-mingw32
+	exit ;;
     i*:PW*:*)
 	echo ${UNAME_MACHINE}-pc-pw32
-	exit 0 ;;
+	exit ;;
+    *:Interix*:*)
+	case ${UNAME_MACHINE} in
+	    x86)
+		echo i586-pc-interix${UNAME_RELEASE}
+		exit ;;
+	    authenticamd | genuineintel | EM64T)
+		echo x86_64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	    IA64)
+		echo ia64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+	echo i${UNAME_MACHINE}-pc-mks
+	exit ;;
+    8664:Windows_NT:*)
+	echo x86_64-pc-mks
+	exit ;;
     i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
 	# How do we know it's Interix rather than the generic POSIX subsystem?
 	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
 	# UNAME_MACHINE based on the output of uname instead of i386?
-	echo i386-pc-interix
-	exit 0 ;;
+	echo i586-pc-interix
+	exit ;;
     i*:UWIN*:*)
 	echo ${UNAME_MACHINE}-pc-uwin
-	exit 0 ;;
+	exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+	echo x86_64-unknown-cygwin
+	exit ;;
     p*:CYGWIN*:*)
 	echo powerpcle-unknown-cygwin
-	exit 0 ;;
+	exit ;;
     prep*:SunOS:5.*:*)
 	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit 0 ;;
+	exit ;;
     *:GNU:*:*)
+	# the GNU system
 	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
-	exit 0 ;;
+	exit ;;
+    *:GNU/*:*:*)
+	# other systems with GNU libc and userland
+	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+	exit ;;
     i*86:Minix:*:*)
 	echo ${UNAME_MACHINE}-pc-minix
-	exit 0 ;;
+	exit ;;
+    aarch64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    aarch64_be:Linux:*:*)
+	UNAME_MACHINE=aarch64_be
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    alpha:Linux:*:*)
+	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+	  EV5)   UNAME_MACHINE=alphaev5 ;;
+	  EV56)  UNAME_MACHINE=alphaev56 ;;
+	  PCA56) UNAME_MACHINE=alphapca56 ;;
+	  PCA57) UNAME_MACHINE=alphapca56 ;;
+	  EV6)   UNAME_MACHINE=alphaev6 ;;
+	  EV67)  UNAME_MACHINE=alphaev67 ;;
+	  EV68*) UNAME_MACHINE=alphaev68 ;;
+	esac
+	objdump --private-headers /bin/sh | grep -q ld.so.1
+	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+	exit ;;
     arm*:Linux:*:*)
+	eval $set_cc_for_build
+	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+	    | grep -q __ARM_EABI__
+	then
+	    echo ${UNAME_MACHINE}-unknown-linux-gnu
+	else
+	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+		| grep -q __ARM_PCS_VFP
+	    then
+		echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+	    else
+		echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
+	    fi
+	fi
+	exit ;;
+    avr32*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit 0 ;;
+	exit ;;
+    cris:Linux:*:*)
+	echo ${UNAME_MACHINE}-axis-linux-gnu
+	exit ;;
+    crisv32:Linux:*:*)
+	echo ${UNAME_MACHINE}-axis-linux-gnu
+	exit ;;
+    frv:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    hexagon:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    i*86:Linux:*:*)
+	LIBC=gnu
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#ifdef __dietlibc__
+	LIBC=dietlibc
+	#endif
+EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+	echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+	exit ;;
     ia64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux
-	exit 0 ;;
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    m32r*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
     m68*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit 0 ;;
-    mips:Linux:*:*)
-	cat >$dummy.c <<EOF
-#ifdef __cplusplus
-#include <stdio.h>  /* for printf() prototype */
-int main (int argc, char *argv[]) {
-#else
-int main (argc, argv) int argc; char *argv[]; {
-#endif
-#ifdef __MIPSEB__
-  printf ("%s-unknown-linux-gnu\n", argv[1]);
-#endif
-#ifdef __MIPSEL__
-  printf ("%sel-unknown-linux-gnu\n", argv[1]);
-#endif
-  return 0;
-}
+	exit ;;
+    mips:Linux:*:* | mips64:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef ${UNAME_MACHINE}
+	#undef ${UNAME_MACHINE}el
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=${UNAME_MACHINE}el
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=${UNAME_MACHINE}
+	#else
+	CPU=
+	#endif
+	#endif
 EOF
-	$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
-	rm -f $dummy.c $dummy
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
 	;;
-    ppc:Linux:*:*)
-	# Determine Lib Version
-	cat >$dummy.c <<EOF
-#include <features.h>
-#if defined(__GLIBC__)
-extern char __libc_version[];
-extern char __libc_release[];
-#endif
-main(argc, argv)
-     int argc;
-     char *argv[];
-{
-#if defined(__GLIBC__)
-  printf("%s %s\n", __libc_version, __libc_release);
-#else
-  printf("unknown\n");
-#endif
-  return 0;
-}
-EOF
-	LIBC=""
-	$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
-	if test "$?" = 0 ; then
-		./$dummy | grep 1\.99 > /dev/null
-		if test "$?" = 0 ; then LIBC="libc1" ; fi
-	fi
-	rm -f $dummy.c $dummy
-	echo powerpc-unknown-linux-gnu${LIBC}
-	exit 0 ;;
-    alpha:Linux:*:*)
-	cat <<EOF >$dummy.s
-	  .data
-	  \$Lformat:
-		.byte 37,100,45,37,120,10,0	# "%d-%x\n"
-	   .text
-		.globl main
-		.align 4
-		.ent main
-	    main:
-		.frame \$30,16,\$26,0
-		ldgp \$29,0(\$27)
-		.prologue 1
-		.long 0x47e03d80 # implver \$0
-		lda \$2,-1
-		.long 0x47e20c21 # amask \$2,\$1
-		lda \$16,\$Lformat
-		mov \$0,\$17
-		not \$1,\$18
-		jsr \$26,printf
-		ldgp \$29,0(\$26)
-		mov 0,\$16
-		jsr \$26,exit
-		.end main
-EOF
-	LIBC=""
-	$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
-	if test "$?" = 0 ; then
-		case `./$dummy` in
-		0-0)	UNAME_MACHINE="alpha" ;;
-		1-0)	UNAME_MACHINE="alphaev5" ;;
-		1-1)    UNAME_MACHINE="alphaev56" ;;
-		1-101)	UNAME_MACHINE="alphapca56" ;;
-		2-303)	UNAME_MACHINE="alphaev6" ;;
-		2-307)	UNAME_MACHINE="alphaev67" ;;
-		esac
-		objdump --private-headers $dummy | \
-		  grep ld.so.1 > /dev/null
-		if test "$?" = 0 ; then
-			LIBC="libc1"
-		fi
-	fi
-	rm -f $dummy.s $dummy
-	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
-	exit 0 ;;
+    or32:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    padre:Linux:*:*)
+	echo sparc-unknown-linux-gnu
+	exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+	echo hppa64-unknown-linux-gnu
+	exit ;;
     parisc:Linux:*:* | hppa:Linux:*:*)
 	# Look for CPU level
 	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
@@ -863,101 +969,71 @@ EOF
 	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
 	  *)    echo hppa-unknown-linux-gnu ;;
 	esac
-	exit 0 ;;
-    parisc64:Linux:*:* | hppa64:Linux:*:*)
-	echo hppa64-unknown-linux-gnu
-	exit 0 ;;
+	exit ;;
+    ppc64:Linux:*:*)
+	echo powerpc64-unknown-linux-gnu
+	exit ;;
+    ppc:Linux:*:*)
+	echo powerpc-unknown-linux-gnu
+	exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
 	echo ${UNAME_MACHINE}-ibm-linux
-	exit 0 ;;
+	exit ;;
+    sh64*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
     sh*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit 0 ;;
+	exit ;;
     sparc:Linux:*:* | sparc64:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit 0 ;;
+	exit ;;
+    tile*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    vax:Linux:*:*)
+	echo ${UNAME_MACHINE}-dec-linux-gnu
+	exit ;;
     x86_64:Linux:*:*)
-	echo x86_64-unknown-linux-gnu
-	exit 0 ;;
-    i*86:Linux:*:*)
-	# The BFD linker knows what the default object file format is, so
-	# first see if it will tell us. cd to the root directory to prevent
-	# problems with other programs or directories called `ld' in the path.
-	ld_supported_emulations=`cd /; ld --help 2>&1 \
-			 | sed -ne '/supported emulations:/!d
-				    s/[ 	][ 	]*/ /g
-				    s/.*supported emulations: *//
-				    s/ .*//
-				    p'`
-        case "$ld_supported_emulations" in
-	  i*86linux)
-		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
-		exit 0
-		;;
-	  elf_i*86)
-		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
-		;;
-	  i*86coff)
-		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
-		exit 0
-		;;
-	esac
-	# Either a pre-BFD a.out linker (linux-gnuoldld)
-	# or one that does not give us useful --help.
-	# GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
-	# If ld does not provide *any* "supported emulations:"
-	# that means it is gnuoldld.
-	test -z "$ld_supported_emulations" && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
-	case "${UNAME_MACHINE}" in
-	i*86)
-	  VENDOR=pc;
-	  ;;
-	*)
-	  VENDOR=unknown;
-	  ;;
-	esac
-	# Determine whether the default compiler is a.out or elf
-	cat >$dummy.c <<EOF
-#include <features.h>
-#ifdef __cplusplus
-#include <stdio.h>  /* for printf() prototype */
-	int main (int argc, char *argv[]) {
-#else
-	int main (argc, argv) int argc; char *argv[]; {
-#endif
-#ifdef __ELF__
-# ifdef __GLIBC__
-#  if __GLIBC__ >= 2
-    printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
-#  else
-    printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
-#  endif
-# else
-   printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
-# endif
-#else
-  printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
-#endif
-  return 0;
-}
-EOF
-	$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
-	rm -f $dummy.c $dummy
-	test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
-	;;
-# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  earlier versions
-# are messed up and put the nodename in both sysname and nodename.
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    xtensa*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
     i*86:DYNIX/ptx:4*:*)
+	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+	# earlier versions are messed up and put the nodename in both
+	# sysname and nodename.
 	echo i386-sequent-sysv4
-	exit 0 ;;
+	exit ;;
     i*86:UNIX_SV:4.2MP:2.*)
-        # Unixware is an offshoot of SVR4, but it has its own version
-        # number series starting with 2...
-        # I am not positive that other SVR4 systems won't match this,
+	# Unixware is an offshoot of SVR4, but it has its own version
+	# number series starting with 2...
+	# I am not positive that other SVR4 systems won't match this,
 	# I just have to hope.  -- rms.
-        # Use sysv4.2uw... so that sysv4* matches it.
+	# Use sysv4.2uw... so that sysv4* matches it.
 	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
-	exit 0 ;;
+	exit ;;
+    i*86:OS/2:*:*)
+	# If we were able to find `uname', then EMX Unix compatibility
+	# is probably installed.
+	echo ${UNAME_MACHINE}-pc-os2-emx
+	exit ;;
+    i*86:XTS-300:*:STOP)
+	echo ${UNAME_MACHINE}-unknown-stop
+	exit ;;
+    i*86:atheos:*:*)
+	echo ${UNAME_MACHINE}-unknown-atheos
+	exit ;;
+    i*86:syllable:*:*)
+	echo ${UNAME_MACHINE}-pc-syllable
+	exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+	echo i386-unknown-lynxos${UNAME_RELEASE}
+	exit ;;
+    i*86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit ;;
     i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
 	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
 	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
@@ -965,100 +1041,113 @@ EOF
 	else
 		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
 	fi
-	exit 0 ;;
-    i*86:*:5:7*)
-        # Fixed at (any) Pentium or better
-        UNAME_MACHINE=i586
-        if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
-	    echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
-	else
-	    echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
-	fi
-	exit 0 ;;
+	exit ;;
+    i*86:*:5:[678]*)
+	# UnixWare 7.x, OpenUNIX and OpenServer 6.
+	case `/bin/uname -X | grep "^Machine"` in
+	    *486*)	     UNAME_MACHINE=i486 ;;
+	    *Pentium)	     UNAME_MACHINE=i586 ;;
+	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+	esac
+	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+	exit ;;
     i*86:*:3.2:*)
 	if test -f /usr/options/cb.name; then
 		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
 		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
 	elif /bin/uname -X 2>/dev/null >/dev/null ; then
-		UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
-		(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
-		(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
 			&& UNAME_MACHINE=i586
-		(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
 			&& UNAME_MACHINE=i686
-		(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
 			&& UNAME_MACHINE=i686
 		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
 	else
 		echo ${UNAME_MACHINE}-pc-sysv32
 	fi
-	exit 0 ;;
-    i*86:*DOS:*:*)
-	echo ${UNAME_MACHINE}-pc-msdosdjgpp
-	exit 0 ;;
+	exit ;;
     pc:*:*:*)
 	# Left here for compatibility:
-        # uname -m prints for DJGPP always 'pc', but it prints nothing about
-        # the processor, so we play safe by assuming i386.
-	echo i386-pc-msdosdjgpp
-        exit 0 ;;
+	# uname -m prints for DJGPP always 'pc', but it prints nothing about
+	# the processor, so we play safe by assuming i586.
+	# Note: whatever this is, it MUST be the same as what config.sub
+	# prints for the "djgpp" host, or else GDB configury will decide that
+	# this is a cross-build.
+	echo i586-pc-msdosdjgpp
+	exit ;;
     Intel:Mach:3*:*)
 	echo i386-pc-mach3
-	exit 0 ;;
+	exit ;;
     paragon:*:*:*)
 	echo i860-intel-osf1
-	exit 0 ;;
+	exit ;;
     i860:*:4.*:*) # i860-SVR4
 	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
 	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
 	else # Add other i860-SVR4 vendors below as they are discovered.
 	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
 	fi
-	exit 0 ;;
+	exit ;;
     mini*:CTIX:SYS*5:*)
 	# "miniframe"
 	echo m68010-convergent-sysv
-	exit 0 ;;
-    M68*:*:R3V[567]*:*)
-	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
-    3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+	exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+	echo m68k-convergent-sysv
+	exit ;;
+    M680?0:D-NIX:5.3:*)
+	echo m68k-diab-dnix
+	exit ;;
+    M68*:*:R3V[5678]*:*)
+	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
 	OS_REL=''
 	test -r /etc/.relid \
 	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
 	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-	  && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+	  && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
 	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-	  && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
-        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-          && echo i486-ncr-sysv4 && exit 0 ;;
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	  && { echo i486-ncr-sysv4; exit; } ;;
+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+	OS_REL='.3'
+	test -r /etc/.relid \
+	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	    && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
     m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
 	echo m68k-unknown-lynxos${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     mc68030:UNIX_System_V:4.*:*)
 	echo m68k-atari-sysv4
-	exit 0 ;;
-    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
-	echo i386-unknown-lynxos${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     TSUNAMI:LynxOS:2.*:*)
 	echo sparc-unknown-lynxos${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     rs6000:LynxOS:2.*:*)
 	echo rs6000-unknown-lynxos${UNAME_RELEASE}
-	exit 0 ;;
-    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+	exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
 	echo powerpc-unknown-lynxos${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     SM[BE]S:UNIX_SV:*:*)
 	echo mips-dde-sysv${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     RM*:ReliantUNIX-*:*:*)
 	echo mips-sni-sysv4
-	exit 0 ;;
+	exit ;;
     RM*:SINIX-*:*:*)
 	echo mips-sni-sysv4
-	exit 0 ;;
+	exit ;;
     *:SINIX-*:*:*)
 	if uname -p 2>/dev/null >/dev/null ; then
 		UNAME_MACHINE=`(uname -p) 2>/dev/null`
@@ -1066,78 +1155,126 @@ EOF
 	else
 		echo ns32k-sni-sysv
 	fi
-	exit 0 ;;
-    PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-                           # says <Richard.M.Bartel at ccMail.Census.GOV>
-        echo i586-unisys-sysv4
-        exit 0 ;;
+	exit ;;
+    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+			# says <Richard.M.Bartel at ccMail.Census.GOV>
+	echo i586-unisys-sysv4
+	exit ;;
     *:UNIX_System_V:4*:FTX*)
 	# From Gerald Hewes <hewes at openmarket.com>.
 	# How about differentiating between stratus architectures? -djm
 	echo hppa1.1-stratus-sysv4
-	exit 0 ;;
+	exit ;;
     *:*:*:FTX*)
 	# From seanf at swdc.stratus.com.
 	echo i860-stratus-sysv4
-	exit 0 ;;
+	exit ;;
+    i*86:VOS:*:*)
+	# From Paul.Green at stratus.com.
+	echo ${UNAME_MACHINE}-stratus-vos
+	exit ;;
+    *:VOS:*:*)
+	# From Paul.Green at stratus.com.
+	echo hppa1.1-stratus-vos
+	exit ;;
     mc68*:A/UX:*:*)
 	echo m68k-apple-aux${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     news*:NEWS-OS:6*:*)
 	echo mips-sony-newsos6
-	exit 0 ;;
+	exit ;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
 	if [ -d /usr/nec ]; then
-	        echo mips-nec-sysv${UNAME_RELEASE}
+		echo mips-nec-sysv${UNAME_RELEASE}
 	else
-	        echo mips-unknown-sysv${UNAME_RELEASE}
+		echo mips-unknown-sysv${UNAME_RELEASE}
 	fi
-        exit 0 ;;
+	exit ;;
     BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
 	echo powerpc-be-beos
-	exit 0 ;;
+	exit ;;
     BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
 	echo powerpc-apple-beos
-	exit 0 ;;
+	exit ;;
     BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
 	echo i586-pc-beos
-	exit 0 ;;
+	exit ;;
+    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
+	echo i586-pc-haiku
+	exit ;;
+    x86_64:Haiku:*:*)
+	echo x86_64-unknown-haiku
+	exit ;;
     SX-4:SUPER-UX:*:*)
 	echo sx4-nec-superux${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     SX-5:SUPER-UX:*:*)
 	echo sx5-nec-superux${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
+    SX-6:SUPER-UX:*:*)
+	echo sx6-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-7:SUPER-UX:*:*)
+	echo sx7-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8:SUPER-UX:*:*)
+	echo sx8-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8R:SUPER-UX:*:*)
+	echo sx8r-nec-superux${UNAME_RELEASE}
+	exit ;;
     Power*:Rhapsody:*:*)
 	echo powerpc-apple-rhapsody${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     *:Rhapsody:*:*)
 	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     *:Darwin:*:*)
-	echo `uname -p`-apple-darwin${UNAME_RELEASE}
-	exit 0 ;;
+	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+	case $UNAME_PROCESSOR in
+	    i386)
+		eval $set_cc_for_build
+		if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+		  if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+		      (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		      grep IS_64BIT_ARCH >/dev/null
+		  then
+		      UNAME_PROCESSOR="x86_64"
+		  fi
+		fi ;;
+	    unknown) UNAME_PROCESSOR=powerpc ;;
+	esac
+	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+	exit ;;
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
-	if test "${UNAME_MACHINE}" = "x86pc"; then
+	UNAME_PROCESSOR=`uname -p`
+	if test "$UNAME_PROCESSOR" = "x86"; then
+		UNAME_PROCESSOR=i386
 		UNAME_MACHINE=pc
 	fi
-	echo `uname -p`-${UNAME_MACHINE}-nto-qnx
-	exit 0 ;;
+	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+	exit ;;
     *:QNX:*:4*)
 	echo i386-pc-qnx
-	exit 0 ;;
-    NSR-[KW]:NONSTOP_KERNEL:*:*)
+	exit ;;
+    NEO-?:NONSTOP_KERNEL:*:*)
+	echo neo-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    NSE-*:NONSTOP_KERNEL:*:*)
+	echo nse-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
 	echo nsr-tandem-nsk${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     *:NonStop-UX:*:*)
 	echo mips-compaq-nonstopux
-	exit 0 ;;
+	exit ;;
     BS2000:POSIX*:*:*)
 	echo bs2000-siemens-sysv
-	exit 0 ;;
+	exit ;;
     DS/*:UNIX_System_V:*:*)
 	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
-	exit 0 ;;
+	exit ;;
     *:Plan9:*:*)
 	# "uname -m" is not consistent, so use $cputype instead. 386
 	# is converted to i386 for consistency with other x86
@@ -1148,35 +1285,56 @@ EOF
 	    UNAME_MACHINE="$cputype"
 	fi
 	echo ${UNAME_MACHINE}-unknown-plan9
-	exit 0 ;;
-    i*86:OS/2:*:*)
-	# If we were able to find `uname', then EMX Unix compatibility
-	# is probably installed.
-	echo ${UNAME_MACHINE}-pc-os2-emx
-	exit 0 ;;
+	exit ;;
     *:TOPS-10:*:*)
 	echo pdp10-unknown-tops10
-	exit 0 ;;
+	exit ;;
     *:TENEX:*:*)
 	echo pdp10-unknown-tenex
-	exit 0 ;;
+	exit ;;
     KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
 	echo pdp10-dec-tops20
-	exit 0 ;;
+	exit ;;
     XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
 	echo pdp10-xkl-tops20
-	exit 0 ;;
+	exit ;;
     *:TOPS-20:*:*)
 	echo pdp10-unknown-tops20
-	exit 0 ;;
+	exit ;;
     *:ITS:*:*)
 	echo pdp10-unknown-its
-	exit 0 ;;
+	exit ;;
+    SEI:*:*:SEIUX)
+	echo mips-sei-seiux${UNAME_RELEASE}
+	exit ;;
+    *:DragonFly:*:*)
+	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	exit ;;
+    *:*VMS:*:*)
+	UNAME_MACHINE=`(uname -p) 2>/dev/null`
+	case "${UNAME_MACHINE}" in
+	    A*) echo alpha-dec-vms ; exit ;;
+	    I*) echo ia64-dec-vms ; exit ;;
+	    V*) echo vax-dec-vms ; exit ;;
+	esac ;;
+    *:XENIX:*:SysV)
+	echo i386-pc-xenix
+	exit ;;
+    i*86:skyos:*:*)
+	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+	exit ;;
+    i*86:rdos:*:*)
+	echo ${UNAME_MACHINE}-pc-rdos
+	exit ;;
+    i*86:AROS:*:*)
+	echo ${UNAME_MACHINE}-pc-aros
+	exit ;;
+    x86_64:VMkernel:*:*)
+	echo ${UNAME_MACHINE}-unknown-esx
+	exit ;;
 esac
 
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
+eval $set_cc_for_build
 cat >$dummy.c <<EOF
 #ifdef _SEQUENT_
 # include <sys/types.h>
@@ -1193,16 +1351,16 @@ main ()
 #include <sys/param.h>
   printf ("m68k-sony-newsos%s\n",
 #ifdef NEWSOS4
-          "4"
+	"4"
 #else
-	  ""
+	""
 #endif
-         ); exit (0);
+	); exit (0);
 #endif
 #endif
 
 #if defined (__arm) && defined (__acorn) && defined (__unix)
-  printf ("arm-acorn-riscix"); exit (0);
+  printf ("arm-acorn-riscix\n"); exit (0);
 #endif
 
 #if defined (hp300) && !defined (hpux)
@@ -1291,12 +1449,12 @@ main ()
 }
 EOF
 
-$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
-rm -f $dummy.c $dummy
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+	{ echo "$SYSTEM_NAME"; exit; }
 
 # Apollos put the system type in the environment.
 
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
 
 # Convex versions that predate uname can use getsysinfo(1)
 
@@ -1305,22 +1463,22 @@ then
     case `getsysinfo -f cpu_type` in
     c1*)
 	echo c1-convex-bsd
-	exit 0 ;;
+	exit ;;
     c2*)
 	if getsysinfo -f scalar_acc
 	then echo c32-convex-bsd
 	else echo c2-convex-bsd
 	fi
-	exit 0 ;;
+	exit ;;
     c34*)
 	echo c34-convex-bsd
-	exit 0 ;;
+	exit ;;
     c38*)
 	echo c38-convex-bsd
-	exit 0 ;;
+	exit ;;
     c4*)
 	echo c4-convex-bsd
-	exit 0 ;;
+	exit ;;
     esac
 fi
 
@@ -1331,7 +1489,9 @@ This script, last modified $timestamp, has failed to recognize
 the operating system you are using. It is advised that you
 download the most up to date version of the config scripts from
 
-    ftp://ftp.gnu.org/pub/gnu/config/
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
 
 If the version you run ($0) is already up to date, please
 send the following data and any information you think might be
diff --git a/src/native/unix/support/config.sub b/src/native/unix/support/config.sub
index 25b4fd8..26a0614 100755
--- a/src/native/unix/support/config.sub
+++ b/src/native/unix/support/config.sub
@@ -1,38 +1,31 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-#   2011 Free Software Foundation, Inc.
+#   Copyright 1992-2013 Free Software Foundation, Inc.
 
-timestamp='2011-03-23'
+timestamp='2013-02-04'
 
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine.  It does not imply ALL GNU software can.
-#
-# This file 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 of the License, or
+# This file 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 3 of the License, or
 # (at your option) any later version.
 #
-# This program 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.
+# This program 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., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
+# the same distribution terms that you use for the rest of that
+# program.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
 
 
-# Please send patches to <config-patches at gnu.org>.  Submit a context
-# diff and a properly formatted GNU ChangeLog entry.
+# Please send patches with a ChangeLog entry to config-patches at gnu.org.
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
@@ -75,9 +68,7 @@ Report bugs and patches to <config-patches at gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
-Software Foundation, Inc.
+Copyright 1992-2013 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -125,13 +116,17 @@ esac
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
-  linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
   knetbsd*-gnu* | netbsd*-gnu* | \
   kopensolaris*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
+  android-linux)
+    os=-linux-android
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+    ;;
   *)
     basic_machine=`echo $1 | sed 's/-[^-]*$//'`
     if [ $basic_machine != $1 ]
@@ -154,7 +149,7 @@ case $os in
 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple | -axis | -knuth | -cray | -microblaze)
+	-apple | -axis | -knuth | -cray | -microblaze*)
 		os=
 		basic_machine=$1
 		;;
@@ -223,6 +218,12 @@ case $os in
 	-isc*)
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
+	-lynx*178)
+		os=-lynxos178
+		;;
+	-lynx*5)
+		os=-lynxos5
+		;;
 	-lynx*)
 		os=-lynxos
 		;;
@@ -247,20 +248,27 @@ case $basic_machine in
 	# Some are omitted here because they have special meanings below.
 	1750a | 580 \
 	| a29k \
+	| aarch64 | aarch64_be \
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 	| am33_2.0 \
-	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+	| arc \
+	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+	| avr | avr32 \
+	| be32 | be64 \
 	| bfin \
 	| c4x | clipper \
 	| d10v | d30v | dlx | dsp16xx \
+	| epiphany \
 	| fido | fr30 | frv \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| hexagon \
 	| i370 | i860 | i960 | ia64 | ia64[nw] \
 	| ip2k | iq2000 \
+	| le32 | le64 \
 	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
-	| maxq | mb | microblaze | mcore | mep | metag \
+	| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips16 \
 	| mips64 | mips64el \
@@ -278,20 +286,21 @@ case $basic_machine in
 	| mipsisa64r2 | mipsisa64r2el \
 	| mipsisa64sb1 | mipsisa64sb1el \
 	| mipsisa64sr71k | mipsisa64sr71kel \
+	| mipsr5900 | mipsr5900el \
 	| mipstx39 | mipstx39el \
 	| mn10200 | mn10300 \
 	| moxie \
 	| mt \
 	| msp430 \
 	| nds32 | nds32le | nds32be \
-	| nios | nios2 \
+	| nios | nios2 | nios2eb | nios2el \
 	| ns16k | ns32k \
 	| open8 \
 	| or32 \
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| pyramid \
-	| rx \
+	| rl78 | rx \
 	| score \
 	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
@@ -300,7 +309,7 @@ case $basic_machine in
 	| spu \
 	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
 	| ubicom32 \
-	| v850 | v850e \
+	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
 	| we32k \
 	| x86 | xc16x | xstormy16 | xtensa \
 	| z8k | z80)
@@ -315,8 +324,7 @@ case $basic_machine in
 	c6x)
 		basic_machine=tic6x-unknown
 		;;
-	m6811 | m68hc11 | m6812 | m68hc12 | picochip)
-		# Motorola 68HC11/12.
+	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
 		basic_machine=$basic_machine-unknown
 		os=-none
 		;;
@@ -329,7 +337,10 @@ case $basic_machine in
 	strongarm | thumb | xscale)
 		basic_machine=arm-unknown
 		;;
-
+	xgate)
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
 	xscaleeb)
 		basic_machine=armeb-unknown
 		;;
@@ -352,11 +363,13 @@ case $basic_machine in
 	# Recognize the basic CPU types with company name.
 	580-* \
 	| a29k-* \
+	| aarch64-* | aarch64_be-* \
 	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| avr-* | avr32-* \
+	| be32-* | be64-* \
 	| bfin-* | bs2000-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* \
 	| clipper-* | craynv-* | cydra-* \
@@ -365,12 +378,15 @@ case $basic_machine in
 	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
 	| h8300-* | h8500-* \
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| hexagon-* \
 	| i*86-* | i860-* | i960-* | ia64-* | ia64[nw]-* \
 	| ip2k-* | iq2000-* \
+	| le32-* | le64-* \
 	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+	| microblaze-* | microblazeel-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
 	| mips16-* \
 	| mips64-* | mips64el-* \
@@ -388,19 +404,20 @@ case $basic_machine in
 	| mipsisa64r2-* | mipsisa64r2el-* \
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipsr5900-* | mipsr5900el-* \
 	| mipstx39-* | mipstx39el-* \
 	| mmix-* \
 	| mt-* \
 	| msp430-* \
 	| nds32-* | nds32le-* | nds32be-* \
-	| nios-* | nios2-* \
+	| nios-* | nios2-* | nios2eb-* | nios2el-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
 	| open8-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
 	| pyramid-* \
-	| romp-* | rs6000-* | rx-* \
+	| rl78-* | romp-* | rs6000-* | rx-* \
 	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
@@ -408,10 +425,11 @@ case $basic_machine in
 	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
 	| tahoe-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
-	| tile-* | tilegx-* \
+	| tile*-* \
 	| tron-* \
 	| ubicom32-* \
-	| v850-* | v850e-* | vax-* \
+	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
+	| vax-* \
 	| we32k-* \
 	| x86-* | x86_64-* | xc16x-* | xps100-* \
 	| xstormy16-* | xtensa*-* \
@@ -711,7 +729,6 @@ case $basic_machine in
 	i370-ibm* | ibm*)
 		basic_machine=i370-ibm
 		;;
-# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
 	i*86v32)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv32
@@ -769,9 +786,13 @@ case $basic_machine in
 		basic_machine=ns32k-utek
 		os=-sysv
 		;;
-	microblaze)
+	microblaze*)
 		basic_machine=microblaze-xilinx
 		;;
+	mingw64)
+		basic_machine=x86_64-pc
+		os=-mingw64
+		;;
 	mingw32)
 		basic_machine=i386-pc
 		os=-mingw32
@@ -808,10 +829,18 @@ case $basic_machine in
 	ms1-*)
 		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
 		;;
+	msys)
+		basic_machine=i386-pc
+		os=-msys
+		;;
 	mvs)
 		basic_machine=i370-ibm
 		os=-mvs
 		;;
+	nacl)
+		basic_machine=le32-unknown
+		os=-nacl
+		;;
 	ncr3000)
 		basic_machine=i486-ncr
 		os=-sysv4
@@ -992,7 +1021,11 @@ case $basic_machine in
 		basic_machine=i586-unknown
 		os=-pw32
 		;;
-	rdos)
+	rdos | rdos64)
+		basic_machine=x86_64-pc
+		os=-rdos
+		;;
+	rdos32)
 		basic_machine=i386-pc
 		os=-rdos
 		;;
@@ -1120,13 +1153,8 @@ case $basic_machine in
 		basic_machine=t90-cray
 		os=-unicos
 		;;
-	# This must be matched before tile*.
-	tilegx*)
-		basic_machine=tilegx-unknown
-		os=-linux-gnu
-		;;
 	tile*)
-		basic_machine=tile-unknown
+		basic_machine=$basic_machine-unknown
 		os=-linux-gnu
 		;;
 	tx39)
@@ -1324,21 +1352,21 @@ case $os in
 	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
 	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
-	      | -sym* | -kopensolaris* \
+	      | -sym* | -kopensolaris* | -plan9* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
 	      | -aos* | -aros* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
-	      | -openbsd* | -solidbsd* \
+	      | -bitrig* | -openbsd* | -solidbsd* \
 	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
 	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* | -cegcc* \
-	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -linux-android* \
-	      | -linux-newlib* | -linux-uclibc* \
+	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
@@ -1470,9 +1498,6 @@ case $os in
 	-aros*)
 		os=-aros
 		;;
-	-kaos*)
-		os=-kaos
-		;;
 	-zvmoe)
 		os=-zvmoe
 		;;
@@ -1521,6 +1546,9 @@ case $basic_machine in
 	c4x-* | tic4x-*)
 		os=-coff
 		;;
+	hexagon-*)
+		os=-elf
+		;;
 	tic54x-*)
 		os=-coff
 		;;
@@ -1548,9 +1576,6 @@ case $basic_machine in
 		;;
 	m68000-sun)
 		os=-sunos3
-		# This also exists in the configure program, but was not the
-		# default.
-		# os=-sunos4
 		;;
 	m68*-cisco)
 		os=-aout
diff --git a/src/native/windows/apps/prunmgr/prunmgr.c b/src/native/windows/apps/prunmgr/prunmgr.c
index 11d6db5..48f17a2 100644
--- a/src/native/windows/apps/prunmgr/prunmgr.c
+++ b/src/native/windows/apps/prunmgr/prunmgr.c
@@ -524,6 +524,7 @@ BOOL __generalStopSave(HWND hDlg)
 
 void __generalPropertyRefresh(HWND hDlg)
 {
+
     Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTART), FALSE);
     Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTOP), FALSE);
     Button_Enable(GetDlgItem(hDlg, IDC_PPSGPAUSE), FALSE);
@@ -561,6 +562,8 @@ void __generalPropertyRefresh(HWND hDlg)
 }
 
 static BOOL bpropCentered = FALSE;
+static HWND _generalPropertyHwnd = NULL;
+
 LRESULT CALLBACK __generalProperty(HWND hDlg,
                                    UINT uMessage,
                                    WPARAM wParam,
@@ -572,6 +575,7 @@ LRESULT CALLBACK __generalProperty(HWND hDlg,
     switch (uMessage) {
         case WM_INITDIALOG:
             {
+                _generalPropertyHwnd = hDlg;
                 if (!bEnableTry)
                     apxCenterWindow(GetParent(hDlg), NULL);
                 else if (!bpropCentered)
@@ -1469,6 +1473,7 @@ void ShowServiceProperties(HWND hWnd)
 
     PropertySheetW(&psH);
     _propertyOpened = FALSE;
+    _generalPropertyHwnd = NULL;
     if (!bEnableTry)
         PostQuitMessage(0);
      bpropCentered = FALSE;
@@ -1485,8 +1490,10 @@ static void signalService(LPCWSTR szServiceName)
     lstrlcatW(en, SIZ_DESLEN, szServiceName);
     lstrlcatW(en, SIZ_DESLEN, L"SIGNAL");
     for (i = 7; i < lstrlenW(en); i++) {
-        if (en[i] >= L'a' && en[i] <= L'z')
-            en[i] = en[i] - 32;
+        if (en[i] == L' ')
+            en[i] = L'_';
+        else
+            en[i] = towupper(en[i]);
     }
 
 
@@ -1609,6 +1616,27 @@ static BOOL saveConfiguration()
     return TRUE;
 }
 
+static BOOL isManagerRunning = FALSE;
+static DWORD WINAPI refreshThread(LPVOID lpParam)
+{
+    while (isManagerRunning) {
+        /* Refresh property window */
+        DWORD os = 0;
+        if (_currentEntry)
+            os = _currentEntry->stServiceStatus.dwCurrentState;
+        _currentEntry = apxServiceEntry(hService, TRUE);
+        if (_currentEntry && _currentEntry->stServiceStatus.dwCurrentState != os) {
+            if (_gui_store->hMainWnd)
+                PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+                            MAKEWPARAM(IDMS_REFRESH, 0), 0);
+            if (_generalPropertyHwnd)
+                __generalPropertyRefresh(_generalPropertyHwnd);
+        }
+        Sleep(1000);
+    }
+    return 0;
+}
+
 /* Main program entry
  * Since we are inependant from CRT
  * the arguments are not used
@@ -1738,6 +1766,8 @@ int WINAPI WinMain(HINSTANCE hInstance,
             apxDisplayError(TRUE, NULL, 0, apxLoadResourceA(IDS_ERRSREG, 0));
         return FALSE;
     }
+    isManagerRunning = TRUE;
+    CreateThread(NULL, 0, refreshThread, NULL, 0, NULL);
     /* Create main invisible window */
     _gui_store->hMainWnd = CreateWindow(_gui_store->szWndClass,
                                         apxLoadResource(IDS_APPLICATION, 0),
@@ -1751,7 +1781,6 @@ int WINAPI WinMain(HINSTANCE hInstance,
     }
     if (lpCmdline->dwCmdIndex == 3)
         PostMessage(_gui_store->hMainWnd, WM_COMMAND, IDM_TM_START, 0);
-
     while (GetMessage(&msg, NULL, 0, 0))  {
         if(!TranslateAccelerator(_gui_store->hMainWnd,
                                  _gui_store->hAccel, &msg)) {
@@ -1759,6 +1788,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
             DispatchMessage(&msg);
         }
     }
+    isManagerRunning = FALSE;
     saveConfiguration();
 
 cleanup:
diff --git a/src/native/windows/apps/prunmgr/prunmgr.h b/src/native/windows/apps/prunmgr/prunmgr.h
index 140cc0f..10c74a3 100644
--- a/src/native/windows/apps/prunmgr/prunmgr.h
+++ b/src/native/windows/apps/prunmgr/prunmgr.h
@@ -24,7 +24,7 @@
 #define _PRUNMGR_H
 
 #undef  PRG_VERSION
-#define PRG_VERSION    "1.0.10.0"
+#define PRG_VERSION    "1.0.15.0"
 #define PRG_REGROOT   L"Apache Software Foundation\\Procrun 2.0"
 
 #define IDM_TM_EXIT                     2000
diff --git a/src/native/windows/apps/prunmgr/prunmgr.manifest b/src/native/windows/apps/prunmgr/prunmgr.manifest
index 247be77..51bf9b0 100644
--- a/src/native/windows/apps/prunmgr/prunmgr.manifest
+++ b/src/native/windows/apps/prunmgr/prunmgr.manifest
@@ -23,4 +23,12 @@
 <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
 </dependentAssembly>
 </dependency>
+<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+<security>
+<!-- Windows UAC support -->
+<requestedPrivileges>
+<requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel>
+</requestedPrivileges>
+</security>
+</trustInfo>
 </assembly>
diff --git a/src/native/windows/apps/prunmgr/prunmgr.rc b/src/native/windows/apps/prunmgr/prunmgr.rc
index 26775e5..018da50 100644
--- a/src/native/windows/apps/prunmgr/prunmgr.rc
+++ b/src/native/windows/apps/prunmgr/prunmgr.rc
@@ -42,7 +42,7 @@ BEGIN
                     ES_READONLY | WS_BORDER | WS_VSCROLL,0,31,335,115
     CONTROL         "BMP_JAKARTA",IDC_STATIC,"Static",SS_BITMAP|0x00000040L,0,0,337,30
     LTEXT           " ",IDC_ABOUTAPP,2,150,270,12
-    LTEXT           "Copyright (c) 2000-2011 The Apache Software Foundation.",IDC_STATIC,2,160,270,12
+    LTEXT           "Copyright (c) 2000-2013 The Apache Software Foundation.",IDC_STATIC,2,160,270,12
     LTEXT           "http://commons.apache.org",IDC_STATIC,2,170,270,12
     PUSHBUTTON      "&System Info",IAB_SYSINF,285,170,50,14
 END
@@ -228,9 +228,9 @@ END
 STRINGTABLE
 BEGIN
     IDS_APPLICATION     RSTR_PSM
-    IDS_APPVERSION      "Version 1.0.10"
+    IDS_APPVERSION      "Version 1.0.15"
     IDS_APPFULLNAME     RSTR_PSM " Version " PRG_VERSION
-    IDS_APPCOPYRIGHT    "Copyright (c) 2000-2012 The Apache Software Foundation"
+    IDS_APPCOPYRIGHT    "Copyright (c) 2000-2013 The Apache Software Foundation"
     IDS_APPDESCRIPTION  "Apache Commons Daemon Service Management Tool"
     IDS_ALREAY_RUNING   "An instance of '%S' application is already running"
     IDS_ERRORCMD        "Unknown command line option '%s'\nSee the manual for command line usage."
@@ -259,8 +259,8 @@ BEGIN
 END
 
 1 VERSIONINFO
- FILEVERSION 1,0,10,0
- PRODUCTVERSION 1,0,10,0
+ FILEVERSION 1,0,15,0
+ PRODUCTVERSION 1,0,15,0
  FILEFLAGSMASK 0x3fL
 #if defined(_DEBUG)
  FILEFLAGS 0x03L
@@ -280,7 +280,7 @@ BEGIN
       VALUE "FileDescription", RSTR_PSM "\0"
       VALUE "FileVersion", PRG_VERSION
       VALUE "InternalName", RSTR_PSM "\0"
-      VALUE "LegalCopyright", "Copyright (c) 2000-2012 The Apache Software Foundation.\0"
+      VALUE "LegalCopyright", "Copyright (c) 2000-2013 The Apache Software Foundation.\0"
       VALUE "OriginalFilename", "prunmgr.exe\0"
       VALUE "ProductName", RSTR_PSM "\0"
       VALUE "ProductVersion", PRG_VERSION
diff --git a/src/native/windows/apps/prunsrv/Makefile b/src/native/windows/apps/prunsrv/Makefile
index 2add62b..54daec9 100644
--- a/src/native/windows/apps/prunsrv/Makefile
+++ b/src/native/windows/apps/prunsrv/Makefile
@@ -32,13 +32,6 @@ SRCDIR = .\..\..
 LFLAGS = $(LFLAGS) /stack:0x64000
 !ENDIF
 
-!IF "$(CPU)" == "X64"
-PREFIX = $(PREFIX)\amd64
-!ENDIF
-!IF "$(CPU)" == "I64"
-PREFIX = $(PREFIX)\ia64
-!ENDIF
-
 LFLAGS = $(LFLAGS) /version:1.0
 LIBS = $(LIBS) user32.lib gdi32.lib winspool.lib comdlg32.lib comctl32.lib shlwapi.lib netapi32.lib
 INCLUDES = -I$(SRCDIR)\include -I$(SRCDIR)\src $(JAVA_INCLUDES)
diff --git a/src/native/windows/apps/prunsrv/prunsrv.c b/src/native/windows/apps/prunsrv/prunsrv.c
index 334e549..af151b3 100644
--- a/src/native/windows/apps/prunsrv/prunsrv.c
+++ b/src/native/windows/apps/prunsrv/prunsrv.c
@@ -263,8 +263,11 @@ DWORD WINAPI eventThread(LPVOID lpParam)
             continue;
         }
         if (dw == WAIT_OBJECT_0 && gSignalValid) {
-            if (!GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0))
-                apxLogWrite(APXLOG_MARK_SYSERR);
+            if (!GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0)) {
+                /* Invoke Thread dump */
+                if (gWorker && _jni_startup)
+                    apxJavaDumpAllStacks(gWorker);
+            }
             ResetEvent(gSignalEvent);
             continue;
         }
@@ -284,24 +287,22 @@ static BOOL redirectStdStreams(APX_STDWRAP *lpWrapper, LPAPXCMDLINE lpCmdline)
     BOOL aErr = FALSE;
     BOOL aOut = FALSE;
 
-    if (lpWrapper->szStdOutFilename || lpWrapper->szStdErrFilename) {
-        /* Alloc console if it doesn't exists. */
-        if (!AttachConsole(ATTACH_PARENT_PROCESS) &&
-             GetLastError() == ERROR_INVALID_HANDLE) {
-            HWND hc;
-            AllocConsole();
-            if ((hc = GetConsoleWindow()) != NULL)
-                ShowWindow(hc, SW_HIDE);
-        }
+    /* Allocate console if we have none
+     */
+    if (GetConsoleWindow() == NULL) {
+        HWND hc;
+        AllocConsole();
+        if ((hc = GetConsoleWindow()) != NULL)
+            ShowWindow(hc, SW_HIDE);
     }
     /* redirect to file or console */
     if (lpWrapper->szStdOutFilename) {
         if (lstrcmpiW(lpWrapper->szStdOutFilename, PRSRV_AUTO) == 0) {
             WCHAR lsn[1024];
             aOut = TRUE;
-            lstrcpyW(lsn, lpCmdline->szApplication);
+            lstrlcpyW(lsn, 1020, lpCmdline->szApplication);
+            lstrlcatW(lsn, 1020, L"-stdout");
             lstrlocaseW(lsn);
-            lstrcatW(lsn, L"-stdout");
             lpWrapper->szStdOutFilename = apxLogFile(gPool,
                                                      lpWrapper->szLogPath,
                                                      lsn,
@@ -326,9 +327,9 @@ static BOOL redirectStdStreams(APX_STDWRAP *lpWrapper, LPAPXCMDLINE lpCmdline)
         if (lstrcmpiW(lpWrapper->szStdErrFilename, PRSRV_AUTO) == 0) {
             WCHAR lsn[1024];
             aErr = TRUE;
-            lstrcpyW(lsn, lpCmdline->szApplication);
+            lstrlcpyW(lsn, 1020, lpCmdline->szApplication);
+            lstrlcatW(lsn, 1020, L"-stderr");
             lstrlocaseW(lsn);
-            lstrcatW(lsn, L"-stderr");
             lpWrapper->szStdErrFilename = apxLogFile(gPool,
                                                      lpWrapper->szLogPath,
                                                      lsn,
@@ -382,7 +383,7 @@ static void printVersion(void)
 {
     fwprintf(stderr, L"Commons Daemon Service Runner version %S/Win%d (%S)\n",
             PRG_VERSION, PRG_BITS, __DATE__);
-    fwprintf(stderr, L"Copyright (c) 2000-2012 The Apache Software Foundation.\n\n"
+    fwprintf(stderr, L"Copyright (c) 2000-2013 The Apache Software Foundation.\n\n"
                      L"For bug reporting instructions, please see:\n"
                      L"<URL:https://issues.apache.org/jira/browse/DAEMON>.");
 }
@@ -555,6 +556,7 @@ static BOOL docmdInstallService(LPAPXCMDLINE lpCmdline)
     DWORD dwStart = SERVICE_DEMAND_START;
     DWORD dwType  = SERVICE_WIN32_OWN_PROCESS;
     WCHAR szImage[SIZ_HUGLEN];
+    WCHAR szName[SIZ_BUFLEN];
 
     apxLogWrite(APXLOG_MARK_DEBUG "Installing service...");
     hService = apxCreateService(gPool, SC_MANAGER_CREATE_SERVICE, FALSE);
@@ -579,12 +581,15 @@ static BOOL docmdInstallService(LPAPXCMDLINE lpCmdline)
         lstrlcatW(szImage, SIZ_HUGLEN, L".exe");
     }
     else
-        lstrcpyW(szImage, SO_INSTALL);
+        lstrlcpyW(szImage, SIZ_HUGLEN, SO_INSTALL);
     /* Replace not needed qoutes */
     apxStrQuoteInplaceW(szImage);
     /* Add run-service command line option */
-    lstrlcatW(szImage, SIZ_HUGLEN, L" //RS//");
-    lstrlcatW(szImage, SIZ_HUGLEN, lpCmdline->szApplication);
+    lstrlcatW(szImage, SIZ_HUGLEN, L" ");
+    lstrlcpyW(szName, SIZ_BUFLEN, L"//RS//");
+    lstrlcatW(szName, SIZ_BUFLEN, lpCmdline->szApplication);
+    apxStrQuoteInplaceW(szName);
+    lstrlcatW(szImage, SIZ_HUGLEN, szName);
     SO_INSTALL = apxPoolStrdupW(gPool, szImage);
     /* Ensure that option gets saved in the registry */
     ST_INSTALL |= APXCMDOPT_FOUND;
@@ -826,24 +831,29 @@ static BOOL docmdUpdateService(LPAPXCMDLINE lpCmdline)
 }
 
 
-/* Report the service status to the SCM
+/* Report the service status to the SCM, including service specific exit code
  */
-int reportServiceStatus(DWORD dwCurrentState,
-                        DWORD dwWin32ExitCode,
-                        DWORD dwWaitHint)
+static BOOL reportServiceStatusE(DWORD dwCurrentState,
+                                 DWORD dwWin32ExitCode,
+                                 DWORD dwWaitHint,
+                                 DWORD dwServiceSpecificExitCode)
 {
    static DWORD dwCheckPoint = 1;
    BOOL fResult = TRUE;
 
+   apxLogWrite(APXLOG_MARK_DEBUG "reportServiceStatusE: %d, %d, %d, %d",
+               dwCurrentState, dwWin32ExitCode, dwWaitHint, dwServiceSpecificExitCode);
+
    if (_service_mode && _service_status_handle) {
-       if (dwCurrentState == SERVICE_START_PENDING)
-            _service_status.dwControlsAccepted = 0;
+       if (dwCurrentState == SERVICE_RUNNING)
+            _service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
         else
-            _service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
+            _service_status.dwControlsAccepted = 0;
 
        _service_status.dwCurrentState  = dwCurrentState;
        _service_status.dwWin32ExitCode = dwWin32ExitCode;
        _service_status.dwWaitHint      = dwWaitHint;
+       _service_status.dwServiceSpecificExitCode = dwServiceSpecificExitCode;
 
        if ((dwCurrentState == SERVICE_RUNNING) ||
            (dwCurrentState == SERVICE_STOPPED))
@@ -853,11 +863,29 @@ int reportServiceStatus(DWORD dwCurrentState,
        fResult = SetServiceStatus(_service_status_handle, &_service_status);
        if (!fResult) {
            /* TODO: Deal with error */
+           apxLogWrite(APXLOG_MARK_ERROR "Failed to set service status");
        }
    }
    return fResult;
 }
 
+/* Report the service status to the SCM
+ */
+static BOOL reportServiceStatus(DWORD dwCurrentState,
+                                DWORD dwWin32ExitCode,
+                                DWORD dwWaitHint)
+{
+    return reportServiceStatusE(dwCurrentState, dwWin32ExitCode, dwWaitHint, 0);
+}
+
+static BOOL reportServiceStatusStopped(DWORD exitCode)
+{
+    if (exitCode) {
+        return reportServiceStatusE(SERVICE_STOPPED, ERROR_SERVICE_SPECIFIC_ERROR, 0, exitCode);
+    } else {
+        return reportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
+    }
+}
 
 BOOL child_callback(APXHANDLE hObject, UINT uMsg,
                     WPARAM wParam, LPARAM lParam)
@@ -880,7 +908,7 @@ static int onExitStop(void)
 {
     if (_service_mode) {
         apxLogWrite(APXLOG_MARK_DEBUG "Stop exit hook called ...");
-        reportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
+        reportServiceStatusStopped(0);
     }
     return 0;
 }
@@ -889,7 +917,16 @@ static int onExitStart(void)
 {
     if (_service_mode) {
         apxLogWrite(APXLOG_MARK_DEBUG "Start exit hook called ...");
-        reportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
+        apxLogWrite(APXLOG_MARK_DEBUG "VM exit code: %d", apxGetVmExitCode());
+        /* Reporting the service as stopped even with a non-zero exit code
+         * will not cause recovery actions to be initiated, so don't report at all.
+         * "A service is considered failed when it terminates without reporting a
+         * status of SERVICE_STOPPED to the service controller"
+         * http://msdn.microsoft.com/en-us/library/ms685939(VS.85).aspx
+         */
+        if (apxGetVmExitCode() == 0) {
+            reportServiceStatusStopped(0);
+        }
     }
     return 0;
 }
@@ -943,15 +980,17 @@ static DWORD WINAPI serviceStop(LPVOID lpParameter)
             apxLogWrite(APXLOG_MARK_ERROR "Failed starting java");
             rv = 3;
         }
-        else if (lstrcmpA(_jni_sclass, "java/lang/System") == 0) {
-            reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 5000);
-            apxLogWrite(APXLOG_MARK_DEBUG "Forcing java jni System.exit worker to finish...");
-            return 0;
-        }
         else {
-            apxLogWrite(APXLOG_MARK_DEBUG "Waiting for java jni stop worker to finish...");
-            apxJavaWait(hWorker, INFINITE, FALSE);
-            apxLogWrite(APXLOG_MARK_DEBUG "Java jni stop worker finished.");
+            if (lstrcmpA(_jni_sclass, "java/lang/System") == 0) {
+                reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 20 * 1000);
+                apxLogWrite(APXLOG_MARK_DEBUG "Forcing java jni System.exit worker to finish...");
+                return 0;
+            }
+            else {
+                apxLogWrite(APXLOG_MARK_DEBUG "Waiting for java jni stop worker to finish...");
+                apxJavaWait(hWorker, INFINITE, FALSE);
+                apxLogWrite(APXLOG_MARK_DEBUG "Java jni stop worker finished.");
+            }
         }
         wait_to_die = TRUE;
     }
@@ -1037,7 +1076,6 @@ cleanup:
         CloseHandle(gSignalThread);
         gSignalEvent = NULL;
     }
-    SetEvent(gShutdownEvent);
     if (timeout > 0x7FFFFFFF)
         timeout = INFINITE;     /* If the timeout was '-1' wait forewer */
     if (wait_to_die && !timeout)
@@ -1073,8 +1111,8 @@ cleanup:
         apxHandleSendMessage(gWorker, WM_CLOSE, 0, 0);
     }
 
-    apxLogWrite(APXLOG_MARK_INFO "Service stopped.");
-    reportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
+    apxLogWrite(APXLOG_MARK_INFO "Service stop thread completed.");
+    SetEvent(gShutdownEvent);
     return rv;
 }
 
@@ -1159,6 +1197,8 @@ static DWORD serviceStart()
             /* Add LibraryPath to the PATH */
            apxAddToPathW(gPool, SO_LIBPATH);
         }
+        /* Set the environment using putenv, so JVM can use it */
+        setInprocEnvironment();
         /* Redirect process */
         gWorker = apxCreateProcessW(gPool,
                                     0,
@@ -1259,12 +1299,14 @@ void WINAPI service_ctrl_handler(DWORD dwCtrlCode)
     HANDLE stopThread;
 
     switch (dwCtrlCode) {
+        case SERVICE_CONTROL_SHUTDOWN:
+            apxLogWrite(APXLOG_MARK_INFO "Service SHUTDOWN signaled");
         case SERVICE_CONTROL_STOP:
-            reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 3000);
+            reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 3 * 1000);
             /* Stop the service asynchronously */
             stopThread = CreateThread(NULL, 0,
                                       serviceStop,
-                                      (LPVOID)SERVICE_CONTROL_STOP,
+                                      (LPVOID)dwCtrlCode,
                                       0, &threadId);
 #if 0
             /* Seems we don't need to wait for the stop thread
@@ -1273,18 +1315,6 @@ void WINAPI service_ctrl_handler(DWORD dwCtrlCode)
             WaitForSingleObject(stopThread, INFINITE);
 #endif
             CloseHandle(stopThread);
-
-            return;
-        case SERVICE_CONTROL_SHUTDOWN:
-            apxLogWrite(APXLOG_MARK_INFO "Service SHUTDOWN signaled");
-            reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 3000);
-            /* Stop the service asynchronously */
-            stopThread = CreateThread(NULL, 0,
-                                      serviceStop,
-                                      (LPVOID)SERVICE_CONTROL_SHUTDOWN,
-                                      0, &threadId);
-            WaitForSingleObject(stopThread, INFINITE);
-            CloseHandle(stopThread);
             return;
         case SERVICE_CONTROL_INTERROGATE:
             reportServiceStatus(_service_status.dwCurrentState,
@@ -1335,8 +1365,7 @@ void WINAPI serviceMain(DWORD argc, LPTSTR *argv)
     DWORD rc = 0;
     _service_status.dwServiceType      = SERVICE_WIN32_OWN_PROCESS;
     _service_status.dwCurrentState     = SERVICE_START_PENDING;
-    _service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP |
-                                         SERVICE_ACCEPT_PAUSE_CONTINUE;
+    _service_status.dwControlsAccepted = SERVICE_CONTROL_INTERROGATE;
     _service_status.dwWin32ExitCode    = 0;
     _service_status.dwCheckPoint       = 0;
     _service_status.dwWaitHint         = 0;
@@ -1352,7 +1381,10 @@ void WINAPI serviceMain(DWORD argc, LPTSTR *argv)
         lstrlcatW(en, SIZ_DESLEN, _service_name);
         lstrlcatW(en, SIZ_DESLEN, PRSRV_SIGNAL);
         for (i = 7; i < lstrlenW(en); i++) {
-            en[i] = towlower(en[i]);
+            if (en[i] == L' ')
+                en[i] = L'_';
+            else
+                en[i] = towupper(en[i]);
         }
         gSignalEvent = CreateEventW(sa, TRUE, FALSE, en);
         CleanNullACL((void *)sa);
@@ -1505,15 +1537,18 @@ void WINAPI serviceMain(DWORD argc, LPTSTR *argv)
         goto cleanup;
     }
     if (gShutdownEvent) {
-        reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
+
         /* Ensure that shutdown thread exits before us */
         apxLogWrite(APXLOG_MARK_DEBUG "Waiting for ShutdownEvent");
+        reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, ONE_MINUTE);
         WaitForSingleObject(gShutdownEvent, ONE_MINUTE);
         apxLogWrite(APXLOG_MARK_DEBUG "ShutdownEvent signaled");
         CloseHandle(gShutdownEvent);
+
         /* This will cause to wait for all threads to exit
          */
         apxLogWrite(APXLOG_MARK_DEBUG "Waiting 1 minute for all threads to exit");
+        reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, ONE_MINUTE);
         apxDestroyJvm(ONE_MINUTE);
     }
     else {
@@ -1526,12 +1561,12 @@ void WINAPI serviceMain(DWORD argc, LPTSTR *argv)
         reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
     }
     apxLogWrite(APXLOG_MARK_DEBUG "JVM destroyed.");
-    reportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
+    reportServiceStatusStopped(apxGetVmExitCode());
 
     return;
 cleanup:
     /* Cleanup */
-    reportServiceStatus(SERVICE_STOPPED, ERROR_SERVICE_SPECIFIC_ERROR, rc);
+    reportServiceStatusStopped(rc);
     gExitval = rc;
     return;
 }
@@ -1729,8 +1764,6 @@ cleanup:
         apxLogWrite(APXLOG_MARK_INFO "Commons Daemon procrun finished");
     if (lpCmdline)
         apxCmdlineFree(lpCmdline);
-    if (_service_status_handle)
-        CloseHandle(_service_status_handle);
     _service_status_handle = NULL;
     _service_mode = FALSE;
     _flushall();
diff --git a/src/native/windows/apps/prunsrv/prunsrv.h b/src/native/windows/apps/prunsrv/prunsrv.h
index 0d7c8b6..5e1ce4c 100644
--- a/src/native/windows/apps/prunsrv/prunsrv.h
+++ b/src/native/windows/apps/prunsrv/prunsrv.h
@@ -25,7 +25,7 @@
 #define _PRUNSRV_H
 
 #undef  PRG_VERSION
-#define PRG_VERSION    "1.0.10.0"
+#define PRG_VERSION    "1.0.15.0"
 #define PRG_REGROOT   L"Apache Software Foundation\\Procrun 2.0"
 
 #endif /* _PRUNSRV_H */
diff --git a/src/native/windows/apps/prunmgr/prunmgr.manifest b/src/native/windows/apps/prunsrv/prunsrv.manifest
similarity index 76%
copy from src/native/windows/apps/prunmgr/prunmgr.manifest
copy to src/native/windows/apps/prunsrv/prunsrv.manifest
index 247be77..204a914 100644
--- a/src/native/windows/apps/prunmgr/prunmgr.manifest
+++ b/src/native/windows/apps/prunsrv/prunsrv.manifest
@@ -16,11 +16,19 @@
   limitations under the License.
 -->
 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-<assemblyIdentity version="3.1.0.0" processorArchitecture="*" name="Apache.Procrun.Prunmgr" type="win32" />
-<description>Apache Procrun Service Manager</description>
+<assemblyIdentity version="3.1.0.0" processorArchitecture="*" name="Apache.Procrun.Prunsrv" type="win32" />
+<description>Apache Commons Daemon Service Runner</description>
 <dependency>
 <dependentAssembly>
 <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
 </dependentAssembly>
 </dependency>
+<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+<security>
+<!-- Windows UAC support -->
+<requestedPrivileges>
+<requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel>
+</requestedPrivileges>
+</security>
+</trustInfo>
 </assembly>
diff --git a/src/native/windows/apps/prunsrv/prunsrv.rc b/src/native/windows/apps/prunsrv/prunsrv.rc
index 6e666cf..6357a68 100644
--- a/src/native/windows/apps/prunsrv/prunsrv.rc
+++ b/src/native/windows/apps/prunsrv/prunsrv.rc
@@ -20,10 +20,11 @@
 #define RSTR_PRUNSRV "Commons Daemon Service Runner"
 
 IDI_MAINICON         ICON                   "../../resources/procrunw.ico"
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "prunsrv.manifest"
 
 1 VERSIONINFO
- FILEVERSION 1,0,10,0
- PRODUCTVERSION 1,0,10,0
+ FILEVERSION 1,0,15,0
+ PRODUCTVERSION 1,0,15,0
  FILEFLAGSMASK 0x3fL
 #if defined(_DEBUG)
  FILEFLAGS 0x03L
@@ -43,7 +44,7 @@ BEGIN
       VALUE "FileDescription", RSTR_PRUNSRV "\0"
       VALUE "FileVersion", PRG_VERSION
       VALUE "InternalName", RSTR_PRUNSRV "\0"
-      VALUE "LegalCopyright", "Copyright (c) 2000-2012 The Apache Software Foundation.\0"
+      VALUE "LegalCopyright", "Copyright (c) 2000-2013 The Apache Software Foundation.\0"
       VALUE "OriginalFilename", "prunsrv.exe\0"
       VALUE "ProductName", RSTR_PRUNSRV "\0"
       VALUE "ProductVersion", PRG_VERSION
diff --git a/src/native/windows/include/javajni.h b/src/native/windows/include/javajni.h
index 14a1342..cc778a0 100644
--- a/src/native/windows/include/javajni.h
+++ b/src/native/windows/include/javajni.h
@@ -32,7 +32,7 @@ typedef struct stAPXJAVA_THREADARGS
     DWORD       bJniVfprintf;
     LPCSTR      szClassName;
     LPCSTR      szMethodName;
-    LPCVOID     lpArguments;    
+    LPCVOID     lpArguments;
     BOOL        setErrorOrOut;
     LPCWSTR     szStdErrFilename;
     LPCWSTR     szStdOutFilename;
@@ -63,6 +63,11 @@ DWORD       apxJavaSetOptions(APXHANDLE hJava, DWORD dwOptions);
 
 BOOL        apxDestroyJvm(DWORD dwTimeout);
 
+DWORD       apxGetVmExitCode();
+
+void        apxSetVmExitCode(DWORD exitCode);
+
+void        apxJavaDumpAllStacks(APXHANDLE hJava);
 
 __APXEND_DECLS
 
diff --git a/src/native/windows/include/log.h b/src/native/windows/include/log.h
index d7b5ed7..118035b 100644
--- a/src/native/windows/include/log.h
+++ b/src/native/windows/include/log.h
@@ -38,6 +38,16 @@ __APXBEGIN_DECLS
         UnlockFile(file, 0, 0, 512, 0);             \
     APXMACRO_END
 
+#define APX_LOGENTER()                              \
+    if (_pt_sys_loglock)                            \
+        EnterCriticalSection(_pt_sys_loglock);      \
+    else (void)0
+
+#define APX_LOGLEAVE()                              \
+    if (_pt_sys_loglock)                            \
+        LeaveCriticalSection(_pt_sys_loglock);      \
+    else (void)0
+
 #define APXLOG_LEVEL_DEBUG  0
 #define APXLOG_LEVEL_INFO   1
 #define APXLOG_LEVEL_WARN   2
diff --git a/src/native/windows/src/javajni.c b/src/native/windows/src/javajni.c
index 85a46d7..4f1cfcf 100644
--- a/src/native/windows/src/javajni.c
+++ b/src/native/windows/src/javajni.c
@@ -47,6 +47,9 @@ static DYNLOAD_FPTR_DECLARE(JNI_CreateJavaVM) = NULL;
 DYNOLAD_TYPE_DECLARE(JNI_GetCreatedJavaVMs, JNICALL, jint)(JavaVM **, jsize, jsize *);
 static DYNLOAD_FPTR_DECLARE(JNI_GetCreatedJavaVMs) = NULL;
 
+DYNOLAD_TYPE_DECLARE(JVM_DumpAllStacks, JNICALL, void)(JNIEnv *, jclass);
+static DYNLOAD_FPTR_DECLARE(JVM_DumpAllStacks) = NULL;
+
 static HANDLE  _st_sys_jvmDllHandle = NULL;
 static JavaVM *_st_sys_jvm = NULL;
 
@@ -113,6 +116,7 @@ typedef struct APXJAVAVM {
     DWORD           dwWorkerStatus;
     SIZE_T          szStackSize;
     HANDLE          hWorkerSync;
+    HANDLE          hWorkerInit;
 } APXJAVAVM, *LPAPXJAVAVM;
 
 /* This is no longer exported in jni.h
@@ -139,31 +143,42 @@ typedef struct APX_JDK1_1InitArgs {
 #define JAVA_CLASSSTRING    "java/lang/String"
 #define MSVCRT71_DLLNAME    L"\\msvcrt71.dll"
 
-static __inline BOOL __apxJvmAttach(LPAPXJAVAVM lpJava)
+static DWORD vmExitCode = 0;
+
+static __inline BOOL __apxJvmAttachEnv(LPAPXJAVAVM lpJava, JNIEnv **lpEnv,
+                                       LPBOOL lpAttached)
 {
     jint _iStatus;
 
-    if (!_st_sys_jvm)
+    if (!_st_sys_jvm || !lpJava->lpJvm)
       return FALSE;
     _iStatus = (*(lpJava->lpJvm))->GetEnv(lpJava->lpJvm,
-                                          (void **)&(lpJava->lpEnv),
+                                          (void **)lpEnv,
                                           lpJava->iVersion);
     if (_iStatus != JNI_OK) {
-        if (_iStatus == JNI_EDETACHED)
+        if (_iStatus == JNI_EDETACHED) {
             _iStatus = (*(lpJava->lpJvm))->AttachCurrentThread(lpJava->lpJvm,
-                                                (void **)&(lpJava->lpEnv), NULL);
+                                                (void **)lpEnv, NULL);
+            if (lpAttached)
+                *lpAttached = TRUE;
+        }
     }
     if (_iStatus != JNI_OK) {
-        lpJava->lpEnv = NULL;
+        *lpEnv = NULL;
         return FALSE;
     }
     else
         return TRUE;
 }
 
+static __inline BOOL __apxJvmAttach(LPAPXJAVAVM lpJava)
+{
+    return __apxJvmAttachEnv(lpJava, &lpJava->lpEnv, NULL);
+}
+
 static __inline BOOL __apxJvmDetach(LPAPXJAVAVM lpJava)
 {
-    if (!_st_sys_jvm)
+    if (!_st_sys_jvm || !lpJava->lpJvm)
       return FALSE;
     if ((*(lpJava->lpJvm))->DetachCurrentThread(lpJava->lpJvm) != JNI_OK) {
         lpJava->lpEnv = NULL;
@@ -183,10 +198,22 @@ static BOOL __apxLoadJvmDll(LPCWSTR szJvmDllPath)
     if (!IS_INVALID_HANDLE(_st_sys_jvmDllHandle))
         return TRUE;    /* jvm.dll is already loaded */
 
-    if (!dllJvmPath || *dllJvmPath == L'\0')
+    if (dllJvmPath && *dllJvmPath) {
+        /* Explicit JVM path.
+         * Check if provided argument is valid
+         */
+        if (GetFileAttributesW(dllJvmPath) == INVALID_FILE_ATTRIBUTES) {
+            /* DAEMON-247: Invalid RuntimeLib explicitly specified is error.
+             */
+            apxLogWrite(APXLOG_MARK_DEBUG "Invalid RuntimeLib specified '%S'", dllJvmPath);
+            return FALSE;
+        }
+    }
+    else {
         dllJvmPath = apxGetJavaSoftRuntimeLib(NULL);
-    if (!dllJvmPath)
-        return FALSE;
+        if (!dllJvmPath)
+            return FALSE;
+    }
     if (GetFileAttributesW(dllJvmPath) == INVALID_FILE_ATTRIBUTES) {
         /* DAEMON-184: RuntimeLib registry key is invalid.
          * Check from Jre JavaHome directly
@@ -267,6 +294,7 @@ static BOOL __apxLoadJvmDll(LPCWSTR szJvmDllPath)
     DYNLOAD_FPTR_LOAD(JNI_GetDefaultJavaVMInitArgs, _st_sys_jvmDllHandle);
     DYNLOAD_FPTR_LOAD(JNI_CreateJavaVM,             _st_sys_jvmDllHandle);
     DYNLOAD_FPTR_LOAD(JNI_GetCreatedJavaVMs,        _st_sys_jvmDllHandle);
+    DYNLOAD_FPTR_LOAD(JVM_DumpAllStacks,            _st_sys_jvmDllHandle);
 
     if (!DYNLOAD_FPTR(JNI_GetDefaultJavaVMInitArgs) ||
         !DYNLOAD_FPTR(JNI_CreateJavaVM) ||
@@ -438,6 +466,13 @@ static jint JNICALL __apxJniVfprintf(FILE *fp, const char *format, va_list args)
     return rv;
 }
 
+static void JNICALL __apxJniExit(jint exitCode)
+{
+    apxLogWrite(APXLOG_MARK_DEBUG "Exit hook with exit code %d", exitCode);
+    vmExitCode = exitCode;
+    return;
+}
+
 static LPSTR __apxStrIndexA(LPCSTR szStr, int nCh)
 {
     LPSTR pStr;
@@ -624,6 +659,9 @@ apxJavaInitialize(APXHANDLE hJava, LPCSTR szClassPath,
             ++sOptions;
         if (szClassPath && *szClassPath)
             ++sOptions;
+
+        sOptions++; /* unconditionally set for extraInfo exit */
+
         nOptions = __apxMultiSzToJvmOptions(hJava->hPool, lpOptions,
                                             &lpJvmOptions, sOptions);
         if (szClassPath && *szClassPath) {
@@ -641,6 +679,12 @@ apxJavaInitialize(APXHANDLE hJava, LPCSTR szClassPath,
             lpJvmOptions[nOptions - sOptions].extraInfo    = __apxJniVfprintf;
             --sOptions;
         }
+
+        /* unconditionally add hook for System.exit() in order to store exit code */
+        lpJvmOptions[nOptions - sOptions].optionString = "exit";
+        lpJvmOptions[nOptions - sOptions].extraInfo    = __apxJniExit;
+        --sOptions;
+
         if (dwMs) {
             wsprintfA(iB[0], "-Xms%dm", dwMs);
             lpJvmOptions[nOptions - sOptions].optionString = iB[0];
@@ -897,12 +941,18 @@ static DWORD WINAPI __apxJavaWorkerThread(LPVOID lpParameter)
     apxLogWrite(APXLOG_MARK_DEBUG "Java Worker thread started %s:%s",
                 lpJava->clWorker.sClazz, lpJava->clWorker.sMethod);
     lpJava->dwWorkerStatus = 1;
-    SetEvent(lpJava->hWorkerSync);
+    SetEvent(lpJava->hWorkerInit);
+    /* Ensure apxJavaStart worker has read our status */
+    WaitForSingleObject(lpJava->hWorkerSync, INFINITE);
     JNICALL_3(CallStaticVoidMethod,
               lpJava->clWorker.jClazz,
               lpJava->clWorker.jMethod,
               lpJava->clWorker.jArgs);
     if (JVM_EXCEPTION_CHECK(lpJava)) {
+        apxLogWrite(APXLOG_MARK_DEBUG "Exception has been thrown");
+        vmExitCode = 1;
+        (*((lpJava)->lpEnv))->ExceptionDescribe((lpJava)->lpEnv);
+        __apxJvmDetach(lpJava);
         WORKER_EXIT(6);
     }
     else {
@@ -913,7 +963,7 @@ finished:
         lpJava->dwWorkerStatus = 0;
         apxLogWrite(APXLOG_MARK_DEBUG "Java Worker thread finished %s:%s with status=%d",
                     lpJava->clWorker.sClazz, lpJava->clWorker.sMethod, rv);
-        SetEvent(lpJava->hWorkerSync);
+        SetEvent(lpJava->hWorkerInit);
     }
     ExitThread(rv);
     /* never gets here but keep the compiler happy */
@@ -928,6 +978,7 @@ apxJavaStart(LPAPXJAVA_THREADARGS pArgs)
     if (!lpJava)
         return FALSE;
     lpJava->dwWorkerStatus = 0;
+    lpJava->hWorkerInit    = CreateEvent(NULL, FALSE, FALSE, NULL);
     lpJava->hWorkerSync    = CreateEvent(NULL, FALSE, FALSE, NULL);
     lpJava->hWorkerThread  = CreateThread(NULL,
                                           lpJava->szStackSize,
@@ -940,9 +991,10 @@ apxJavaStart(LPAPXJAVA_THREADARGS pArgs)
     }
     ResumeThread(lpJava->hWorkerThread);
     /* Wait until the worker thread initializes */
-    WaitForSingleObject(lpJava->hWorkerSync, INFINITE);
+    WaitForSingleObject(lpJava->hWorkerInit, INFINITE);
     if (lpJava->dwWorkerStatus == 0)
         return FALSE;
+    SetEvent(lpJava->hWorkerSync);
     if (lstrcmpA(lpJava->clWorker.sClazz, "java/lang/System")) {
         /* Give some time to initialize the thread
          * Unless we are calling System.exit(0).
@@ -1215,3 +1267,30 @@ apxJavaSetOut(APXHANDLE hJava, BOOL setErrorOrOut, LPCWSTR szFilename)
 
 }
 
+DWORD apxGetVmExitCode(void) {
+    return vmExitCode;
+}
+
+void apxSetVmExitCode(DWORD exitCode) {
+    vmExitCode = exitCode;
+    return;
+}
+
+void
+apxJavaDumpAllStacks(APXHANDLE hJava)
+{
+    BOOL bAttached;
+    LPAPXJAVAVM lpJava;
+    JNIEnv *lpEnv = NULL;
+
+    if (DYNLOAD_FPTR(JVM_DumpAllStacks) == NULL ||
+        hJava == NULL ||
+        hJava->dwType != APXHANDLE_TYPE_JVM)
+        return;
+    lpJava = APXHANDLE_DATA(hJava);
+    if (__apxJvmAttachEnv(lpJava, &lpEnv, &bAttached)) {
+        DYNLOAD_FPTR(JVM_DumpAllStacks)(lpEnv, NULL);
+        if (bAttached)
+            (*(lpJava->lpJvm))->DetachCurrentThread(lpJava->lpJvm);
+    }
+}
diff --git a/src/native/windows/src/log.c b/src/native/windows/src/log.c
index 8b8e8e8..2d697a2 100644
--- a/src/native/windows/src/log.c
+++ b/src/native/windows/src/log.c
@@ -41,9 +41,10 @@ typedef struct apx_logfile_st {
 } apx_logfile_st;
 
 /* Per-application master log file */
-static apx_logfile_st *_st_sys_loghandle = NULL;
-
-static apx_logfile_st  _st_sys_errhandle = { NULL, APXLOG_LEVEL_WARN, FALSE};
+static apx_logfile_st   *_st_sys_loghandle = NULL;
+static CRITICAL_SECTION  _st_sys_loglock;
+static CRITICAL_SECTION *_pt_sys_loglock = NULL;
+static apx_logfile_st    _st_sys_errhandle = { NULL, APXLOG_LEVEL_WARN, FALSE};
 
 static void logRotate(apx_logfile_st *lf, LPSYSTEMTIME t)
 {
@@ -88,6 +89,10 @@ static void logRotate(apx_logfile_st *lf, LPSYSTEMTIME t)
         /* TODO: Log something */
         return;
     }
+    /* Make sure we relock the correct file */
+    APX_LOGLOCK(h);
+    APX_LOGUNLOCK(lf->hFile);
+    /* Close original handle */
     CloseHandle(lf->hFile);
     lf->hFile = h;
 }
@@ -171,6 +176,10 @@ HANDLE apxLogOpen(
     SYSTEMTIME sysTime;
     apx_logfile_st *h;
 
+    if (_pt_sys_loglock == NULL) {
+        InitializeCriticalSection(&_st_sys_loglock);
+        _pt_sys_loglock = &_st_sys_loglock;
+    }
     GetLocalTime(&sysTime);
     if (!szPath) {
         if (GetSystemDirectoryW(sPath, MAX_PATH) == 0)
@@ -300,10 +309,14 @@ apxLogWrite(
     if (IS_INVALID_HANDLE(lf)) {
         lf = &_st_sys_errhandle;
         lf->hFile = GetStdHandle(STD_ERROR_HANDLE);
+    }
+    if (lf == &_st_sys_errhandle) {
+        /* Do not rotate if redirected to console */
         dolock = FALSE;
     }
     if (dwLevel < lf->dwLogLevel)
         return 0;
+    APX_LOGENTER();
     if (f && (lf->dwLogLevel == APXLOG_LEVEL_DEBUG || dwLevel == APXLOG_LEVEL_ERROR)) {
         f = (szFile + lstrlenA(szFile) - 1);
         while(f != szFile && '\\' != *f && '/' != *f)
@@ -346,6 +359,8 @@ apxLogWrite(
             buffer[--len] = '\0';
         if (!IS_INVALID_HANDLE(lf->hFile)) {
             SYSTEMTIME t;
+            /* Append operation */
+            SetFilePointer(lf->hFile, 0, &wr, FILE_END);
             GetLocalTime(&t);
             if (dolock) {
                 APX_LOGLOCK(lf->hFile);
@@ -363,14 +378,18 @@ apxLogWrite(
                 wsprintfA(sb, "(%10s:%-4d) ", f, dwLine);
                 WriteFile(lf->hFile, sb, lstrlenA(sb), &wr, NULL);
             }
+
+            /* add thread ID to log output */
+            wsprintfA(sb, "[%5d] ", GetCurrentThreadId());
+            WriteFile(lf->hFile, sb, lstrlenA(sb), &wr, NULL);
+
             if (len)
                 WriteFile(lf->hFile, buffer, len, &wr, NULL);
 
             /* Terminate the line */
             WriteFile(lf->hFile, LINE_SEP, sizeof(LINE_SEP) - 1, &wr, NULL);
-#ifdef _DEBUG_FULL
-            FlushFileBuffers(lf->hFile);
-#endif
+            if (dwLevel)
+                FlushFileBuffers(lf->hFile);
             if (dolock) {
                 APX_LOGUNLOCK(lf->hFile);
             }
@@ -383,6 +402,7 @@ apxLogWrite(
         }
 #endif
     }
+    APX_LOGLEAVE();
     /* Restore the last Error code */
     SetLastError(err);
     if (szFormat && err != 0 && dwLevel == APXLOG_LEVEL_ERROR) {
diff --git a/src/native/windows/src/rprocess.c b/src/native/windows/src/rprocess.c
index 45d2047..15f8b33 100644
--- a/src/native/windows/src/rprocess.c
+++ b/src/native/windows/src/rprocess.c
@@ -116,6 +116,12 @@ static DWORD WINAPI __apxProcWorkerThread(LPVOID lpParameter)
     if (WaitForSingleObject(lpProc->stProcInfo.hProcess,
                             INFINITE) == WAIT_OBJECT_0) {
         lpProc->dwChildStatus |= CHILD_MAINTREAD_FINISHED;
+
+        /* store worker's exit code as VM exit code for later use */
+        GetExitCodeProcess(lpProc->stProcInfo.hProcess, &dwExitCode);
+        apxLogWrite(APXLOG_MARK_DEBUG "Child process exit code %d", dwExitCode);
+        apxSetVmExitCode(dwExitCode);
+
 #if 0
         if (hProcess->fnCallback)
             (*hProcess->fnCallback)(hProcess, WM_QUIT, (WPARAM)dwExitCode, 0);
diff --git a/src/samples/ProcrunServiceRemove.cmd b/src/samples/ProcrunServiceRemove.cmd
index dfc1b74..5fd04fd 100644
--- a/src/samples/ProcrunServiceRemove.cmd
+++ b/src/samples/ProcrunServiceRemove.cmd
@@ -1,42 +1,42 @@
- at echo off
-rem 
-rem Licensed to the Apache Software Foundation (ASF) under one or more
-rem contributor license agreements.  See the NOTICE file distributed with
-rem this work for additional information regarding copyright ownership.
-rem The ASF licenses this file to You under the Apache License, Version 2.0
-rem (the "License"); you may not use this file except in compliance with
-rem the License.  You may obtain a copy of the License at
-rem
-rem     http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-
-rem Batch script for removing the ProcrunService (JVM and Java versions)
-
-setlocal
-
-rem The service names (make sure they does not clash with an existing service)
-set SERVICE_JVM=ProcrunServiceJvm
-set SERVICE_JAVA=ProcrunServiceJava
-
-rem my location
-set MYPATH=%~dp0
-
-rem location of Prunsrv
-set PATH_PRUNSRV=%MYPATH%
-set PR_LOGPATH=%PATH_PRUNSRV%
-rem Allow prunsrv to be overridden
-if "%PRUNSRV%" == "" set PRUNSRV=%PATH_PRUNSRV%prunsrv
-
-echo Removing %SERVICE_JVM%
-%PRUNSRV% //DS//%SERVICE_JVM%
-
-echo Removing %SERVICE_JAVA%
-%PRUNSRV% //DS//%SERVICE_JAVA%
-%PRUNSRV% //IS//%SERVICE_JAVA%
-
-echo Finished
+ at echo off
+rem 
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+rem Batch script for removing the ProcrunService (JVM and Java versions)
+
+setlocal
+
+rem The service names (make sure they does not clash with an existing service)
+set SERVICE_JVM=ProcrunServiceJvm
+set SERVICE_JAVA=ProcrunServiceJava
+
+rem my location
+set MYPATH=%~dp0
+
+rem location of Prunsrv
+set PATH_PRUNSRV=%MYPATH%
+set PR_LOGPATH=%PATH_PRUNSRV%
+rem Allow prunsrv to be overridden
+if "%PRUNSRV%" == "" set PRUNSRV=%PATH_PRUNSRV%prunsrv
+
+echo Removing %SERVICE_JVM%
+%PRUNSRV% //DS//%SERVICE_JVM%
+
+echo Removing %SERVICE_JAVA%
+%PRUNSRV% //DS//%SERVICE_JAVA%
+%PRUNSRV% //IS//%SERVICE_JAVA%
+
+echo Finished
diff --git a/src/site/xdoc/binaries.xml b/src/site/xdoc/binaries.xml
index 83854bd..8cef8b3 100644
--- a/src/site/xdoc/binaries.xml
+++ b/src/site/xdoc/binaries.xml
@@ -29,35 +29,14 @@
 In the directory
 <a href="http://www.apache.org/dist/commons/daemon/binaries/">binaries</a>
 you will find subdirectories containing archives
-corresponding to your operating system. If your machine is not in the list,
-please mail us and we will try to make it available, or you can try to build it on your own.
-The non-Windows files are compressed tar files. They are named <code>commons-daemon-m.n.p-bin-os-hw.tar.gz</code>.
-For example: In the directory <code>linux</code> we have <code>commons-daemon-1.0.10-bin-linux-i686.tar.gz</code>
-That is a file suitable for a Linux system running on Intel hardware.
-Windows builds are provided as a zip file.
+corresponding to your operating system. Only the Windows builds are provided as a zip file.
 </p>
 </section>
 
 <section name="How do I get the executable?">
-<subsection name="jsvc">
-<p>
-Do the following:
-<ul>
-  <li>Find the tar.gz file corresponding to your configuration.</li>
-  <li>Download it.</li>
-  <li>Uncompress the tar file and extract the contents (better with gnu tar).
-  There should be an executable file called <code>jsvc</code> and some text files</li>
-  <li>Copy the executable to the location where you want to run it.</li>
-  <li>Write a suitable shell script
-     (see in <code>src/samples</code> and <code>src/native/unix/native/Tomcat.sh</code>)
-     to get your Java application started as a daemon.
-  </li>
-</ul>
-</p>
-</subsection>
 <subsection name="procrun">
 <p>
-The Windows archive (e.g. commons-daemon-1.0.10-bin-windows.zip) contains 2 different executables:
+The Windows archive (e.g. commons-daemon-1.0.15-bin-windows.zip) contains 2 different executables:
 <ul>
 <li>prunsrv.exe - service application for running applications as services.</li>
 <li>prunmgr.exe - the GUI manager application used to monitor and configure installed services.</li>
diff --git a/src/site/xdoc/download_daemon.xml b/src/site/xdoc/download_daemon.xml
index b3f9cec..40a927c 100644
--- a/src/site/xdoc/download_daemon.xml
+++ b/src/site/xdoc/download_daemon.xml
@@ -54,7 +54,7 @@ limitations under the License.
       <p>
         We recommend you use a mirror to download our release
         builds, but you <strong>must</strong> verify the integrity of
-        the downloaded files using signatures downloaded from our main
+        the downloaded files using signatures downloaded from our main 
         distribution directories. Recent releases (48 hours) may not yet
         be available from the mirrors.
       </p>
@@ -71,7 +71,7 @@ limitations under the License.
 
       <form action="[location]" method="get" id="SelectMirror">
         <p>
-          Other mirrors:
+          Other mirrors: 
           <select name="Preferred">
           [if-any http]
             [for http]<option value="[http]">[http]</option>[end]
@@ -90,52 +90,37 @@ limitations under the License.
       <p>
         The <a href="http://www.apache.org/dist/commons/KEYS">KEYS</a>
         link links to the code signing keys used to sign the product.
-        The <code>PGP</code> link downloads the OpenPGP compatible signature from our main site.
+        The <code>PGP</code> link downloads the OpenPGP compatible signature from our main site. 
         The <code>MD5</code> link downloads the checksum from the main site.
       </p>
     </subsection>
     </section>
-    <section name="Commons Daemon 1.0.10">
+    <section name="Commons Daemon 1.0.15 ">
       <subsection name="Binaries">
         <table>
           <tr>
-              <td><a href="[preferred]/commons/daemon/binaries/commons-daemon-1.0.10-bin.tar.gz">commons-daemon-1.0.10-bin.tar.gz</a></td>
-              <td><a href="http://www.apache.org/dist/commons/daemon/binaries/commons-daemon-1.0.10-bin.tar.gz.md5">md5</a></td>
-              <td><a href="http://www.apache.org/dist/commons/daemon/binaries/commons-daemon-1.0.10-bin.tar.gz.asc">pgp</a></td>
+              <td><a href="[preferred]/commons/daemon/binaries/commons-daemon-1.0.15-bin.tar.gz">commons-daemon-1.0.15-bin.tar.gz</a></td>
+              <td><a href="http://www.apache.org/dist/commons/daemon/binaries/commons-daemon-1.0.15-bin.tar.gz.md5">md5</a></td>
+              <td><a href="http://www.apache.org/dist/commons/daemon/binaries/commons-daemon-1.0.15-bin.tar.gz.asc">pgp</a></td>
           </tr>
           <tr>
-              <td><a href="[preferred]/commons/daemon/binaries/commons-daemon-1.0.10-bin.zip">commons-daemon-1.0.10-bin.zip</a></td>
-              <td><a href="http://www.apache.org/dist/commons/daemon/binaries/commons-daemon-1.0.10-bin.zip.md5">md5</a></td>
-              <td><a href="http://www.apache.org/dist/commons/daemon/binaries/commons-daemon-1.0.10-bin.zip.asc">pgp</a></td>
-          </tr>
-          <tr>
-              <td><a href="[preferred]/commons/daemon/binaries/">Browse native binaries download area...</a></td>
-              <td></td>
-              <td></td>
+              <td><a href="[preferred]/commons/daemon/binaries/commons-daemon-1.0.15-bin.zip">commons-daemon-1.0.15-bin.zip</a></td>
+              <td><a href="http://www.apache.org/dist/commons/daemon/binaries/commons-daemon-1.0.15-bin.zip.md5">md5</a></td>
+              <td><a href="http://www.apache.org/dist/commons/daemon/binaries/commons-daemon-1.0.15-bin.zip.asc">pgp</a></td>
           </tr>
         </table>
       </subsection>
       <subsection name="Source">
         <table>
           <tr>
-              <td><a href="[preferred]/commons/daemon/source/commons-daemon-1.0.10-src.tar.gz">commons-daemon-1.0.10-src.tar.gz</a></td>
-              <td><a href="http://www.apache.org/dist/commons/daemon/source/commons-daemon-1.0.10-src.tar.gz.md5">md5</a></td>
-              <td><a href="http://www.apache.org/dist/commons/daemon/source/commons-daemon-1.0.10-src.tar.gz.asc">pgp</a></td>
-          </tr>
-          <tr>
-              <td><a href="[preferred]/commons/daemon/source/commons-daemon-1.0.10-src.zip">commons-daemon-1.0.10-src.zip</a></td>
-              <td><a href="http://www.apache.org/dist/commons/daemon/source/commons-daemon-1.0.10-src.zip.md5">md5</a></td>
-              <td><a href="http://www.apache.org/dist/commons/daemon/source/commons-daemon-1.0.10-src.zip.asc">pgp</a></td>
+              <td><a href="[preferred]/commons/daemon/source/commons-daemon-1.0.15-src.tar.gz">commons-daemon-1.0.15-src.tar.gz</a></td>
+              <td><a href="http://www.apache.org/dist/commons/daemon/source/commons-daemon-1.0.15-src.tar.gz.md5">md5</a></td>
+              <td><a href="http://www.apache.org/dist/commons/daemon/source/commons-daemon-1.0.15-src.tar.gz.asc">pgp</a></td>
           </tr>
           <tr>
-              <td><a href="[preferred]/commons/daemon/source/commons-daemon-1.0.10-native-src.tar.gz">commons-daemon-1.0.10-native-src.tar.gz</a></td>
-              <td><a href="http://www.apache.org/dist/commons/daemon/source/commons-daemon-1.0.10-native-src.tar.gz.md5">md5</a></td>
-              <td><a href="http://www.apache.org/dist/commons/daemon/source/commons-daemon-1.0.10-native-src.tar.gz.asc">pgp</a></td>
-          </tr>
-          <tr>
-              <td><a href="[preferred]/commons/daemon/source/commons-daemon-1.0.10-native-src.zip">commons-daemon-1.0.10-native-src.zip</a></td>
-              <td><a href="http://www.apache.org/dist/commons/daemon/source/commons-daemon-1.0.10-native-src.zip.md5">md5</a></td>
-              <td><a href="http://www.apache.org/dist/commons/daemon/source/commons-daemon-1.0.10-native-src.zip.asc">pgp</a></td>
+              <td><a href="[preferred]/commons/daemon/source/commons-daemon-1.0.15-src.zip">commons-daemon-1.0.15-src.zip</a></td>
+              <td><a href="http://www.apache.org/dist/commons/daemon/source/commons-daemon-1.0.15-src.zip.md5">md5</a></td>
+              <td><a href="http://www.apache.org/dist/commons/daemon/source/commons-daemon-1.0.15-src.zip.asc">pgp</a></td>
           </tr>
         </table>
       </subsection>
@@ -145,10 +130,9 @@ limitations under the License.
           Older releases can be obtained from the archives.
         </p>
         <ul>
-          <li class="download"><a href="[preferred]/commons/daemon/">Browse download area...</a></li>
-          <li><a href="http://archive.apache.org/dist/commons/daemon/">Archives...</a></li>
+          <li class="download"><a href="[preferred]/commons/daemon/">browse download area</a></li>
+          <li><a href="http://archive.apache.org/dist/commons/daemon/">archives...</a></li>
         </ul>
     </section>
   </body>
 </document>
-
diff --git a/src/site/xdoc/jsvc.xml b/src/site/xdoc/jsvc.xml
index 14c2841..8f16f8a 100644
--- a/src/site/xdoc/jsvc.xml
+++ b/src/site/xdoc/jsvc.xml
@@ -145,6 +145,8 @@ Where options include:
         user used to run the daemon (defaults to current user)
     -verbose[:class|gc|jni]
         enable verbose output
+    -cwd </full/path>
+        set working directory to given location (defaults to /)
     -outfile </full/path/to/file>
         Location for output from stdout (defaults to /dev/null)
         Use the value '&2' to simulate '1>&2'

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/commons-daemon.git



More information about the pkg-java-commits mailing list