1 |
root |
1.1 |
#!/bin/bash |
2 |
|
|
|
3 |
root |
1.8 |
# this gem of a hack gathers all files required by the client for the platform |
4 |
root |
1.4 |
# by deep magic, it works on osx, linux and windows. on MY osx, linux |
5 |
|
|
# and windows, that is. |
6 |
|
|
|
7 |
root |
1.1 |
STRIP="strip" |
8 |
|
|
LIBEXT=so |
9 |
|
|
LIB0=so.? |
10 |
|
|
SO=so |
11 |
|
|
SYSLIB=/usr/lib |
12 |
|
|
MAKE=make |
13 |
|
|
ARCHNAME=x86 |
14 |
root |
1.4 |
GENPACK_ENVVARS="LD_LIBRARY_PATH=." |
15 |
root |
1.1 |
|
16 |
|
|
umask 022 |
17 |
|
|
|
18 |
|
|
if [ "$(uname -s)" = CYGWIN_NT-5.0 ]; then |
19 |
|
|
. ~/.setenv |
20 |
|
|
|
21 |
|
|
OS=windows |
22 |
root |
1.7 |
URLADER=windows-x86 |
23 |
root |
1.1 |
unset PANGO |
24 |
|
|
PERL=/c/perl/bin/perl |
25 |
|
|
MAKE=nmake |
26 |
|
|
SYSLIB=/c/gtk/bin |
27 |
|
|
LIBEXT=dll |
28 |
|
|
LIB0=dll |
29 |
|
|
SO=dll |
30 |
|
|
STRIP=":" # stripping the perl library kills it, and apparently, everythignis always stripped |
31 |
|
|
|
32 |
|
|
# fontconfig apparently ignores env vars and always looks at ./etc/fonts/fonts.conf, |
33 |
|
|
# but only if . isn't actually called bin or lib. hope for the best. |
34 |
|
|
GENPACK_ENVVARS="FONTCONFIG_PATH=pm/Deliantra/Client/private/resources/fonts FONTCONFIG_FILE=fonts.conf" |
35 |
|
|
|
36 |
|
|
pango-querymodules() { |
37 |
|
|
/c/gtk/bin/pango-querymodules # empty output usually |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
elif [ "$(uname -s)" = Darwin ]; then |
41 |
|
|
OS=darwin |
42 |
root |
1.6 |
URLADER=darwin-x86 |
43 |
root |
1.1 |
PANGO=1.6.0 |
44 |
|
|
PERL=/opt/local/bin/perl |
45 |
root |
1.4 |
GENPACK_ENVVARS="DYLD_LIBRARY_PATH=." |
46 |
root |
1.1 |
|
47 |
|
|
SYSLIB=/opt/local/lib |
48 |
|
|
LIB0=dylib |
49 |
|
|
SO=bundle |
50 |
|
|
STRIP="strip -x" |
51 |
|
|
elif [ $(arch) = i686 ]; then |
52 |
|
|
OS=linux |
53 |
root |
1.6 |
URLADER=linux-x86 |
54 |
root |
1.1 |
PANGO=1.5.0 |
55 |
|
|
PERL=/usr/bin/perl |
56 |
|
|
else |
57 |
|
|
OS=linux |
58 |
root |
1.6 |
URLADER=linux-amd64 |
59 |
root |
1.1 |
PANGO=1.5.0 |
60 |
|
|
PERL=/usr/bin/perl |
61 |
|
|
ARCHNAME=amd64 |
62 |
|
|
fi |
63 |
|
|
|
64 |
|
|
export DIST="$(pwd)/dist/$OS-$ARCHNAME" |
65 |
|
|
|
66 |
root |
1.12 |
eval $($PERL -V:sitebinexp:) |
67 |
root |
1.1 |
|
68 |
root |
1.12 |
"$sitebinexp"/perl-libextractor --exedir . --dlldir . --bindir pm/bin --libdir pm \ |
69 |
|
|
--perl --core-support --script deliantra \ |
70 |
|
|
--runtime-only --strip \ |
71 |
|
|
--copy "$DIST" |
72 |
root |
1.1 |
|
73 |
|
|
cat <<EOF >"$DIST"/pango.rc |
74 |
|
|
[Pango] |
75 |
|
|
ModuleFiles = pango.modules |
76 |
|
|
EOF |
77 |
|
|
|
78 |
|
|
( |
79 |
|
|
exec 5>"$DIST"/pango.modules |
80 |
|
|
pango-querymodules | grep ^/ | while read lib rest; do |
81 |
|
|
base=$(basename "$lib") |
82 |
|
|
[ "$base" = pango-basic-x.$LIBEXT ] && continue |
83 |
|
|
cp -p "$lib" "$DIST"/. |
84 |
root |
1.7 |
echo "./$base $rest" >&5 # using ./ seems to help pango not to rummage around in /usr/lib etc. |
85 |
root |
1.1 |
done |
86 |
|
|
) |
87 |
|
|
|
88 |
|
|
############################################################################# |
89 |
|
|
|
90 |
|
|
IFS=" |
91 |
|
|
" # space tab nl cr - cr for windows |
92 |
|
|
eval $($PERL -V:sitebinexp -V:sitearchexp -V:sitelib -V:vendorarchexp -V:vendorlibexp -V:archlibexp -V:privlibexp) |
93 |
|
|
|
94 |
|
|
mkdir -p "$DIST"/pm/bin |
95 |
|
|
cp "$sitebinexp"/deliantra "$DIST"/pm/bin/ |
96 |
|
|
cp -p util/run "$DIST" |
97 |
|
|
|
98 |
|
|
############################################################################# |
99 |
|
|
|
100 |
|
|
if [ "$OS" = windows ]; then |
101 |
|
|
libdeps() { |
102 |
|
|
objdump -p "$1" | awk '/\tDLL Name:/ { print $3 }' | while read lib; do |
103 |
|
|
set -- $(type "$lib") |
104 |
|
|
case "$3" in |
105 |
|
|
/c/WINNT/* | /c/sdk/* ) |
106 |
|
|
;; |
107 |
|
|
* ) |
108 |
|
|
echo "$3" |
109 |
|
|
;; |
110 |
|
|
esac |
111 |
|
|
done |
112 |
|
|
} |
113 |
|
|
elif [ "$OS" = darwin ]; then |
114 |
|
|
libdeps() { |
115 |
|
|
otool -L "$1" | perl -ne 'print "$1\n" if m%^\s+(/opt\S+)%' |
116 |
|
|
} |
117 |
|
|
else |
118 |
|
|
libdeps() { |
119 |
|
|
ldd "$1" | perl -ne 'print "$1\n" if / => (\S+)/' |
120 |
|
|
} |
121 |
|
|
fi |
122 |
|
|
|
123 |
|
|
add_deps() { |
124 |
|
|
local so="$1" |
125 |
|
|
libdeps "$so" | while read path; do |
126 |
|
|
base="$(basename "$path")" |
127 |
|
|
if ! [ -e "$base" ]; then |
128 |
|
|
cp -p "$path" . |
129 |
|
|
chmod 755 "$base" |
130 |
|
|
add_deps "$base" |
131 |
|
|
fi |
132 |
|
|
done |
133 |
|
|
} |
134 |
|
|
|
135 |
|
|
( |
136 |
|
|
cd "$DIST" |
137 |
|
|
|
138 |
|
|
if [ "$OS" = windows ]; then |
139 |
|
|
cp -p $SYSLIB/libvorbisfile-3.dll $SYSLIB/mikmod.dll $SYSLIB/libpng12-0.dll . |
140 |
|
|
cp /root/src/CFPlus/util/splash.bmp . |
141 |
|
|
chmod -R u+rwX pm/auto |
142 |
root |
1.2 |
|
143 |
|
|
# convert perl to a non-console-app |
144 |
|
|
$PERL -MWin32::Exe -e '$e = new Win32::Exe"perl.exe"; $e->set_subsystem_windows; $e->write' |
145 |
|
|
|
146 |
root |
1.1 |
else |
147 |
|
|
for lib in mikmod vorbisfile; do |
148 |
|
|
cp -p $SYSLIB/lib$lib.$LIB0 . |
149 |
|
|
chmod 755 lib$lib.$LIB0 |
150 |
|
|
done |
151 |
|
|
fi |
152 |
|
|
|
153 |
|
|
for so in $(find . -name "*.$SO" -o -name "*.$LIBEXT" -o -name "*.$LIB0") perl; do |
154 |
|
|
add_deps "$so" |
155 |
|
|
done |
156 |
|
|
|
157 |
|
|
rm -f pm/auto/POSIX/*.al |
158 |
|
|
|
159 |
|
|
for lib in \ |
160 |
|
|
dl c m rt pthread nsl crypt \ |
161 |
|
|
X11 Xext Xau Xdmcp ICE SM Xrandr Xrender Xxf86vm drm GL \ |
162 |
|
|
z |
163 |
|
|
do |
164 |
root |
1.5 |
rm -f lib"$lib".$LIB0 |
165 |
root |
1.1 |
done |
166 |
|
|
|
167 |
root |
1.5 |
if [ "$OS" != windows ]; then |
168 |
|
|
# patch braindamaged pango |
169 |
root |
1.8 |
|
170 |
root |
1.10 |
if [ "$OS" != darwin ]; then |
171 |
|
|
set libpango-1.0.$LIB0 |
172 |
|
|
perl -pe 's{/u(?=sr/lib(32)?/pango)}{.\x00}g;' <"$1" >"$1~" && mv "$1~" "$1" |
173 |
root |
1.8 |
else |
174 |
root |
1.10 |
set lib*pango-1.0.0.dylib |
175 |
|
|
perl -pe 's{/o(?=pt/local/.../pango)}{.\x00}g;' <"$1" >"$1~" && mv "$1~" "$1" |
176 |
root |
1.8 |
fi |
177 |
root |
1.5 |
chmod 755 "$1" |
178 |
|
|
fi |
179 |
|
|
|
180 |
root |
1.1 |
if [ "$OS" = darwin ]; then |
181 |
|
|
# "dll hell" is most severe on os x, because apple |
182 |
|
|
# does not generally give a shit for backwards compatibility, |
183 |
|
|
# alwayss ships outdated libraries and often provides libraries |
184 |
|
|
# of the same name as well-known libs (such as libjpeg), that |
185 |
|
|
# of course do something completely different |
186 |
|
|
patchlibs() { |
187 |
|
|
<"$1" \ |
188 |
|
|
perl -0777 -pe ' |
189 |
|
|
s%('"/opt/local/lib[^\x00]*/lib"'([^\x00/]+)\.dylib\x00)% |
190 |
|
|
my $s = $1; |
191 |
|
|
my $r = "libdeliantra-$2.dylib\x00"; |
192 |
|
|
(length $r) <= (length $s) |
193 |
|
|
or die "lib replacement <$r> larger than <$s>\n"; |
194 |
|
|
substr $s, 0, length $r, $r; |
195 |
|
|
$s |
196 |
|
|
%ge |
197 |
|
|
' \ |
198 |
|
|
>"$1~" && mv "$1~" "$1" || exit 67 |
199 |
|
|
} |
200 |
|
|
|
201 |
|
|
# patch bundles and pango modules with external dependencies, |
202 |
|
|
# should be few, so hardcode(tm) |
203 |
|
|
for so in \ |
204 |
|
|
pm/auto/BDB/BDB.bundle \ |
205 |
|
|
pm/auto/Deliantra/Client/Client.bundle \ |
206 |
|
|
*.$LIBEXT |
207 |
|
|
do |
208 |
|
|
patchlibs "$so" |
209 |
|
|
done |
210 |
|
|
|
211 |
|
|
# now patch and rename all .dylibs |
212 |
|
|
for lib in *.$LIB0; do |
213 |
|
|
stem="${lib#lib}" |
214 |
|
|
stem="${stem%.$LIB0}" |
215 |
|
|
patchlibs "$lib" |
216 |
|
|
mv "$lib" "libdeliantra-$stem.dylib" |
217 |
|
|
done |
218 |
|
|
fi |
219 |
|
|
|
220 |
root |
1.7 |
[ "$OS" = linux ] && chrpath -d perl $(find pm -name "*.so") # debian perls have an rpath, many modules too |
221 |
root |
1.1 |
$STRIP $(find . -name "*.$SO" -o -name "*.$LIBEXT" -o -name "*.$LIB0") perl |
222 |
root |
1.7 |
|
223 |
|
|
: >timidity.cfg |
224 |
root |
1.1 |
) |
225 |
|
|
|
226 |
root |
1.6 |
cat >"$DIST".vars <<EOF |
227 |
|
|
G_URLADER="$URLADER" |
228 |
|
|
G_OS="$OS" |
229 |
|
|
G_ARCHNAME="$ARCHNAME" |
230 |
|
|
G_ENVVARS="$GENPACK_ENVVARS" |
231 |
root |
1.7 |
G_COMMAND="./perl run" |
232 |
root |
1.6 |
EOF |
233 |
root |
1.1 |
|