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
|
app=$1
if [ -z "$app" ]; then
echo "Usage: $0 app"
exit 1
fi
ARCH=$($app/Contents/MacOS/swipl --arch)
moduledir=$app/Contents/swipl/lib/$ARCH
frameworkdir=$app/Contents/Frameworks
# macdeployqt appears to copy libjvm.dylib. We
# do not want that.
if [ -f $frameworkdir/libjvm.dylib ]; then
printf "Removing libjvm.dylib from bundle\n"
rm $frameworkdir/libjvm.dylib
fi
printf "Adding Macport dylibs to modules in $moduledir\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
|