1 |
gbeauche |
1.1 |
#!/bin/sh |
2 |
|
|
# |
3 |
|
|
# mkstandalone - Make a standalone bundle with GTK runtime |
4 |
|
|
# |
5 |
|
|
# Basilisk II (C) 1997-2006 Christian Bauer |
6 |
|
|
# |
7 |
|
|
# mkstandalone Copyright (C) 2006 Gwenole Beauchesne |
8 |
|
|
# |
9 |
|
|
# This program is free software; you can redistribute it and/or modify |
10 |
|
|
# it under the terms of the GNU General Public License as published by |
11 |
|
|
# the Free Software Foundation; either version 2 of the License, or |
12 |
|
|
# (at your option) any later version. |
13 |
|
|
# |
14 |
|
|
# This program is distributed in the hope that it will be useful, |
15 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
|
|
# GNU General Public License for more details. |
18 |
|
|
# |
19 |
|
|
# You should have received a copy of the GNU General Public License |
20 |
|
|
# along with this program; if not, write to the Free Software |
21 |
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
|
|
|
23 |
|
|
PROG="${1%.app}" |
24 |
|
|
|
25 |
|
|
[ -n "$PROG" ] || { |
26 |
|
|
echo "Usage: ${0##*/} <program|bundle>" |
27 |
|
|
exit 1 |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
[ -d "$PROG.app" ] || { |
31 |
|
|
echo "ERROR: $PROG.app bundle does not exist" |
32 |
|
|
exit 1 |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
[ -x "$PROG.app/Contents/MacOS/$PROG" ] || { |
36 |
|
|
echo "ERROR: $PROG.app is not a properly formed bundle" |
37 |
|
|
exit 1 |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
echo "Processing bundle $PROG.app" |
41 |
|
|
|
42 |
|
|
FRAMEWORKS="GLib GDK GTK" |
43 |
|
|
|
44 |
|
|
rm -r -f $PROG.app/Contents/Frameworks |
45 |
|
|
mkdir -p $PROG.app/Contents/Frameworks |
46 |
|
|
|
47 |
|
|
int_args="" |
48 |
|
|
for fmk_path in `otool -L $PROG.app/Contents/MacOS/$PROG | \ |
49 |
|
|
sed -n '/ *\(\/.*\.framework\/.*\) ([^)]*)/s//\1/p'` |
50 |
|
|
do |
51 |
|
|
fmk_spath="${fmk_path%/Versions/*}" |
52 |
|
|
fmk="${fmk_spath%.framework}" |
53 |
|
|
fmk="${fmk##*/}" |
54 |
|
|
|
55 |
|
|
case " $FRAMEWORKS " in |
56 |
|
|
(*" $fmk "*) ;; |
57 |
|
|
(*) continue ;; |
58 |
|
|
esac |
59 |
|
|
|
60 |
|
|
echo " Linking in framework $fmk" |
61 |
|
|
fmk_dpath=$PROG.app/Contents/Frameworks/$fmk.framework |
62 |
|
|
rm -rf $fmk_dpath |
63 |
|
|
cp -Rf $fmk_spath $fmk_dpath |
64 |
|
|
find $fmk_dpath -name "*Headers*" | xargs rm -rf |
65 |
|
|
fmk_vpath="${fmk_path##*.framework/}" |
66 |
|
|
|
67 |
|
|
# change library dependency |
68 |
|
|
install_name_tool -change \ |
69 |
|
|
$fmk_spath/$fmk_vpath \ |
70 |
|
|
@executable_path/../Frameworks/$fmk.framework/$fmk_vpath \ |
71 |
|
|
$PROG.app/Contents/MacOS/$PROG |
72 |
|
|
|
73 |
|
|
# change shared library id name |
74 |
|
|
fmk_newid="@executable_path/../Frameworks/${fmk_path#*/Frameworks/}" |
75 |
|
|
install_name_tool -id $fmk_newid $fmk_dpath/$fmk_vpath |
76 |
|
|
|
77 |
|
|
# expand final install_name_tool args list |
78 |
|
|
int_args="$int_args -change $fmk_path $fmk_newid" |
79 |
|
|
|
80 |
|
|
# strip shared library |
81 |
|
|
strip -x $fmk_dpath/$fmk_vpath |
82 |
|
|
done |
83 |
|
|
|
84 |
|
|
# change remaining dependency libs names |
85 |
|
|
for f in $FRAMEWORKS; do |
86 |
|
|
install_name_tool $int_args $PROG.app/Contents/Frameworks/$f.framework/$f |
87 |
|
|
done |
88 |
|
|
|
89 |
|
|
exit 0 |