forked from SWI-Prolog/swipl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacosx_bundle_fixup.sh
executable file
·83 lines (73 loc) · 1.73 KB
/
macosx_bundle_fixup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
deployqt=
usage()
{ echo "Usage: $0 [--deployqt=prog] app"
exit 1
}
done=no
while [ $done = no ]; do
case "$1" in
--deployqt=*)
deployqt="$(echo $1 | sed 's/--deployqt=//')"
shift
;;
--*)
usage
;;
*)
done=yes
;;
esac
done
app=$1
if [ -z "$app" ]; then
usage
fi
printf "Fixing app bundle in $app\n"
ARCH=$($app/Contents/MacOS/swipl --arch)
moduledir=$app/Contents/swipl/lib/$ARCH
frameworkdir=$app/Contents/Frameworks
if [ ! -z "$deployqt" ]; then
dest=$(dirname $app)
printf "Moving modules to avoid deployqt from interfering ..."
mv $moduledir $dest
printf "ok\n"
printf "Running $(basename $deployqt) ...\n"
$deployqt $app
printf "Restoring modules\n"
mv $dest/$(basename $moduledir) $(dirname $moduledir)
fi
printf "Adding Macport dylibs to modules\n"
changeset="$(echo $moduledir/*) $app/Contents/MacOS/swipl"
while [ ! -z "$changeset" ]; do
newchanges=
for f in $changeset; do
case "$(file $f)" in
*Mach-O*)
opt_dep=$(otool -L $f |
grep '\(/opt/local\|/deps/\)' |
grep -v libjvm |
awk '{print $1}')
if [ ! -z "$opt_dep" ]; then
change=""
for dep in $opt_dep; do
file="$frameworkdir/$(basename $dep)"
if [ ! -f $file ]; then
printf " Adding $dep ... "
cp $dep $frameworkdir
chmod 755 $file
newchanges="$newchanges $file"
printf 'ok\n'
fi
change="$change -change $dep @rpath/$(basename $dep)"
done
if [ ! -z "$change" ]; then
install_name_tool $change $f
fi
fi
;;
*)
esac
done
changeset="$newchanges"
done