]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Thu, 13 Oct 2016 22:51:44 +0000 (17:51 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Thu, 13 Oct 2016 22:51:44 +0000 (17:51 -0500)
install/macos/clean_libs.sh [new file with mode: 0755]
install/macos/prepare_libs.sh [new file with mode: 0755]
install/macos/relink_lib.sh [new file with mode: 0755]

diff --git a/install/macos/clean_libs.sh b/install/macos/clean_libs.sh
new file mode 100755 (executable)
index 0000000..14613ce
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+lib_dir=$1
+
+for i in $lib_dir/*
+  do
+  lnk_i=`readlink $i`
+  if ! [[ $lnk_i = *[!\ ]* ]]; then
+      echo $lnk_i
+  fi
+done
+
+## eof
diff --git a/install/macos/prepare_libs.sh b/install/macos/prepare_libs.sh
new file mode 100755 (executable)
index 0000000..e8cb78d
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+lib_dir=$1
+
+for i in $lib_dir/*
+  do
+  lnk_i=`readlink $i`
+  if ! [[ $lnk_i = *[!\ ]* ]]; then
+      equal_lib=""
+      for j in $lib_dir/*
+        do
+        lnk_j=`readlink $j`
+        if ! [[ $lnk_j = *[!\ ]* ]]; then
+            difference=`diff -q $i $j`
+            if ! [[ $difference = *[!\ ]* ]]; then
+                equal_lib+=$j
+                equal_lib+=" "
+            fi
+        fi
+      done
+      if [[ $equal_lib = *[!\ ]* ]]; then
+          max_len=0
+          max_str=""
+          for k in $equal_lib
+            do
+            if [ ${#k} -ge $max_len ]; then
+                        max_len=${#k}
+                            max_str=$k
+            fi
+          done
+          echo $max_str
+          for k in $equal_lib
+            do
+            if ! [ $k == $max_str ]; then
+                rm -rf $k
+                ln -fs $max_str $k
+            fi
+          done
+          unset max_len
+          unset max_str
+      fi
+      unset equal_lib
+  fi
+done
+
+## eof
diff --git a/install/macos/relink_lib.sh b/install/macos/relink_lib.sh
new file mode 100755 (executable)
index 0000000..f2172c2
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+file=$1
+lib_dir=$2
+exec_dir=$3
+
+strindex( )
+{ 
+  x="${1%%$2*}"
+  [[ $x = $1 ]] && echo -1 || echo ${#x}
+  }
+  
+file_link=`readlink $file`
+if ! [[ $file_link = *[!\ ]* ]]; then
+    for lib in $lib_dir/*
+      do
+      lib_name=`basename $lib`
+      linked_lib=`otool -L $file | grep $lib_name | tail -1`
+      if [[ $linked_lib = *[!\ ]* ]]; then
+          index=`strindex "$linked_lib" " ("`
+          real_lib=`echo $linked_lib | cut -c 1-$index`
+          lib_link=`readlink $lib`
+          if [[ $lib_link = *[!\ ]* ]]; then
+              lib_link=`basename $lib_link`
+          else
+              lib_link=$lib_name
+          fi
+          if [[ $lib_link = *[!\ ]* ]]; then
+              echo $real_lib $lib_link
+              install_name_tool -change $real_lib $exec_dir/$lib_link $file
+          fi
+      fi
+    done
+fi
+
+## eof
\ No newline at end of file