annotate tools/make-shared-from-static @ 2868:1c18d3bb1829

Include suitesparse as a dependency of Octave
author John W. Eaton <jwe@octave.org>
date Tue, 27 Nov 2012 18:12:49 -0500
parents 7c6b29399d05
children 4f9b72cf7ee7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2858
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 #!/usr/bin/env bash
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 set -e
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 LD=
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 AR=
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 infile=
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 outfile=
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 LIBS=
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 topdir=$(pwd)
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 tmpdir=$topdir/make-shared-from-static.$$
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 trap "cd $topdir; rm -rf $tmpdir" 1 2 15
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 for arg
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 do
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 case "$1" in
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 --ld)
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 shift
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 if [ $# -gt 0 ]; then
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 LD="$1"
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 shift
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 else
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 echo "make-shared-from-static: expecting argument for --ld option" 1>&2
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 exit 1
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 fi
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 ;;
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 --ar)
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 shift
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 if [ $# -gt 0 ]; then
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 AR="$1"
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 shift
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 else
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 echo "make-shared-from-static: expecting argument for --ar option" 1>&2
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 exit 1
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 fi
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 ;;
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 -l*)
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 LIBS="$LIBS $1"
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 shift
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 ;;
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 *.a)
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 if [ -z "$infile" ]; then
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 case "$1" in
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 /*)
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 infile="$1"
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 ;;
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 *)
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 infile=$(pwd)/$1
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 ;;
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 esac
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 outfile=$(echo $infile | sed 's/\.a$/.dll/')
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 shift
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 else
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 echo "make-shared-from-static: only one input file allowed" 1>&2
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 exit 1
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 fi
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 ;;
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 esac
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 done
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 if [ -z "$outfile" ]; then
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 echo "make-shared-from-static: no output file specified" 1>&2
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 exit 1
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 fi
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 mkdir $tmpdir
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 (
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 cd $tmpdir
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 $AR x $infile
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 $LD -shared -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--out-implib=$outfile.a -o $outfile *.o $LIBS
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 )
7c6b29399d05 New script to make shared libraries from static libraries. This
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
2868
1c18d3bb1829 Include suitesparse as a dependency of Octave
John W. Eaton <jwe@octave.org>
parents: 2858
diff changeset
78 rm -rf $tmpdir