changeset 2858:7c6b29399d05

New script to make shared libraries from static libraries. This script should only be used as a temporary solution for those packages which do not have Makefiles that can be easily fixed to generate shared libraries. It would be better to fix the build systems of these libraries to correctly generate shared libraries using CMake or autotools.
author John W. Eaton <jwe@octave.org>
date Thu, 15 Nov 2012 16:14:26 -0500
parents 94c2c61023a0
children a952c6e14c28
files Makefile tools/make-shared-from-static
diffstat 2 files changed, 80 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Fri Nov 16 11:17:52 2012 -0500
+++ b/Makefile	Thu Nov 15 16:14:26 2012 -0500
@@ -52,6 +52,8 @@
 PKGS       := $(shell $(SED) -n 's/^.* id="\([^"]*\)-package">.*$$/\1/p' '$(TOP_DIR)/index.html')
 PATH       := $(PREFIX)/bin:$(PATH)
 
+MAKE_SHARED_FROM_STATIC := $(TOP_DIR)/tools/make-shared-from-static
+
 CMAKE_TOOLCHAIN_FILE := $(PREFIX)/$(TARGET)/share/cmake/mxe-conf.cmake
 
 # unexport any environment variables that might cause trouble
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/make-shared-from-static	Thu Nov 15 16:14:26 2012 -0500
@@ -0,0 +1,78 @@
+#!/usr/bin/env bash
+
+set -e
+
+LD=
+AR=
+infile=
+outfile=
+LIBS=
+
+topdir=$(pwd)
+tmpdir=$topdir/make-shared-from-static.$$
+
+trap "cd $topdir; rm -rf $tmpdir" 1 2 15
+
+for arg
+do
+  case "$1" in
+    --ld)
+      shift
+      if [ $# -gt 0 ]; then
+        LD="$1"
+        shift
+      else
+        echo "make-shared-from-static: expecting argument for --ld option" 1>&2
+        exit 1
+      fi
+    ;;
+    --ar)
+      shift
+      if [ $# -gt 0 ]; then
+        AR="$1"
+        shift
+      else
+        echo "make-shared-from-static: expecting argument for --ar option" 1>&2
+        exit 1
+      fi
+    ;;
+    -l*)
+      LIBS="$LIBS $1"
+      shift
+    ;;
+    *.a)
+      if [ -z "$infile" ]; then
+        case "$1" in
+          /*)
+            infile="$1"
+          ;;
+          *)
+            infile=$(pwd)/$1
+          ;;
+        esac
+        outfile=$(echo $infile | sed 's/\.a$/.dll/')
+        shift
+      else
+        echo "make-shared-from-static: only one input file allowed" 1>&2
+        exit 1
+      fi
+    ;;
+  esac
+done
+
+if [ -z "$outfile" ]; then
+  echo "make-shared-from-static: no output file specified" 1>&2
+  exit 1
+fi
+
+mkdir $tmpdir
+
+(
+  cd $tmpdir
+
+  $AR x $infile
+
+  $LD -shared -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--out-implib=$outfile.a -o $outfile *.o $LIBS
+)
+
+rm -rvf $tmpdir
\ No newline at end of file