$NetBSD: patch-configure,v 1.22 2017/03/27 12:54:59 jperkin Exp $

All kinds of OS-specific changes to configure
--- configure.orig	2016-11-04 16:08:24.000000000 +0000
+++ configure
@@ -726,7 +726,10 @@ if test $with_sharedlibs = "yes"; then
         *gcc*)
           sharedcccompopts="-fPIC"
           if sh ./solaris-ld; then
-            mksharedlib="ld -G"
+            case "$target" in
+            x86_64*) mksharedlib="$bytecc -shared" ;;
+            *)       mksharedlib="$bytecc -G" ;;
+            esac
             byteccrpath="-R"
             mksharedlibrpath="-R"
           else
@@ -753,7 +756,7 @@ if test $with_sharedlibs = "yes"; then
       byteccrpath="-Wl,-rpath,"
       mksharedlibrpath="-rpath "
       shared_libraries_supported=true;;
-    i[3456]86-*-darwin[89].*)
+    i[3456]86-*-darwin*)
       mksharedlib="$bytecc -bundle -flat_namespace -undefined suppress \
                    -read_only_relocs suppress"
       bytecccompopts="$dl_defs $bytecccompopts"
@@ -795,11 +798,7 @@ if test $with_sharedlibs = "yes"; then
     i[3456]86-*-linux*)           natdynlink=true;;
     i[3456]86-*-gnu*)             natdynlink=true;;
     x86_64-*-linux*)              natdynlink=true;;
-    i[3456]86-*-darwin[89].*)     natdynlink=true;;
-    i[3456]86-*-darwin*)
-      if test $arch64 == true; then
-        natdynlink=true
-      fi;;
+    i[3456]86-*-darwin*)          natdynlink=true;;
     x86_64-*-darwin*)             natdynlink=true;;
     s390x*-*-linux*)              natdynlink=true;;
     powerpc*-*-linux*)            natdynlink=true;;
@@ -813,6 +812,9 @@ if test $with_sharedlibs = "yes"; then
     x86_64-*-openbsd*)            natdynlink=true;;
     i[3456]86-*-netbsd*)          natdynlink=true;;
     x86_64-*-netbsd*)             natdynlink=true;;
+    i[3456]86-*-dragonfly*)       natdynlink=true;;
+    x86_64-*-dragonfly*)          natdynlink=true;;
+    *-*-solaris*)                 natdynlink=true;;
     i386-*-gnu0.3)                natdynlink=true;;
     i[3456]86-*-haiku*)           natdynlink=true;;
     arm*-*-linux*)                natdynlink=true;;
@@ -842,6 +844,7 @@ case "$target" 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
@@ -851,6 +854,7 @@ case "$target" in
   i[3456]86-*-haiku*)           arch=i386; system=beos;;
   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
@@ -888,6 +892,7 @@ case "$target" in
   x86_64-*-mingw*)              arch=amd64; system=mingw;;
   aarch64-*-linux*)             arch=arm64; system=linux;;
   x86_64-*-cygwin*)             arch=amd64; system=cygwin;;
+  x86_64-*-solaris*)            arch=amd64; system=solaris;;
 esac
 
 # Some platforms exist both in 32-bit and 64-bit variants, not distinguished
@@ -923,7 +928,6 @@ case "$arch,$nativecc,$system,$model" in
   *,*,nextstep,*)      nativecclinkopts="-posix";;
   *,*,rhapsody,*)      if $arch64; then partialld="ld -r -arch ppc64"; fi;;
   amd64,gcc*,macosx,*) partialld="ld -r -arch x86_64";;
-  amd64,gcc*,solaris,*) partialld="ld -r -m elf_x86_64";;
   power,gcc*,elf,ppc)   partialld="ld -r -m elf32ppclinux";;
   power,gcc*,elf,ppc64)   partialld="ld -r -m elf64ppc";;
   power,gcc*,elf,ppc64le)   partialld="ld -r -m elf64lppc";;
@@ -941,8 +945,8 @@ case "$arch,$system" in
                     fi;;
   amd64,solaris)  as="${TOOLPREF}as --64"
                   aspp="${TOOLPREF}gcc -m64 -c";;
-  i386,solaris)   as="${TOOLPREF}as"
-                  aspp="${TOOLPREF}gcc -c";;
+  i386,solaris)   as="${TOOLPREF}as --32"
+                  aspp="${TOOLPREF}gcc -m32 -c";;
   power,elf)      if $arch64; then
                     as="${TOOLPREF}as -a64 -mppc64"
                     aspp="${TOOLPREF}gcc -m64 -c"
@@ -991,6 +995,8 @@ case "$arch,$system" in
   arm,linux*) profiling='prof';;
   power,elf) profiling='prof';;
   power,bsd*) profiling='prof';;
+  *,*,dragonfly) profiling='prof';;
+  amd64,solaris) profiling='prof';;
   *) profiling='noprof';;
 esac
 
@@ -1554,6 +1560,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`
@@ -1600,6 +1608,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       \
@@ -1657,6 +1666,7 @@ if test "$x11_include" = "not found"; th
                           \
     /usr/lib64            \
     /usr/lib              \
+    /usr/pkg/lib          \
     /usr/local/lib        \
     /usr/unsupported/lib  \
     /usr/athena/lib       \
@@ -1678,19 +1688,16 @@ if test "$x11_include" = "not found"; th
       if test $dir = /usr/lib; then
         x11_link="-lX11"
       else
-        x11_libs="-L$dir"
-        case "$target" in
-          *-*-freebsd*|*-*-dragonfly*) x11_link="-L$dir -lX11";;
-          *-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=""
