From cbecfd2350e2d10811921f1154994bf7581b491e Mon Sep 17 00:00:00 2001
From: Peter Tworek <tworaz666@gmail.com>
Date: Wed, 22 May 2013 16:48:34 -0400
Subject: [PATCH] Add shared library support for Minix3.

---
 m4/libtool.m4 | 34 ++++++++++++++++++++++++++++++++++
 m4/ltdl.m4    |  3 +++
 2 files changed, 37 insertions(+)

diff --git a/m4/libtool.m4 b/m4/libtool.m4
index d7013c5..555f6fb 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -2676,6 +2676,18 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
+minix*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Minix ld.elf_so'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
@@ -3265,6 +3277,10 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
+minix*)
+  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+  ;;
+
 netbsd*)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
@@ -4121,6 +4137,8 @@ m4_if([$1], [CXX], [
 	;;
       m88k*)
 	;;
+      minix*)
+	;;
       mvs*)
 	case $cc_basename in
 	  cxx*)
@@ -4907,6 +4925,11 @@ _LT_EOF
       fi
       ;;
 
+    minix*)
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      ;;
+
     netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
@@ -5389,6 +5412,13 @@ _LT_EOF
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
+    minix*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
     netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
@@ -6575,6 +6605,10 @@ if test yes != "$_lt_caught_CXX_error"; then
         _LT_TAGVAR(ld_shlibs, $1)=no
 	;;
 
+      minix*)
+        _LT_TAGVAR(ld_shlibs, $1)=yes
+	;;
+
       mvs*)
         case $cc_basename in
           cxx*)
diff --git a/m4/ltdl.m4 b/m4/ltdl.m4
index 7251813..41dcb25 100644
--- a/m4/ltdl.m4
+++ b/m4/ltdl.m4
@@ -496,6 +496,9 @@ AC_CACHE_CHECK([whether deplibs are loaded by dlopen],
     # at 6.2 and later dlopen does load deplibs.
     lt_cv_sys_dlopen_deplibs=yes
     ;;
+  minix*)
+    lt_cv_sys_dlopen_deplibs=yes
+    ;;
   netbsd*)
     lt_cv_sys_dlopen_deplibs=yes
     ;;
-- 
1.8.1.5

