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 |
root |
1.13 |
DISTf="dist/$OS-$ARCHNAME" |
65 |
|
|
export DIST="$(pwd)/$DISTf" |
66 |
root |
1.1 |
|
67 |
root |
1.13 |
eval $("$PERL" -V:sitebinexp:) |
68 |
root |
1.1 |
|
69 |
root |
1.13 |
"$PERL" "$sitebinexp"/perl-libextractor --exedir . --dlldir . --bindir pm/bin --libdir pm \ |
70 |
root |
1.12 |
--perl --core-support --script deliantra \ |
71 |
|
|
--runtime-only --strip \ |
72 |
root |
1.13 |
--copy "$DISTf" |
73 |
root |
1.1 |
|
74 |
|
|
cat <<EOF >"$DIST"/pango.rc |
75 |
|
|
[Pango] |
76 |
|
|
ModuleFiles = pango.modules |
77 |
|
|
EOF |
78 |
|
|
|
79 |
|
|
( |
80 |
|
|
exec 5>"$DIST"/pango.modules |
81 |
|
|
pango-querymodules | grep ^/ | while read lib rest; do |
82 |
|
|
base=$(basename "$lib") |
83 |
|
|
[ "$base" = pango-basic-x.$LIBEXT ] && continue |
84 |
|
|
cp -p "$lib" "$DIST"/. |
85 |
root |
1.7 |
echo "./$base $rest" >&5 # using ./ seems to help pango not to rummage around in /usr/lib etc. |
86 |
root |
1.1 |
done |
87 |
|
|
) |
88 |
|
|
|
89 |
|
|
############################################################################# |
90 |
|
|
|
91 |
|
|
IFS=" |
92 |
|
|
" # space tab nl cr - cr for windows |
93 |
|
|
eval $($PERL -V:sitebinexp -V:sitearchexp -V:sitelib -V:vendorarchexp -V:vendorlibexp -V:archlibexp -V:privlibexp) |
94 |
|
|
|
95 |
|
|
mkdir -p "$DIST"/pm/bin |
96 |
|
|
cp "$sitebinexp"/deliantra "$DIST"/pm/bin/ |
97 |
|
|
cp -p util/run "$DIST" |
98 |
|
|
|
99 |
|
|
############################################################################# |
100 |
|
|
|
101 |
|
|
if [ "$OS" = windows ]; then |
102 |
|
|
libdeps() { |
103 |
|
|
objdump -p "$1" | awk '/\tDLL Name:/ { print $3 }' | while read lib; do |
104 |
|
|
set -- $(type "$lib") |
105 |
|
|
case "$3" in |
106 |
|
|
/c/WINNT/* | /c/sdk/* ) |
107 |
|
|
;; |
108 |
|
|
* ) |
109 |
|
|
echo "$3" |
110 |
|
|
;; |
111 |
|
|
esac |
112 |
|
|
done |
113 |
|
|
} |
114 |
|
|
elif [ "$OS" = darwin ]; then |
115 |
|
|
libdeps() { |
116 |
|
|
otool -L "$1" | perl -ne 'print "$1\n" if m%^\s+(/opt\S+)%' |
117 |
|
|
} |
118 |
|
|
else |
119 |
|
|
libdeps() { |
120 |
|
|
ldd "$1" | perl -ne 'print "$1\n" if / => (\S+)/' |
121 |
|
|
} |
122 |
|
|
fi |
123 |
|
|
|
124 |
|
|
add_deps() { |
125 |
|
|
local so="$1" |
126 |
|
|
libdeps "$so" | while read path; do |
127 |
|
|
base="$(basename "$path")" |
128 |
|
|
if ! [ -e "$base" ]; then |
129 |
|
|
cp -p "$path" . |
130 |
|
|
chmod 755 "$base" |
131 |
|
|
add_deps "$base" |
132 |
|
|
fi |
133 |
|
|
done |
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
( |
137 |
|
|
cd "$DIST" |
138 |
|
|
|
139 |
|
|
if [ "$OS" = windows ]; then |
140 |
|
|
cp -p $SYSLIB/libvorbisfile-3.dll $SYSLIB/mikmod.dll $SYSLIB/libpng12-0.dll . |
141 |
|
|
cp /root/src/CFPlus/util/splash.bmp . |
142 |
|
|
chmod -R u+rwX pm/auto |
143 |
root |
1.2 |
|
144 |
|
|
# convert perl to a non-console-app |
145 |
|
|
$PERL -MWin32::Exe -e '$e = new Win32::Exe"perl.exe"; $e->set_subsystem_windows; $e->write' |
146 |
|
|
|
147 |
root |
1.1 |
else |
148 |
|
|
for lib in mikmod vorbisfile; do |
149 |
|
|
cp -p $SYSLIB/lib$lib.$LIB0 . |
150 |
|
|
chmod 755 lib$lib.$LIB0 |
151 |
|
|
done |
152 |
|
|
fi |
153 |
|
|
|
154 |
|
|
for so in $(find . -name "*.$SO" -o -name "*.$LIBEXT" -o -name "*.$LIB0") perl; do |
155 |
|
|
add_deps "$so" |
156 |
|
|
done |
157 |
|
|
|
158 |
|
|
rm -f pm/auto/POSIX/*.al |
159 |
|
|
|
160 |
|
|
for lib in \ |
161 |
|
|
dl c m rt pthread nsl crypt \ |
162 |
|
|
X11 Xext Xau Xdmcp ICE SM Xrandr Xrender Xxf86vm drm GL \ |
163 |
|
|
z |
164 |
|
|
do |
165 |
root |
1.5 |
rm -f lib"$lib".$LIB0 |
166 |
root |
1.1 |
done |
167 |
|
|
|
168 |
root |
1.5 |
if [ "$OS" != windows ]; then |
169 |
|
|
# patch braindamaged pango |
170 |
root |
1.8 |
|
171 |
root |
1.10 |
if [ "$OS" != darwin ]; then |
172 |
|
|
set libpango-1.0.$LIB0 |
173 |
|
|
perl -pe 's{/u(?=sr/lib(32)?/pango)}{.\x00}g;' <"$1" >"$1~" && mv "$1~" "$1" |
174 |
root |
1.8 |
else |
175 |
root |
1.10 |
set lib*pango-1.0.0.dylib |
176 |
|
|
perl -pe 's{/o(?=pt/local/.../pango)}{.\x00}g;' <"$1" >"$1~" && mv "$1~" "$1" |
177 |
root |
1.8 |
fi |
178 |
root |
1.5 |
chmod 755 "$1" |
179 |
|
|
fi |
180 |
|
|
|
181 |
root |
1.1 |
if [ "$OS" = darwin ]; then |
182 |
|
|
# "dll hell" is most severe on os x, because apple |
183 |
|
|
# does not generally give a shit for backwards compatibility, |
184 |
|
|
# alwayss ships outdated libraries and often provides libraries |
185 |
|
|
# of the same name as well-known libs (such as libjpeg), that |
186 |
|
|
# of course do something completely different |
187 |
|
|
patchlibs() { |
188 |
|
|
<"$1" \ |
189 |
|
|
perl -0777 -pe ' |
190 |
|
|
s%('"/opt/local/lib[^\x00]*/lib"'([^\x00/]+)\.dylib\x00)% |
191 |
|
|
my $s = $1; |
192 |
|
|
my $r = "libdeliantra-$2.dylib\x00"; |
193 |
|
|
(length $r) <= (length $s) |
194 |
|
|
or die "lib replacement <$r> larger than <$s>\n"; |
195 |
|
|
substr $s, 0, length $r, $r; |
196 |
|
|
$s |
197 |
|
|
%ge |
198 |
|
|
' \ |
199 |
|
|
>"$1~" && mv "$1~" "$1" || exit 67 |
200 |
|
|
} |
201 |
|
|
|
202 |
|
|
# patch bundles and pango modules with external dependencies, |
203 |
|
|
# should be few, so hardcode(tm) |
204 |
|
|
for so in \ |
205 |
|
|
pm/auto/BDB/BDB.bundle \ |
206 |
|
|
pm/auto/Deliantra/Client/Client.bundle \ |
207 |
|
|
*.$LIBEXT |
208 |
|
|
do |
209 |
|
|
patchlibs "$so" |
210 |
|
|
done |
211 |
|
|
|
212 |
|
|
# now patch and rename all .dylibs |
213 |
|
|
for lib in *.$LIB0; do |
214 |
|
|
stem="${lib#lib}" |
215 |
|
|
stem="${stem%.$LIB0}" |
216 |
|
|
patchlibs "$lib" |
217 |
|
|
mv "$lib" "libdeliantra-$stem.dylib" |
218 |
|
|
done |
219 |
|
|
fi |
220 |
|
|
|
221 |
root |
1.7 |
[ "$OS" = linux ] && chrpath -d perl $(find pm -name "*.so") # debian perls have an rpath, many modules too |
222 |
root |
1.1 |
$STRIP $(find . -name "*.$SO" -o -name "*.$LIBEXT" -o -name "*.$LIB0") perl |
223 |
root |
1.7 |
|
224 |
|
|
: >timidity.cfg |
225 |
root |
1.1 |
) |
226 |
|
|
|
227 |
root |
1.6 |
cat >"$DIST".vars <<EOF |
228 |
|
|
G_URLADER="$URLADER" |
229 |
|
|
G_OS="$OS" |
230 |
|
|
G_ARCHNAME="$ARCHNAME" |
231 |
|
|
G_ENVVARS="$GENPACK_ENVVARS" |
232 |
root |
1.7 |
G_COMMAND="./perl run" |
233 |
root |
1.6 |
EOF |
234 |
root |
1.1 |
|