1 |
#!/bin/bash |
2 |
|
3 |
STRIP="strip" |
4 |
LIBEXT=so |
5 |
LIB0=so.? |
6 |
SO=so |
7 |
SYSLIB=/usr/lib |
8 |
MAKE=make |
9 |
ARCHNAME=x86 |
10 |
GENPACK_ENVVARS= |
11 |
|
12 |
umask 022 |
13 |
|
14 |
if [ "$(uname -s)" = CYGWIN_NT-5.0 ]; then |
15 |
. ~/.setenv |
16 |
|
17 |
OS=windows |
18 |
URLADER=.exe |
19 |
unset PANGO |
20 |
PERL=/c/perl/bin/perl |
21 |
MAKE=nmake |
22 |
SYSLIB=/c/gtk/bin |
23 |
LIBEXT=dll |
24 |
LIB0=dll |
25 |
SO=dll |
26 |
STRIP=":" # stripping the perl library kills it, and apparently, everythignis always stripped |
27 |
|
28 |
# fontconfig apparently ignores env vars and always looks at ./etc/fonts/fonts.conf, |
29 |
# but only if . isn't actually called bin or lib. hope for the best. |
30 |
GENPACK_ENVVARS="FONTCONFIG_PATH=pm/Deliantra/Client/private/resources/fonts FONTCONFIG_FILE=fonts.conf" |
31 |
|
32 |
pango-querymodules() { |
33 |
/c/gtk/bin/pango-querymodules # empty output usually |
34 |
} |
35 |
|
36 |
elif [ "$(uname -s)" = Darwin ]; then |
37 |
OS=darwin |
38 |
URLADER=-osx105 |
39 |
PANGO=1.6.0 |
40 |
PERL=/opt/local/bin/perl |
41 |
|
42 |
SYSLIB=/opt/local/lib |
43 |
LIB0=dylib |
44 |
SO=bundle |
45 |
STRIP="strip -x" |
46 |
elif [ $(arch) = i686 ]; then |
47 |
OS=linux |
48 |
URLADER=-x86 |
49 |
PANGO=1.5.0 |
50 |
PERL=/usr/bin/perl |
51 |
else |
52 |
OS=linux |
53 |
URLADER=-amd64 |
54 |
PANGO=1.5.0 |
55 |
PERL=/usr/bin/perl |
56 |
ARCHNAME=amd64 |
57 |
fi |
58 |
|
59 |
export DIST="$(pwd)/dist/$OS-$ARCHNAME" |
60 |
|
61 |
rm -rf "$DIST" |
62 |
mkdir -p "$DIST" |
63 |
|
64 |
#PERL=/opt/perl |
65 |
#PANGO=1.6.0 |
66 |
|
67 |
export EV_EVENTFD=0 |
68 |
export EV_INOTIFY=0 |
69 |
export EV_SIGNALFD=0 |
70 |
|
71 |
if false; then |
72 |
# for mod in common-sense AnyEvent EV JSON-XS Deliantra Compress-LZF BDB Guard CFPlus; do |
73 |
for mod in CFPlus; do |
74 |
( |
75 |
cd /root/src/$mod |
76 |
$PERL Makefile.PL </dev/null |
77 |
$MAKE clean |
78 |
$PERL Makefile.PL </dev/null |
79 |
$MAKE install || exit |
80 |
$MAKE clean |
81 |
) |
82 |
done |
83 |
fi |
84 |
|
85 |
cat <<EOF >"$DIST"/pango.rc |
86 |
[Pango] |
87 |
ModuleFiles = pango.modules |
88 |
EOF |
89 |
|
90 |
( |
91 |
exec 5>"$DIST"/pango.modules |
92 |
pango-querymodules | grep ^/ | while read lib rest; do |
93 |
base=$(basename "$lib") |
94 |
[ "$base" = pango-basic-x.$LIBEXT ] && continue |
95 |
cp -p "$lib" "$DIST"/. |
96 |
echo "$base $rest" >&5 |
97 |
done |
98 |
) |
99 |
|
100 |
############################################################################# |
101 |
|
102 |
IFS=" |
103 |
" # space tab nl cr - cr for windows |
104 |
eval $($PERL -V:sitebinexp -V:sitearchexp -V:sitelib -V:vendorarchexp -V:vendorlibexp -V:archlibexp -V:privlibexp) |
105 |
|
106 |
mkdir -p "$DIST"/pm/bin |
107 |
cp "$sitebinexp"/deliantra "$DIST"/pm/bin/ |
108 |
cp -p util/run "$DIST" |
109 |
|
110 |
( |
111 |
exec <util/modules.dep |
112 |
|
113 |
# while read type name; do |
114 |
# if [ "$type" = d ]; then |
115 |
# # not implemented |
116 |
# dir=$(echo "$name" | sed -e s%::%/%g) |
117 |
# for lib in "$sitearchexp" "$sitelib" "$vendorarchexp" "$vendorlibexp" "$archlibexp" "$privlibexp"; do |
118 |
# if [ -e "$lib/auto/$dir/.packlist" ]; then |
119 |
# cat "$lib/auto/$dir/.packlist" |
120 |
# fi |
121 |
# echo "x $lib $dir" |
122 |
# done |
123 |
# elif [ $type = m ]; then |
124 |
# : |
125 |
# else |
126 |
# echo "unknown type $type ($name)" |
127 |
# exit 1 |
128 |
# fi |
129 |
# done |
130 |
mkdir -p "$DIST"/pm |
131 |
|
132 |
export OSDIST="$DIST" |
133 |
[ "$OS" = windows ] && OSDIST=$(cygpath -w "$OSDIST") |
134 |
|
135 |
$PERL -e ' |
136 |
use Config; |
137 |
use File::Glob qw(:glob); |
138 |
use File::Copy; |
139 |
use File::Path; |
140 |
use File::Basename; |
141 |
|
142 |
my @path = do { |
143 |
my %seen; |
144 |
grep !$seen{$_}++, grep length, map $Config{$_}, qw( |
145 |
sitearchexp |
146 |
sitelib |
147 |
vendorarchexp |
148 |
vendorlibexp |
149 |
archlibexp |
150 |
privlibexp |
151 |
) |
152 |
}; |
153 |
|
154 |
while (<>) { |
155 |
s/\015?\012$//; |
156 |
next if /^(#|$)/; |
157 |
s/\.dynob$/.'$SO'/; |
158 |
|
159 |
my $found; |
160 |
for my $lib (@path) { |
161 |
chdir $lib || next; |
162 |
|
163 |
my @glob = File::Glob::bsd_glob $_, 0; # explicit 0 needed |
164 |
|
165 |
if (@glob) { |
166 |
++$found; |
167 |
|
168 |
for (@glob) { |
169 |
if (-d $_) { |
170 |
system "rsync", "-aR", $_, "$ENV{DIST}/pm/."; |
171 |
} else { |
172 |
File::Path::mkpath "$ENV{OSDIST}/pm/" . dirname $_; |
173 |
File::Copy::syscopy "$_", "$ENV{OSDIST}/pm/$_" |
174 |
or die "$ENV{OSDIST}/pm/$_: $!"; |
175 |
|
176 |
if (s/\.pm$//) { |
177 |
$auto = "auto/$_"; |
178 |
|
179 |
for my $glob ("*.'$SO'", "autosplit.ix", "*.al") { |
180 |
for (bsd_glob "$auto/$glob", 0) { |
181 |
File::Path::mkpath "$ENV{OSDIST}/pm/" . dirname $_; |
182 |
File::Copy::syscopy "$_", "$ENV{OSDIST}/pm/$_"; |
183 |
} |
184 |
} |
185 |
} |
186 |
} |
187 |
} |
188 |
|
189 |
last; |
190 |
} |
191 |
} |
192 |
|
193 |
warn "$_: not found\n" |
194 |
unless $found; |
195 |
} |
196 |
' |
197 |
) || exit |
198 |
|
199 |
############################################################################# |
200 |
|
201 |
if [ "$OS" = windows ]; then |
202 |
libdeps() { |
203 |
objdump -p "$1" | awk '/\tDLL Name:/ { print $3 }' | while read lib; do |
204 |
set -- $(type "$lib") |
205 |
case "$3" in |
206 |
/c/WINNT/* | /c/sdk/* ) |
207 |
;; |
208 |
* ) |
209 |
echo "$3" |
210 |
;; |
211 |
esac |
212 |
done |
213 |
} |
214 |
elif [ "$OS" = darwin ]; then |
215 |
libdeps() { |
216 |
otool -L "$1" | perl -ne 'print "$1\n" if m%^\s+(/opt\S+)%' |
217 |
} |
218 |
else |
219 |
libdeps() { |
220 |
ldd "$1" | perl -ne 'print "$1\n" if / => (\S+)/' |
221 |
} |
222 |
fi |
223 |
|
224 |
add_deps() { |
225 |
local so="$1" |
226 |
libdeps "$so" | while read path; do |
227 |
base="$(basename "$path")" |
228 |
if ! [ -e "$base" ]; then |
229 |
cp -p "$path" . |
230 |
chmod 755 "$base" |
231 |
add_deps "$base" |
232 |
fi |
233 |
done |
234 |
} |
235 |
|
236 |
( |
237 |
cd "$DIST" |
238 |
|
239 |
cp -p "$PERL" . |
240 |
|
241 |
if [ "$OS" = windows ]; then |
242 |
cp -p $SYSLIB/libvorbisfile-3.dll $SYSLIB/mikmod.dll $SYSLIB/libpng12-0.dll . |
243 |
cp /root/src/CFPlus/util/splash.bmp . |
244 |
chmod -R u+rwX pm/auto |
245 |
|
246 |
# convert perl to a non-console-app |
247 |
$PERL -MWin32::Exe -e '$e = new Win32::Exe"perl.exe"; $e->set_subsystem_windows; $e->write' |
248 |
|
249 |
else |
250 |
# patch braindamaged pango |
251 |
perl -pe 's{/u(?=sr/lib(32)?/pango)}{/\x00}g; s{\Q'$PANGO'\E\x00}{y.t.u\x00}g' <$SYSLIB/libpango-1.0.$LIB0 >libpango-1.0.$LIB0 |
252 |
chmod 755 libpango-1.0.$LIB0 |
253 |
|
254 |
for lib in mikmod vorbisfile; do |
255 |
cp -p $SYSLIB/lib$lib.$LIB0 . |
256 |
chmod 755 lib$lib.$LIB0 |
257 |
done |
258 |
fi |
259 |
|
260 |
for so in $(find . -name "*.$SO" -o -name "*.$LIBEXT" -o -name "*.$LIB0") perl; do |
261 |
add_deps "$so" |
262 |
done |
263 |
|
264 |
rm -f pm/auto/POSIX/*.al |
265 |
|
266 |
for lib in \ |
267 |
dl c m rt pthread nsl crypt \ |
268 |
X11 Xext Xau Xdmcp ICE SM Xrandr Xrender Xxf86vm drm GL \ |
269 |
z |
270 |
do |
271 |
rm -f lib"$lib".$SO0 |
272 |
done |
273 |
|
274 |
if [ "$OS" = darwin ]; then |
275 |
# "dll hell" is most severe on os x, because apple |
276 |
# does not generally give a shit for backwards compatibility, |
277 |
# alwayss ships outdated libraries and often provides libraries |
278 |
# of the same name as well-known libs (such as libjpeg), that |
279 |
# of course do something completely different |
280 |
patchlibs() { |
281 |
<"$1" \ |
282 |
perl -0777 -pe ' |
283 |
s%('"/opt/local/lib[^\x00]*/lib"'([^\x00/]+)\.dylib\x00)% |
284 |
my $s = $1; |
285 |
my $r = "libdeliantra-$2.dylib\x00"; |
286 |
(length $r) <= (length $s) |
287 |
or die "lib replacement <$r> larger than <$s>\n"; |
288 |
substr $s, 0, length $r, $r; |
289 |
$s |
290 |
%ge |
291 |
' \ |
292 |
>"$1~" && mv "$1~" "$1" || exit 67 |
293 |
} |
294 |
|
295 |
# patch bundles and pango modules with external dependencies, |
296 |
# should be few, so hardcode(tm) |
297 |
for so in \ |
298 |
pm/auto/BDB/BDB.bundle \ |
299 |
pm/auto/Deliantra/Client/Client.bundle \ |
300 |
*.$LIBEXT |
301 |
do |
302 |
patchlibs "$so" |
303 |
done |
304 |
|
305 |
# now patch and rename all .dylibs |
306 |
for lib in *.$LIB0; do |
307 |
stem="${lib#lib}" |
308 |
stem="${stem%.$LIB0}" |
309 |
patchlibs "$lib" |
310 |
mv "$lib" "libdeliantra-$stem.dylib" |
311 |
done |
312 |
fi |
313 |
|
314 |
[ "$OS" = linux ] && chrpath -d perl # debian perls have an rpath. really. |
315 |
$STRIP $(find . -name "*.$SO" -o -name "*.$LIBEXT" -o -name "*.$LIB0") perl |
316 |
) |
317 |
|
318 |
printf -- urlader$URLADER >"$DIST".urlader |
319 |
|
320 |
echo >"$DIST".genpack genpack deliantra_S-$OS-"$ARCHNAME" '"$EXE_VER"' '"$1"' $GENPACK_ENVVARS ./perl run |
321 |
|
322 |
exit |
323 |
|
324 |
|
325 |
tar cf deliantra-gnu-linux-$ARCHNAME.tar deliantra-gnu-linux-$ARCHNAME |
326 |
gzip -9vf deliantra-gnu-linux-$ARCHNAME.tar |
327 |
todata deliantra-gnu-linux-$ARCHNAME.tar.gz |
328 |
|