$NetBSD: patch-configure,v 1.7 2013/11/04 16:39:32 joerg Exp $

Several configure changes to work on and detect NetBSD (and some other OSes)

--- configure.orig	2013-07-23 14:48:47.000000000 +0000
+++ configure
@@ -271,14 +271,14 @@ iflexdir=""
 case "$bytecc,$host" in
   cc,*-*-nextstep*)
     # GNU C extensions disabled, but __GNUC__ still defined!
-    bytecccompopts="-fno-defer-pop $gcc_warnings -U__GNUC__ -posix"
+    bytecccompopts="$gcc_warnings -U__GNUC__ -posix"
     bytecclinkopts="-posix";;
   *,*-*-rhapsody*)
     # Almost the same as NeXTStep
-    bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC"
+    bytecccompopts="$gcc_warnings -DSHRINKED_GNUC"
     mathlib="";;
   *,*-*-darwin*)
-    bytecccompopts="-fno-defer-pop $gcc_warnings"
+    bytecccompopts="$gcc_warnings"
     mathlib=""
     mkexe="$mkexe -Wl,-no_compact_unwind"
     # Tell gcc that we can use 32-bit code addresses for threaded code
@@ -287,11 +287,11 @@ case "$bytecc,$host" in
     echo "#  define ARCH_CODE32" >> m.h
     echo "#endif" >> m.h;;
   *,*-*-beos*)
-    bytecccompopts="-fno-defer-pop $gcc_warnings"
+    bytecccompopts="$gcc_warnings"
     # No -lm library
     mathlib="";;
   gcc,alpha*-*-osf*)
-    bytecccompopts="-fno-defer-pop $gcc_warnings"
+    bytecccompopts="$gcc_warnings"
     if cc="$bytecc" sh ./hasgot -mieee; then
       bytecccompopts="-mieee $bytecccompopts";
     fi
@@ -319,11 +319,11 @@ case "$bytecc,$host" in
     bytecccompopts="-DUMK";;
   gcc*,powerpc-*-aix*)
     # Avoid name-space pollution by requiring Unix98-conformant includes
-    bytecccompopts="-fno-defer-pop $gcc_warnings -D_XOPEN_SOURCE=500";;
+    bytecccompopts="$gcc_warnings -D_XOPEN_SOURCE=500";;
   *,powerpc-*-aix*)
     bytecccompopts="-D_XOPEN_SOURCE=500";;
   gcc*,*-*-cygwin*)
-    bytecccompopts="-fno-defer-pop $gcc_warnings -U_WIN32"
+    bytecccompopts="$gcc_warnings -U_WIN32"
     dllccompopts="-U_WIN32 -DCAML_DLL"
     if test $withsharedlibs = yes; then
       flexlink="flexlink -chain cygwin -merge-manifest -stack 16777216"
@@ -340,14 +340,14 @@ case "$bytecc,$host" in
     exe=".exe"
     ostype="Cygwin";;
   gcc*,x86_64-*-linux*)
-    bytecccompopts="-fno-defer-pop $gcc_warnings"
+    bytecccompopts="$gcc_warnings"
     # Tell gcc that we can use 32-bit code addresses for threaded code
     # unless we are compiled for a shared library (-fPIC option)
     echo "#ifndef __PIC__" >> m.h
     echo "#  define ARCH_CODE32" >> m.h
     echo "#endif" >> m.h;;
   gcc*)
-    bytecccompopts="-fno-defer-pop $gcc_warnings";;
+    bytecccompopts="$gcc_warnings";;
 esac
 
 # Configure compiler to use in further tests
@@ -542,7 +542,7 @@ if test $withsharedlibs = "yes"; then
       mksharedlib="$flexlink"
       mkmaindll="$flexlink -maindll"
       shared_libraries_supported=true;;
-    *-*-linux-gnu|*-*-linux|*-*-freebsd[3-9]*|*-*-freebsd[1-9][0-9]*|*-*-openbsd*|*-*-netbsd*|*-*-gnu*)
+    *-*-linux-gnu|*-*-linux|*-*-freebsd[3-9]*|*-*-freebsd[1-9][0-9]*|*-*-openbsd*|*-*-netbsd*|*-*-gnu*|*-*-dragonfly)
       sharedcccompopts="-fPIC"
       mksharedlib="$bytecc -shared"
       bytecclinkopts="$bytecclinkopts -Wl,-E"
@@ -638,7 +638,7 @@ if test $withsharedlibs = "yes"; then
     x86_64-*-linux*)              natdynlink=true;;
     i[3456]86-*-darwin[89].*)     natdynlink=true;;
     i[3456]86-*-darwin*)
-      if test $arch64 == true; then
+      if test $arch64 = true; then
         natdynlink=true
       fi;;
     x86_64-*-darwin*)             natdynlink=true;;
@@ -652,6 +652,8 @@ if test $withsharedlibs = "yes"; then
     x86_64-*-openbsd*)            natdynlink=true;;
     i[345]86-*-netbsd*)           natdynlink=true;;
     x86_64-*-netbsd*)             natdynlink=true;;
+    i[345]86-*-dragonfly)         natdynlink=true;;
+    x86_64-*-dragonfly)           natdynlink=true;;
     i386-*-gnu0.3)                natdynlink=true;;
     arm*-*-linux*)                natdynlink=true;;
   esac
@@ -677,6 +679,7 @@ case "$host" in
   sparc*-*-gnu*)                arch=sparc; system=gnu;;
   i[3456]86-*-linux*)           arch=i386; system=linux_`sh ./runtest elf.c`;;
   i[3456]86-*-*bsd*)            arch=i386; system=bsd_`sh ./runtest elf.c`;;
+  i[3456]86-*-dragonfly*)       arch=i386; system=bsd_`sh ./runtest elf.c`;;
   i[3456]86-*-nextstep*)        arch=i386; system=nextstep;;
   i[3456]86-*-solaris*)         if $arch64; then
                                   arch=amd64; system=solaris
@@ -685,6 +688,7 @@ case "$host" in
                                 fi;;
   i[3456]86-*-beos*)            arch=i386; system=beos;;
   i[3456]86-*-cygwin*)          arch=i386; system=cygwin;;
+  i[3456]86-*-interix3*)	arch=i386; system=interix3;;
   i[3456]86-*-darwin*)          if $arch64; then
                                   arch=amd64; system=macosx
                                 else
@@ -697,6 +701,7 @@ case "$host" in
   powerpc-*-rhapsody*)          arch=power; model=ppc; system=rhapsody;;
   powerpc-*-darwin*)            arch=power; system=rhapsody
                                 if $arch64;then model=ppc64;else model=ppc;fi;;
+	arm*-*-netbsd)								arch=arm; system=netbsd;;
   armv6*-*-linux-gnueabihf)     arch=arm; model=armv6; system=linux_eabihf;;
   arm*-*-linux-gnueabihf)       arch=arm; system=linux_eabihf;;
   armv7*-*-linux-gnueabi)       arch=arm; model=armv7; system=linux_eabi;;
@@ -709,6 +714,8 @@ case "$host" in
   x86_64-*-gnu*)                arch=amd64; system=gnu;;
   x86_64-*-freebsd*)            arch=amd64; system=freebsd;;
   x86_64-*-netbsd*)             arch=amd64; system=netbsd;;
+  x86_64-*-dragonfly*)          arch=amd64; system=dragonfly;;
+  x86_64-*-solaris*)            arch=amd64; system=solaris;;
   x86_64-*-openbsd*)            arch=amd64; system=openbsd;;
   x86_64-*-darwin*)             arch=amd64; system=macosx;;
 esac
@@ -745,7 +752,7 @@ case "$arch,$nativecc,$system,$host_type
                        if $arch64; then partialld="ld -r -arch ppc64"; fi;;
   *,gcc*,cygwin,*)     nativecccompopts="$gcc_warnings -U_WIN32";;
   amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";;
-  amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";;
+  amd64,gcc*,solaris,*) partialld="ld -r -64";;
   *,gcc*,*,*)          nativecccompopts="$gcc_warnings";;
 esac
 
@@ -765,8 +772,8 @@ case "$arch,$model,$system" in
                     aspp='gcc -c';;
   arm,*,*)          as='as';
                     aspp='gcc -c';;
-  i386,*,solaris)   as='as'
-                    aspp='/usr/ccs/bin/as -P';;
+  i386,*,solaris)   as='as --32'
+                    aspp='gcc -traditional -c';;
   i386,*,*)         as='as'
                     aspp='gcc -c';;
   power,*,elf)      as='as -u -m ppc'
@@ -800,6 +807,8 @@ case "$arch,$model,$system" in
   amd64,*,linux) profiling='prof';;
   amd64,*,gnu) profiling='prof';;
   arm,*,linux*) profiling='prof';;
+  power,*,bsd) profiling='prof';;
+  *,*,dragonfly) profiling='prof';;
   *) profiling='noprof';;
 esac
 
@@ -1258,6 +1267,8 @@ fi
 x11_include="not found"
 x11_link="not found"
 
+if test "$disable_x11" != "yes"; then
+
 if test -z "$x11_include_dir" -a -z "$x11_lib_dir"; then
   if pkg-config --exists x11 2>/dev/null; then
     x11_include=`pkg-config --cflags x11`
@@ -1304,6 +1315,7 @@ if test "$x11_include" = "not found"; th
     /usr/XFree86/include/X11  \
                               \
     /usr/include              \
+    /usr/pkg/include          \
     /usr/local/include        \
     /usr/unsupported/include  \
     /usr/athena/include       \
@@ -1361,6 +1373,7 @@ if test "$x11_include" = "not found"; th
                           \
     /usr/lib64            \
     /usr/lib              \
+    /usr/pkg/lib          \
     /usr/local/lib        \
     /usr/unsupported/lib  \
     /usr/athena/lib       \
@@ -1382,18 +1395,16 @@ if test "$x11_include" = "not found"; th
       if test $dir = /usr/lib; then
         x11_link="-lX11"
       else
-        x11_libs="-L$dir"
-        case "$host" in
-          *-kfreebsd*-gnu) x11_link="-L$dir -lX11";;
-          *-*-*bsd*) x11_link="-R$dir -L$dir -lX11";;
-          *) x11_link="-L$dir -lX11";;
-        esac
+        x11_libs="-L$dir ${COMPILER_RPATH_FLAG}$dir"
+        x11_link="-L$dir ${COMPILER_RPATH_FLAG}$dir -lX11"
       fi
       break
     fi
   done
 fi
 
+fi # end of disable_x11 test
+
 if test "x11_include" != "not found"; then
   if test "$x11_include" = "-I/usr/include"; then
     x11_include=""
