--- ./ltconfig.orig	2000-08-03 04:21:13.000000000 +0300
+++ ./ltconfig	2016-12-04 20:43:42.946480000 +0200
@@ -1189,7 +1189,7 @@
   netbsd*)
     if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
       archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
-      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      archive_expsym_cmds='echo "{ global:" > $lib-ver~		 sed -e "s|$|;|" < $export_symbols >> $lib-ver~	 echo "local: *; };" >> $lib-ver~$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-version-script $wl$lib-ver -o $lib'
     else
       archive_cmds='$LD -Bshareable $libobjs $deplibs $linkopts -o $lib'
       # can we support soname and/or expsyms with a.out? -oliva
@@ -1211,7 +1211,7 @@
 EOF
     elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
       archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
-      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      archive_expsym_cmds='echo "{ global:" > $lib-ver~		 sed -e "s|$|;|" < $export_symbols >> $lib-ver~	 echo "local: *; };" >> $lib-ver~$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-version-script $wl$lib-ver -o $lib'
     else
       ld_shlibs=no
     fi
@@ -1227,7 +1227,7 @@
   *)
     if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
       archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
-      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      archive_expsym_cmds='echo "{ global:" > $lib-ver~		 sed -e "s|$|;|" < $export_symbols >> $lib-ver~	 echo "local: *; };" >> $lib-ver~$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-version-script $wl$lib-ver -o $lib'
     else
       ld_shlibs=no
     fi
@@ -1330,7 +1330,7 @@
     fix_srcfile_path='`cygpath -w $srcfile`'
     ;;
 
-  freebsd1*)
+  freebsd1.*)
     ld_shlibs=no
     ;;
 
@@ -1354,7 +1354,7 @@
     ;;
 
   # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-  freebsd*)
+dragonfly* |   freebsd*)
     archive_cmds='$CC -shared -o $lib $libobjs $deplibs $linkopts'
     hardcode_libdir_flag_spec='-R$libdir'
     hardcode_direct=yes
@@ -1864,19 +1864,19 @@
   lt_cv_dlopen_libs=
   ;;
 
-freebsd1*)
+freebsd1.*)
   dynamic_linker=no
   ;;
   
-freebsd*)
-  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+dragonfly* | freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
   version_type=freebsd-$objformat
   case "$version_type" in
     freebsd-elf*)
-      deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object'
+      deplibs_check_method=pass_all
       file_magic_cmd=/usr/bin/file
       file_magic_test_file=`echo /usr/lib/libc.so*`
-      library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
+      library_names_spec='$libname$release.so$versuffix		 $libname$release.so$major $libname.so'	 soname_spec='$libname$release.so$major'
       need_version=no
       need_lib_prefix=no
       ;;
