-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fretwork-deps.sh
411 lines (334 loc) · 8.01 KB
/
fretwork-deps.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
#!/bin/bash
#
# Constants
#
PREFIX=`pwd`/deps
HOST=$PLATFORM
COMMON_AUTOCONF_FLAGS="--prefix=${PREFIX} --host=${HOST} --disable-static --enable-shared CPPFLAGS=-I${PREFIX}/include LDFLAGS=-L${PREFIX}/lib"
CROSS_GCC=${PLATFORM}-gcc
#
# Path
#
export PATH="${PREFIX}/bin:${PATH}"
#
# Info
#
info()
{
message=$1
echo "[INFO] ${message}"
}
#
# Download
#
download()
{
url=$1
filename=`basename $1`
wget -q $filename $url
# copy urls
echo $1 >> ${PREFIX}/URLs
}
#
# Build the workspace
#
build_workspace()
{
info "Build the workspace"
mkdir -p $PREFIX
mkdir -p "${PREFIX}/bin" "${PREFIX}/lib" "${PREFIX}/include"
mkdir -p "${PREFIX}/lib/pkgconfig"
# pkg-config wrapper
cat >"${PREFIX}"/bin/pkg-config <<EOF
#!/bin/sh -e
exec env PKG_CONFIG_LIBDIR='$PREFIX'/lib/pkgconfig '`which pkg-config`' "\$@"
EOF
chmod -v 0755 "$PREFIX"/bin/pkg-config
}
#
# Build iconv
#
build_iconv()
{
iconv_version="0.0.8"
info "Build iconv ${iconv_version}"
# download
download https://github.com/win-iconv/win-iconv/archive/v${iconv_version}.tar.gz
tar zxf v${iconv_version}.tar.gz
# compile
cd win-iconv-${iconv_version}
make CC=$CROSS_GCC iconv.dll
# copy files
cp iconv.dll ${PREFIX}/bin
cp iconv.h ${PREFIX}/include
cp libiconv.dll.a "${PREFIX}"/lib
cd ..
}
#
# Build zlib
#
build_zlib()
{
zlib_version="1.2.11"
info "Build zlib ${zlib_version}"
# download
download http://www.zlib.net/zlib-${zlib_version}.tar.gz
tar zxf zlib-${zlib_version}.tar.gz
# compile
cd zlib-${zlib_version}
make -f win32/Makefile.gcc PREFIX="${PLATFORM}"- zlib1.dll
cp zlib.h zconf.h "${PREFIX}"/include
cp zlib1.dll "${PREFIX}"/bin
cp libz.dll.a "${PREFIX}"/lib
cd ..
}
#
# Build gettext
#
build_gettext()
{
gettext_version="0.18.3"
info "Build gettext ${gettext_version}"
# download
download http://ftp.gnu.org/gnu/gettext/gettext-${gettext_version}.tar.gz
tar zxf gettext-${gettext_version}.tar.gz
# compile
cd gettext-${gettext_version}/gettext-runtime
./configure $COMMON_AUTOCONF_FLAGS -disable-java --disable-csharp --enable-relocatable --disable-libasprintf
make
make install
cd ../..
}
#
# Build libffi
#
build_libffi()
{
libffi_version="3.0.12"
info "Build libffi ${libffi_version}"
# download
download ftp://sourceware.org/pub/libffi/libffi-${libffi_version}.tar.gz
tar zxf libffi-${libffi_version}.tar.gz
# compile
cd libffi-${libffi_version}
./configure $COMMON_AUTOCONF_FLAGS --enable-portable-binary
make
make install
cd ..
}
#
# Build GLib
#
build_glib()
{
#
# deps
#
build_gettext
build_libffi
#
# glib
#
# https://developer.gnome.org/glib/2.34/
glib_version="2.34.3"
info "Build GLib ${glib_version}"
# download
glib_name="glib-${glib_version}"
glib_url="http://ftp.gnome.org/pub/GNOME/sources/glib/${glib_version%.*}/${glib_name}.tar.xz"
download ${glib_url}
tar Jxf ${glib_name}.tar.xz
# compile
cd ${glib_name}
./configure $COMMON_AUTOCONF_FLAGS --disable-modular-tests
make -C glib
make -C gthread
make -C glib install
make -C gthread install
# copy files
cp -v glib-2.0.pc gthread-2.0.pc ${PREFIX}/lib/pkgconfig
cd ..
}
#
# Build pkg-config
#
build_pkgconfig()
{
pkgconfig_version="0.28"
info "Build pkg-config ${pkgconfig_version}"
# download
download http://pkgconfig.freedesktop.org/releases/pkg-config-${pkgconfig_version}.tar.gz
tar zxf pkg-config-${pkgconfig_version}.tar.gz
# compile
cd pkg-config-${pkgconfig_version}
./configure $COMMON_AUTOCONF_FLAGS
make
make install
cd ..
}
#
# Build libogg
#
build_libogg()
{
libogg_version="1.3.0"
info "Build libogg ${libogg_version}"
# download
download http://downloads.xiph.org/releases/ogg/libogg-${libogg_version}.tar.xz
tar Jxf libogg-${libogg_version}.tar.xz
# compile
cd libogg-${libogg_version}
./configure $COMMON_AUTOCONF_FLAGS
make
make install
cd ..
}
#
# Build libtheora
#
build_libtheora()
{
libtheora_version="1.2.0alpha1"
info "Build libtheora ${libtheora_version}"
# download
download http://downloads.xiph.org/releases/theora/libtheora-${libtheora_version}.tar.xz
tar Jxf libtheora-${libtheora_version}.tar.xz
# compile
cd libtheora-${libtheora_version}
# fix .def files of theora use CRLF line terminators, which makes the new
# binutils trigger a linker error:
# /usr/bin/i686-w64-mingw32-ld: .libs/libtheoradec-1.dll.def:3: syntax error
sed -i -e 's#\r##g' win32/xmingw32/libtheoradec-all.def
sed -i -e 's#\r##g' win32/xmingw32/libtheoraenc-all.def
# config, make, install
./configure $COMMON_AUTOCONF_FLAGS --disable-examples --without-vorbis --disable-oggtest --with-ogg-includes=${PREFIX}/include --with-ogg-libraries=${PREFIX}/lib
make
make install
cd ..
}
#
# Build libvorbis
#
build_libvorbis()
{
libvorbis_version="1.3.3"
info "Build libvorbis ${libvorbis_version}"
# download
download http://downloads.xiph.org/releases/vorbis/libvorbis-${libvorbis_version}.tar.xz
tar Jxf libvorbis-${libvorbis_version}.tar.xz
# compile
cd libvorbis-${libvorbis_version}
./configure $COMMON_AUTOCONF_FLAGS
make
make install
cd ..
}
#
# Build soundtouch
#
build_soundtouch()
{
soundtouch_version="1.7.1"
info "Build soundtouch ${soundtouch_version}"
# download
download http://www.surina.net/soundtouch/soundtouch-${soundtouch_version}.tar.gz
tar zxf soundtouch-${soundtouch_version}.tar.gz
# compile
cd soundtouch
./bootstrap
./configure $COMMON_AUTOCONF_FLAGS
make LDFLAGS=-no-undefined
make install
cd ..
}
#
# Build SDL
#
build_sdl()
{
sdl_version="1.2.15"
info "Build SDL ${sdl_version}"
# download
download http://www.libsdl.org/release/SDL-${sdl_version}.tar.gz
tar zxf SDL-${sdl_version}.tar.gz
# compile
cd SDL-${sdl_version}
./configure $COMMON_AUTOCONF_FLAGS
make
make install
# copy files
mv "${PREFIX}"/lib/libSDLmain.a "${PREFIX}"/lib/SDLmain.lib
rm -f "${PREFIX}"/lib/libSDLmain.la
cp include/SDL_config_win32.h "${PREFIX}"/include/SDL/SDL_config.h
cd ..
}
#
# Build SDL Mixer
#
build_sdl_mixer()
{
# deps
build_sdl
sdl_mixer_version="1.2.12"
info "Build SDL Mixer ${sdl_mixer_version}"
# download
download http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-${sdl_mixer_version}.tar.gz
tar zxf SDL_mixer-${sdl_mixer_version}.tar.gz
# compile
cd SDL_mixer-${sdl_mixer_version}
./configure $COMMON_AUTOCONF_FLAGS --disable-music-mod --disable-music-midi --disable-music-mp3
make
make install
cd ..
}
#
# Package all deps
#
package_dist()
{
info "Package deps"
# copy deps into dist
mkdir -p dist
cp -a deps dist
ls -l dist/deps
# remove unecessary files (except bin and lib)
info "Remove doc and share"
rm -rf dist/deps/{doc,share}
# remove libtool libs, .def files and unecessary scripts
info "Remove libtool and def files"
ls -l dist/deps/lib/{*.la,*.def}
rm -rf dist/deps/lib/{*.la,*.def}
# generate .def files
python2 makedefs.py dist/deps/lib dist/deps/bin "${PLATFORM}-dlltool -I"
# strip binaries and libs
${PLATFORM}-strip --strip-all dist/deps/bin/*.exe dist/deps/bin/*.dll
${PLATFORM}-strip --strip-debug dist/deps/lib/*.lib dist/deps/lib/*.a
# make a README
cat readme.template dist/deps/URLs > dist/README.md
rm -rf dist/deps/URLs
# create the tarball
cd dist
tarball="fretwork-${WIN}-deppack-`date +%Y%m%d`.tar.gz"
tar zcf ../${tarball} *
cd ..
# Copy the tarball to out
mkdir -p out
cp ${tarball} out/
}
#
# Main
#
main()
{
build_workspace
build_iconv
build_zlib
build_glib
build_pkgconfig
build_libogg
build_libtheora
build_libvorbis
build soundtouch
build_sdl_mixer
package_dist
}
#main