fix spotScale implementation
[divverent/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 LAST=
28 for LIB in "$MACLIBDIR"/gtk-2.0/*/loaders/libpixbufloader-bmp.so "$MACLIBDIR"/gdk-pixbuf-2.0/*/loaders/libpixbufloader-bmp.so; do
29         [ -f "$LIB" ] || continue
30         LAST=$LIB
31 done
32 cp -L "$LAST" "$INSTALLDIR"
33 finkgetdeps "$LAST"
34
35 LAST=
36 for LIB in "$MACLIBDIR"/pango/*/modules/pango-basic-fc.so; do
37         [ -f "$LIB" ] || continue
38         LAST=$LIB
39 done
40 cp -L "$LAST" "$INSTALLDIR"
41 finkgetdeps "$LAST"
42
43 LAST=
44 for LIB in "$MACLIBDIR"/pango/*/modules/pango-basic-x.so; do
45         [ -f "$LIB" ] || continue
46         LAST=$LIB
47 done
48 cp -L "$LAST" "$INSTALLDIR"
49 finkgetdeps "$LAST"
50
51 cp -L "$MACLIBDIR"/../etc/fonts/fonts.conf "$INSTALLDIR"
52 cp -L "$MACLIBDIR"/../etc/fonts/fonts.dtd "$INSTALLDIR"
53 cp -L "$MACLIBDIR"/../etc/gtk-2.0/gdk-pixbuf.loaders "$INSTALLDIR"
54 cp -L "$MACLIBDIR"/../etc/pango/pangorc "$INSTALLDIR"
55
56 $CAT > "$INSTALLDIR/../netradiant.sh" <<EOF
57 #!/bin/sh
58
59 MY_DIRECTORY="\${0%/*}" # cut off the script name
60 MY_DIRECTORY="\${MY_DIRECTORY%/*}" # cut off MacOS
61 MY_DIRECTORY="\${MY_DIRECTORY%/*}" # cut off Contents
62
63 export DYLD_LIBRARY_PATH="\$MY_DIRECTORY/Contents/MacOS/install"
64 export PANGO_RC_FILE="\$MY_DIRECTORY/Contents/MacOS/install/pangorc"
65 export GDK_PIXBUF_MODULE_FILE="\$MY_DIRECTORY/Contents/MacOS/install/gdk-pixbuf.loaders"
66 export FONTCONFIG_FILE="\$MY_DIRECTORY/Contents/MacOS/install/fonts.conf"
67
68 cd "\$MY_DIRECTORY/Contents/MacOS/install"
69 if [ -x /usr/bin/open-x11 ]; then
70         env LC_ALL="en_US.UTF-8" /usr/bin/open-x11 ./radiant.$EXE "$@" &
71 else
72         env LC_ALL="en_US.UTF-8" ./radiant.$EXE "$@" &
73 fi
74 EOF
75
76 chmod 755 "$INSTALLDIR/../netradiant.sh"
77