download gamepacks: properly support xonoticpack
[xonotic/netradiant.git] / install-dylibs.sh
1 #!/bin/sh
2
3 set -ex
4
5 : ${OTOOL:=otool}
6 : ${CP:=cp}
7 : ${INSTALLDIR:=.}
8 : ${EXE:=ppc}
9 : ${MACLIBDIR:=/sw/lib}
10 : ${CAT:=cat}
11
12
13 finkgetdeps()
14 {
15         otool -L "$1" | grep "$MACLIBDIR" | while read -r LIB STUFF; do
16                 [ -z "${LIB##*:}" ] && continue # first line
17                 [ -f "$INSTALLDIR/${LIB##*/}" ] && continue
18                 cp -vL "$LIB" "$INSTALLDIR"
19                 finkgetdeps "$LIB"
20         done
21 }
22
23
24 finkgetdeps "$INSTALLDIR/radiant.$EXE"
25 echo Warning: this only works if only ONE version of gtk-2.0 and pango is installed
26
27 for LIB in "$MACLIBDIR"/gtk-2.0/*/loaders/libpixbufloader-bmp.so; do
28         LAST=$LIB
29 done
30 cp -L "$LAST" "$INSTALLDIR"
31 finkgetdeps "$LAST"
32
33 for LIB in "$MACLIBDIR"/pango/*/modules/pango-basic-fc.so; do
34         LAST=$LIB
35 done
36 cp -L "$LAST" "$INSTALLDIR"
37 finkgetdeps "$LAST"
38
39 for LIB in "$MACLIBDIR"/pango/*/modules/pango-basic-x.so; do
40         LAST=$LIB
41 done
42 cp -L "$LAST" "$INSTALLDIR"
43 finkgetdeps "$LAST"
44
45 cp -L "$MACLIBDIR"/../etc/fonts/fonts.conf "$INSTALLDIR"
46 cp -L "$MACLIBDIR"/../etc/fonts/fonts.dtd "$INSTALLDIR"
47 cp -L "$MACLIBDIR"/../etc/gtk-2.0/gdk-pixbuf.loaders "$INSTALLDIR"
48 cp -L "$MACLIBDIR"/../etc/pango/pangorc "$INSTALLDIR"
49
50 $CAT > "$INSTALLDIR/../netradiant.sh" <<EOF
51 #!/bin/sh
52
53 MY_DIRECTORY="\${0%/*}" # cut off the script name
54 MY_DIRECTORY="\${MY_DIRECTORY%/*}" # cut off MacOS
55 MY_DIRECTORY="\${MY_DIRECTORY%/*}" # cut off Contents
56
57 export DYLD_LIBRARY_PATH="\$MY_DIRECTORY/Contents/MacOS/install"
58 export PANGO_RC_FILE="\$MY_DIRECTORY/Contents/MacOS/install/pangorc"
59 export GDK_PIXBUF_MODULE_FILE="\$MY_DIRECTORY/Contents/MacOS/install/gdk-pixbuf.loaders"
60 export FONTCONFIG_FILE="\$MY_DIRECTORY/Contents/MacOS/install/fonts.conf"
61
62 cd "\$MY_DIRECTORY/Contents/MacOS/install"
63 if [ -x /usr/bin/open-x11 ]; then
64         env LC_ALL="en_US.UTF-8" /usr/bin/open-x11 ./radiant.$EXE "$@" &
65 else
66         env LC_ALL="en_US.UTF-8" ./radiant.$EXE "$@" &
67 fi
68 EOF
69
70 chmod 755 "$INSTALLDIR/../netradiant.sh"
71