--- configure.orig	2014-11-12 12:59:57.000000000 +0100
+++ configure	2016-09-20 13:20:41.017496000 +0200
@@ -680,6 +680,8 @@
 ARC_TRUE
 AARCH64_FALSE
 AARCH64_TRUE
+POWERPC_BSDSUNIX_FALSE
+POWERPC_BSDSUNIX_TRUE
 POWERPC_FREEBSD_FALSE
 POWERPC_FREEBSD_TRUE
 POWERPC_DARWIN_FALSE
@@ -718,6 +720,8 @@
 X86_WIN64_TRUE
 X86_WIN32_FALSE
 X86_WIN32_TRUE
+X86_BSDSUNIX_FALSE
+X86_BSDSUNIX_TRUE
 X86_FREEBSD_FALSE
 X86_FREEBSD_TRUE
 X86_FALSE
@@ -5901,7 +5905,7 @@
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  netbsd* | bsdsunix* | freebsd* | openbsd* | darwin* | dragonfly*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -6336,13 +6340,13 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-freebsd* | dragonfly*)
+bsdsunix* | freebsd* | dragonfly*)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
     case $host_cpu in
     i*86 )
       # Not sure whether the presence of OpenBSD here was a mistake.
       # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_deplibs_check_method='file_magic (BSDSUniX|FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
       lt_cv_file_magic_cmd=/usr/bin/file
       lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
       ;;
@@ -10490,7 +10494,7 @@
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | dragonfly*)
+    bsdsunix* | freebsd* | dragonfly*)
       archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec='-R$libdir'
       hardcode_direct=yes
@@ -11454,6 +11458,25 @@
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
+bsdsunix*)
+  objformat=elf
+  version_type=bsdsunix-$objformat
+  case $version_type in
+    bsdsunix-elf*)
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    bsdsunix-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
@@ -13430,11 +13453,11 @@
         ld_shlibs_CXX=no
         ;;
 
-      freebsd-elf*)
+      bsdsunix-elf*|freebsd-elf*)
         archive_cmds_need_lc_CXX=no
         ;;
 
-      freebsd* | dragonfly*)
+      bsdsunix* | freebsd* | dragonfly*)
         # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
         # conventions
         ld_shlibs_CXX=yes
@@ -14421,7 +14444,7 @@
 	    ;;
 	esac
 	;;
-      freebsd* | dragonfly*)
+      bsdsunix* | freebsd* | dragonfly*)
 	# FreeBSD uses GNU C++
 	;;
       hpux9* | hpux10* | hpux11*)
@@ -15289,6 +15312,25 @@
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
+bsdsunix*)
+  objformat=elf
+  version_type=bsdsunix-$objformat
+  case $version_type in
+    bsdsunix-elf*)
+      library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    bsdsunix-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
 freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
@@ -17096,6 +17138,10 @@
 	TARGET=X86_64; TARGETDIR=x86
   	;;
 
+  amd64-*-bsdsunix*)
+	TARGET=X86_64; TARGETDIR=x86
+  	;;
+
   amd64-*-freebsd*)
 	TARGET=X86_64; TARGETDIR=x86
   	;;
@@ -17130,6 +17176,10 @@
 	TARGET=PA_HPUX; TARGETDIR=pa
 	;;
 
+  i?86-*-bsdsunix*)
+	TARGET=X86_BSDSUNIX; TARGETDIR=x86
+	;;
+
   i?86-*-freebsd* | i?86-*-openbsd*)
 	TARGET=X86_FREEBSD; TARGETDIR=x86
 	;;
@@ -17221,7 +17271,7 @@
   mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
 	TARGET=MIPS; TARGETDIR=mips
 	;;
-  mips*-*linux* | mips*-*-openbsd*)
+  mips*-*-bsdsunix* | mips*-*linux* | mips*-*-openbsd* | mips*-*-freebsd*)
 	# Support 128-bit long double for NewABI.
 	HAVE_LONG_DOUBLE='defined(__mips64)'
 	TARGET=MIPS; TARGETDIR=mips
@@ -17251,6 +17301,13 @@
   powerpc-*-aix* | rs6000-*-aix*)
 	TARGET=POWERPC_AIX; TARGETDIR=powerpc
 	;;
+  powerpc-*-bsdsunix*)
+	TARGET=POWERPC_BSDSUNIX; TARGETDIR=powerpc
+	HAVE_LONG_DOUBLE_VARIANT=1
+	;;
+  powerpc64-*-bsdsunix*)
+	TARGET=POWERPC; TARGETDIR=powerpc
+	;;
   powerpc-*-freebsd* | powerpc-*-openbsd*)
 	TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
 	HAVE_LONG_DOUBLE_VARIANT=1
@@ -17330,6 +17387,14 @@
   X86_FALSE=
 fi
 
+ if test x$TARGET = xX86_BSDSUNIX; then
+  X86_BSDSUNIX_TRUE=
+  X86_BSDSUNIX_FALSE='#'
+else
+  X86_BSDSUNIX_TRUE='#'
+  X86_BSDSUNIX_FALSE=
+fi
+
  if test x$TARGET = xX86_FREEBSD; then
   X86_FREEBSD_TRUE=
   X86_FREEBSD_FALSE='#'
@@ -17482,6 +17547,14 @@
   POWERPC_DARWIN_FALSE=
 fi
 
+ if test x$TARGET = xPOWERPC_BSDSUNIX; then
+  POWERPC_BSDSUNIX_TRUE=
+  POWERPC_BSDSUNIX_FALSE='#'
+else
+  POWERPC_BSDSUNIX_TRUE='#'
+  POWERPC_BSDSUNIX_FALSE=
+fi
+
  if test x$TARGET = xPOWERPC_FREEBSD; then
   POWERPC_FREEBSD_TRUE=
   POWERPC_FREEBSD_FALSE='#'
@@ -18530,7 +18603,7 @@
 $as_echo "#define FFI_EXEC_TRAMPOLINE_TABLE 1" >>confdefs.h
 
      ;;
-     *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
+     *-apple-darwin1* | *-*-bsdsunix* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
 
 $as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h
 
@@ -18912,6 +18985,10 @@
   as_fn_error $? "conditional \"X86\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${X86_BSDSUNIX_TRUE}" && test -z "${X86_BSDSUNIX_FALSE}"; then
+  as_fn_error $? "conditional \"X86_BSDSUNIX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${X86_FREEBSD_TRUE}" && test -z "${X86_FREEBSD_FALSE}"; then
   as_fn_error $? "conditional \"X86_FREEBSD\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -18988,6 +19065,10 @@
   as_fn_error $? "conditional \"POWERPC_DARWIN\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${POWERPC_BSDSUNIX_TRUE}" && test -z "${POWERPC_BSDSUNIX_FALSE}"; then
+  as_fn_error $? "conditional \"POWERPC_BSDSUNIX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${POWERPC_FREEBSD_TRUE}" && test -z "${POWERPC_FREEBSD_FALSE}"; then
   as_fn_error $? "conditional \"POWERPC_FREEBSD\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5