$NetBSD: patch-ab,v 1.3 2011/12/31 23:56:47 dholland Exp $

Caution: the extra cpp checking (the three hunks containing "Should be
one line") is manually hacked and not reflected in configure.in; do
not regenerate configure with autoconf without merging it. This
checking is required because somewhere between gcc 4.1 and 4.5 cpp
started doing regrettable things with backslash-escaped newlines.

--- configure.orig	2003-03-18 14:19:12.000000000 +0000
+++ configure
@@ -822,9 +822,17 @@ case "${canonical}" in
       sparc*-*-netbsd*)	machine=sparc ;;
       vax-*-netbsd*)	machine=vax ;;
       arm-*-netbsd*)	machine=arm ;;
+      x86_64-*-netbsd*)	machine=amd64 ;;
+      hppa-*-netbsd*)	machine=hp800 ;;
+      shle-*-netbsd*)	machine=sh3el ;;
     esac
   ;;
 
+  ## Darwin / Mac OS X
+  powerpc-apple-darwin* )
+    machine=powermac opsys=darwin ;;
+  i386-apple-darwin* )
+    machine=intel386 opsys=darwin ;;
   ## OpenBSD ports
   *-*-openbsd* )
     opsys=openbsd
@@ -909,6 +917,10 @@ case "${canonical}" in
     machine=macppc opsys=gnu-linux
   ;;
 
+  x86_64-*-linux* )
+    machine=amd64 opsys=gnu-linux
+  ;;
+
   ## Altos 3068
   m68*-altos-sysv* )
     machine=altos opsys=usg5-2
@@ -1659,6 +1671,7 @@ case "${canonical}" in
       *-sysv4.2uw* )	  	opsys=unixware; NON_GNU_CPP=/lib/cpp ;;
       *-386bsd* )	        opsys=386bsd ;;
       *-freebsd* )	        opsys=freebsd ;;
+      *-dragonfly* )	        opsys=dragonfly ;;
       *-nextstep* )             opsys=nextstep ;;
       ## Otherwise, we'll fall through to the generic opsys code at the bottom.
     esac
@@ -2052,15 +2065,21 @@ else
   CPP="${CC-cc} -E"
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
+  # And, gcc 4.5? and up does not preserve escaped newlines, which is
+  # fatal for preprocessing makefiles.
   cat > conftest.$ac_ext <<EOF
 #line 2057 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
+Should \\
+be one line.
 EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+ac_try="$ac_cpp conftest.$ac_ext >conftest2.out 2>conftest.out"
 { (eval echo configure:2063: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"; \
+    grep -L "Should  *be one line" conftest2.out \
+    `
 if test -z "$ac_err"; then
   :
 else
@@ -2074,10 +2093,14 @@ else
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
+Should \\
+be one line.
 EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+ac_try="$ac_cpp conftest.$ac_ext >conftest2.out 2>conftest.out"
 { (eval echo configure:2080: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"; \
+    grep -L "Should  *be one line" conftest2.out \
+    `
 if test -z "$ac_err"; then
   :
 else
@@ -2091,10 +2114,14 @@ else
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
+Should \\
+be one line.
 EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+ac_try="$ac_cpp conftest.$ac_ext >conftest2.out 2>conftest.out"
 { (eval echo configure:2097: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"; \
+    grep -L "Should  *be one line" conftest2.out \
+    `
 if test -z "$ac_err"; then
   :
 else
@@ -9124,6 +9151,22 @@ EOF
 fi
 
 
+# NETBSD: NetBSD's newer run-time linker fix.
+if test $opsys = netbsd; then
+  if test -f /usr/lib/crti.o; then
+    cat >> confdefs.h <<\EOF
+#define HAVE_NETBSD_CRTI 1
+EOF
+
+  fi
+  if test -f /usr/lib/crtn.o; then
+    cat >> confdefs.h <<\EOF
+#define HAVE_NETBSD_CRTN 1
+EOF
+
+  fi
+fi
+
 # Set up the CFLAGS for real compilation, so we can substitute it.
 CFLAGS="$REAL_CFLAGS"
 CPPFLAGS="$REAL_CPPFLAGS"
