# HG changeset patch # User John W. Eaton # Date 1353014066 18000 # Node ID 7c6b29399d05bdb23320daa9d0313022c097b1de # Parent 94c2c61023a00a305ddbe669ff86a968bdbb8493 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. diff -r 94c2c61023a0 -r 7c6b29399d05 Makefile --- 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 diff -r 94c2c61023a0 -r 7c6b29399d05 tools/make-shared-from-static --- /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