This repository has been archived by the owner on Jan 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.sh
executable file
·570 lines (473 loc) · 14.3 KB
/
build.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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
#!/bin/bash
SOURCE=`dirname "$0"`/source
PWD=`pwd`
BUILD=$PWD/build
INSTALL=$PWD/install
export PATH="$INSTALL/bin:$PATH"
export LD_LIBRARY_PATH="$INSTALL/lib:/usr/local/lib"
export DYLIB_LIBRARY_PATH="$INSTALL/lib"
export DYLD_FRAMEWORK_PATH="$INSTALL/frameworks"
if python -c 'import sys; print sys.version; sys.exit(0)'; then
echo "Python works."
else
echo "Python could not be found. Please add the directory containing"
echo "the python program to your PATH."
exit 1
fi
# The xes are required to prevent msys from interpreting these as
# paths.
SOURCE=`python $SOURCE/norm_source.py "x$PWD" "x$SOURCE"`
CP='cp -pR'
echo
echo Source: $SOURCE
echo Build: $BUILD
echo Install: $INSTALL
echo
mkdir -p $BUILD
mkdir -p $INSTALL
# Unix debug
# export CFLAGS="$CFLAGS -ggdb -I$INSTALL/include -I$INSTALL/include/freetype2 -fPIC"
# export LDFLAGS="-ggdb -L$INSTALL/lib $LDFLAGS -fPIC"
# echo warning debug build; sleep 3
# Windows debug
# export CFLAGS="$CFLAGS -gstabs -I$INSTALL/include -I$INSTALL/include/freetype2 -I$INSTALL/include/SDL"
# export LDFLAGS="-gstabs -L$INSTALL/lib $LDFLAGS"
# echo warning debug build; sleep 3
# Production
export CFLAGS="$CFLAGS -O2 -I$INSTALL/include -I$INSTALL/include/freetype2 -I$INSTALL/include/SDL"
export LDFLAGS="-O2 -L$INSTALL/lib $LDFLAGS"
PLATFORM=linux
if [ "x$MSYSTEM" != "x" ]; then
export CFLAGS="$CFLAGS -fno-strict-aliasing "
PLATFORM="windows"
else
if [ `uname` = 'Darwin' ]; then
PLATFORM="mac"
fi
if [ `arch` = "x86_64" ]; then
export CFLAGS="-fPIC $CFLAGS"
export LDFLAGS="-fPIC $LDFLAGS"
fi
fi
export CPPFLAGS="$CFLAGS"
export CXXFLAGS="$CFLAGS"
OLD_CC="$CC"
OLD_LD="$LD"
OLD_CXX="$CXX"
OLD_CXXLD="$CXXLD"
OLD_CFLAGS="$CFLAGS"
OLD_CXXFLAGS="$CXXFLAGS"
OLD_LDFLAGS="$LDFLAGS"
OLD_CXXLDFLAGS="$CXXLDFLAGS"
export SED=sed
export RENPY_DEPS_INSTALL=$INSTALL
try () {
"$@" || exit 1
}
libtool() {
cp /usr/local/bin/libtool .
}
try mkdir -p "$INSTALL/lib"
rm -Rf "$INSTALL/lib64"
try ln -s "$INSTALL/lib" "$INSTALL/lib64"
cd $BUILD
cat <<EOF > ../env.sh
export RENPY_ORIGINAL_PATH="\$PATH"
export RENPY_ORIGINAL_PYTHONPATH="\$PYTHONPATH"
export RENPY_ORIGINAL_LD_LIBRARY_PATH="\$LD_LIBRARY_PATH"
export RENPY_ORIGINAL_DYLIB_LIBRARY_PATH="\$DYLIB_LIBRARY_PATH"
export RENPY_ORIGINAL_DYLD_FRAMEWORK_PATH="\$DYLD_FRAMEWORK_PATH"
export RENPY_DEPS_INSTALL="$INSTALL"
export PATH="$PATH"
export PYTHONPATH="$INSTALL/python"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
export DYLIB_LIBRARY_PATH="$DYLIB_LIBRARY_PATH"
export DYLD_FRAMEWORK_PATH="$DYLD_FRAMEWORK_PATH"
EOF
# try cp "$SOURCE/gcc_version.c" "$BUILD"
# try gcc -c "$BUILD/gcc_version.c"
if [ \! -e built.nasm ]; then
try tar xzf "$SOURCE/nasm-2.09.10.tar.gz"
try cd "$BUILD/nasm-2.09.10"
try ./configure --prefix="$INSTALL"
try make
try make install
cd "$BUILD"
try touch built.nasm
fi
if [ $PLATFORM != "windows" ]; then
if [ \! -e built.yasm ]; then
try tar xzf "$SOURCE/yasm-1.2.0.tar.gz"
try cd "$BUILD/yasm-1.2.0"
try ./configure --prefix="$INSTALL"
try make
try make install
cd "$BUILD"
try touch built.yasm
fi
else
# A source-built yasm doesn't seem to work on my computer. So
# use the prebuilt version.
try cp "$SOURCE/yasm-1.2.0-win32.exe" "$INSTALL/bin/yasm.exe"
fi
if [ \! -e built.sdl ]; then
# try mkdir -p "$INSTALL/include/asm"
# try touch "$INSTALL/include/asm/page.h"
try tar xzf "$SOURCE/SDL2-2.0.4.tar.gz"
try cd "$BUILD/SDL2-2.0.4"
try patch -p1 < "$SOURCE/sdl-renpy.diff"
if [ $PLATFORM = "mac" ]; then
SDL_EXTRA="--disable-video-x11"
else
SDL_EXTRA=""
fi
try ./configure --prefix="$INSTALL" --disable-dependency-tracking \
--disable-video-dummy \
--disable-video-directfb \
--disable-nas \
--disable-video-wayland \
$SDL_EXTRA $SDL_ASM
try make
try make install
cd "$BUILD"
touch built.sdl
fi
# This will be built shared on Linux and Mac by build_python, and
# on windows here.
if [ \! -e built.zlib ]; then
try tar xvzf "$SOURCE/zlib-1.2.6.tar.gz"
try cd "$BUILD/zlib-1.2.6"
if [ "x$MSYSTEM" != "x" ]; then
try make -f win32/Makefile.gcc
try make -f win32/Makefile.gcc install \
INCLUDE_PATH="$INSTALL/include" \
LIBRARY_PATH="$INSTALL/lib" \
BINARY_PATH="$INSTALL/bin" \
SHARED_MODE=1
else
try ./configure --prefix="$INSTALL"
try make
try make install
fi
cd "$BUILD"
touch built.zlib
fi
if [ \! -e built.freetype ]; then
try tar xjf "$SOURCE/freetype-2.4.11.tar.bz2"
try cd "$BUILD/freetype-2.4.11"
try patch -p1 < "$SOURCE/freetype-2.2.1-enable-valid.patch"
try ./configure --prefix="$INSTALL"
try make modules
try make
try make install prefix="$INSTALL"
cd "$BUILD"
touch built.freetype
fi
if [ \! -e built.sdl_ttf ]; then
try tar xvzf "$SOURCE/SDL2_ttf-2.0.12.tar.gz"
try cd "$BUILD/SDL2_ttf-2.0.12"
try ./configure --prefix="$INSTALL"
# try patch -p1 < "$SOURCE/no_freetype_internals.dpatch"
try make
try make install
cd "$BUILD"
touch built.sdl_ttf
fi
if [ \! -e built.jpegturbo ]; then
try tar xzf "$SOURCE/libjpeg-turbo-1.4.0.tar.gz"
try cd "$BUILD/libjpeg-turbo-1.4.0"
try ./configure --prefix="$INSTALL" $JPEG_ASM
try make
try make install
cd "$BUILD"
try touch built.jpegturbo
fi
if [ \! -e built.png ]; then
if [ $PLATFORM != "mac" ]; then
export CFLAGS="$CFLAGS -DPNG_NO_WRITE_tIME"
fi
try tar xvzf "$SOURCE/libpng-1.2.49.tar.gz"
try cd "$BUILD/libpng-1.2.49"
try ./configure --prefix="$INSTALL" --enable-shared --disable-static
try make
try make install
cd "$BUILD"
touch built.png
fi
if [ $PLATFORM = "windows" ]; then
try cp "$INSTALL/lib/libpng.dll.a" "$INSTALL/lib/libpng12.dll.a"
fi
if [ \! -e built.sdl2_image ]; then
export LIBS="-lz"
tar xzf "$SOURCE/SDL2_image-2.0.1.tar.gz" || true
try cd "$BUILD/SDL2_image-2.0.1"
try cd external/libwebp-0.3.0/
try ./configure --prefix="$INSTALL" --enable-static --disable-shared --disable-threading
try make
try make install
try cd ../..
try ./configure --prefix="$INSTALL" --disable-tif --disable-imageio --enable-shared --disable-static --disable-jpg-shared --disable-png-shared --enable-webp --disable-webp-shared --disable-xcf
try make
try make install
cd "$BUILD"
touch built.sdl2_image
fi
# if [ \! -e built.sdl_gfx ]; then
# try tar xvzf "$SOURCE/SDL2_gfx-1.0.1.tar.gz"
# try cd "$BUILD/SDL2_gfx-1.0.1"
# try ./configure --prefix="$INSTALL"
# try make
# try make install
# cd "$BUILD"
# touch built.sdl_gfx
# fi
if [ \! -e built.sdl_mixer ]; then
tar xzf "$SOURCE/SDL2_mixer-2.0.0.tar.gz"
try cd "$BUILD/SDL2_mixer-2.0.0"
try ./configure --prefix="$INSTALL"
try make
try make install
cd "$BUILD"
touch built.sdl_mixer
fi
#if [ \! -e built.pygame ]; then
#
# try mkdir -p "$INSTALL/lib/msvcr90"
#
# try tar xzf "$SOURCE/pygame-1.9.1release.tar.gz"
# try cd "$BUILD/pygame-1.9.1release"
#
# try cp "$SOURCE/pygame-setup.py" setup.py
# try python "$SOURCE/write_pygame_setup.py" "$INSTALL" > Setup
#
# if [ $PLATFORM = "windows" ]; then
# try python setup.py build --compiler=mingw32 install_lib -d "$INSTALL/python"
# try cp "$INSTALL/bin/"*.dll "$INSTALL/python/pygame"
# else
# try python setup.py build install_lib -d "$INSTALL/python"
# fi
#
# try cp lib/*.ico "$INSTALL/python/pygame"
# try cp lib/*.icns "$INSTALL/python/pygame"
# try cp lib/*.tiff "$INSTALL/python/pygame"
# try cp lib/*.ttf "$INSTALL/python/pygame"
# try cp lib/*.bmp "$INSTALL/python/pygame"
#
# try python setup.py install_headers -d "$INSTALL/include/pygame"
#
# cd "$BUILD"
# touch built.pygame
#fi
if [ $PLATFORM = "windows" ]; then
FFMPEG_FLAGS="--disable-pthreads --enable-w32threads"
FFMPEG_CFLAGS="-D__MINGW32__"
else
FFMPEG_FLAGS=--arch=`arch`
FFMPEG_CFLAGS="-D__MINGW32__"
fi
if [ \! -e built.ffmpeg ]; then
try tar xjf "$SOURCE/ffmpeg-3.0.tar.bz2"
try cd "$BUILD/ffmpeg-3.0"
# My windows libraries don't seem to export fstat. So use _fstat32
# instead.
# if [ $PLATFORM = "windows" ]; then
# try patch -p1 < "$SOURCE/libav-fstat.diff"
# fi
export CFLAGS="$CFLAGS -fno-common $FFMPEG_CFLAGS"
export CXXFLAGS="$CXXFLAGS -fno-common $FFMPEG_CFLAGS"
try ./configure --prefix="$INSTALL" \
--cc="${CC:-gcc}" \
$FFMPEG_FLAGS \
--enable-runtime-cpudetect \
--enable-shared \
--enable-avresample \
--disable-encoders \
--disable-muxers \
--disable-bzlib \
--disable-demuxers \
--enable-demuxer=au \
--enable-demuxer=avi \
--enable-demuxer=flac \
--enable-demuxer=m4v \
--enable-demuxer=matroska \
--enable-demuxer=mov \
--enable-demuxer=mp3 \
--enable-demuxer=mpegps \
--enable-demuxer=mpegts \
--enable-demuxer=mpegtsraw \
--enable-demuxer=mpegvideo \
--enable-demuxer=ogg \
--enable-demuxer=wav \
--disable-decoders \
--enable-decoder=flac \
--enable-decoder=mp2 \
--enable-decoder=mp3 \
--enable-decoder=mp3on4 \
--enable-decoder=mpeg1video \
--enable-decoder=mpeg2video \
--enable-decoder=mpegvideo \
--enable-decoder=msmpeg4v1 \
--enable-decoder=msmpeg4v2 \
--enable-decoder=msmpeg4v3 \
--enable-decoder=mpeg4 \
--enable-decoder=pcm_dvd \
--enable-decoder=pcm_s16be \
--enable-decoder=pcm_s16le \
--enable-decoder=pcm_s8 \
--enable-decoder=pcm_u16be \
--enable-decoder=pcm_u16le \
--enable-decoder=pcm_u8 \
--enable-decoder=theora \
--enable-decoder=vorbis \
--enable-decoder=opus \
--enable-decoder=vp3 \
--enable-decoder=vp8 \
--enable-decoder=vp9 \
--disable-parsers \
--enable-parser=mpegaudio \
--enable-parser=mpegvideo \
--enable-parser=mpeg4video \
--enable-parser=vp3 \
--enable-parser=vp8 \
--disable-protocols \
--disable-devices \
--disable-vdpau \
--disable-vda \
--disable-filters \
--disable-bsfs \
--disable-d3d11va \
--disable-dxva2 \
--disable-vaapi \
--disable-vda \
--disable-vdpau \
--disable-videotoolbox \
--disable-iconv
try make
try make install
try mkdir -p "$INSTALL/include/libswscale"
try cp libswscale/swscale.h "$INSTALL/include/libswscale"
cd "$BUILD"
touch built.ffmpeg
fi
CFLAGS="$OLD_CFLAGS"
CXXFLAGS="$OLD_CXXFLAGS"
# if [ -n "$RENPY_BUILD_ALT" ]; then
#
# mkdir -p "$BUILD/alt"
#
# if [ \! -e built.avalt ]; then
# try tar xzf "$SOURCE/libav-9.6.tar.gz" -C "$BUILD/alt"
# try cd "$BUILD/alt/libav-9.6"
#
# # My windows libraries don't seem to export fstat. So use _fstat32
# # instead.
# #try patch -p1 < "$SOURCE/ffmpeg-fstat.diff"
#
# # av_cold is also a problem on windows.
# export CFLAGS="$CFLAGS -fno-common -Dav_cold= $LIBAV_CFLAGS"
# export CXXFLAGS="$CXXFLAGS -fno-common -Dav_cold= $LIBAV_CFLAGS"
# MEM_ALIGN_HACK="--enable-memalign-hack"
#
# try ./configure --prefix="$INSTALL/alt" \
# --cc="${CC:-gcc}" \
# $FFMPEGFLAGS \
# $MEM_ALIGN_HACK \
# --enable-runtime-cpudetect \
# --enable-shared \
# --disable-encoders \
# --disable-muxers \
# --disable-bzlib \
# --disable-demuxers \
# --enable-demuxer=au \
# --enable-demuxer=avi \
# --enable-demuxer=flac \
# --enable-demuxer=matroska \
# --enable-demuxer=mov \
# --enable-demuxer=ogg \
# --enable-demuxer=wav \
# --enable-demuxer=webm \
# --disable-decoders \
# --enable-decoder=flac \
# --enable-decoder=pcm_dvd \
# --enable-decoder=pcm_s16be \
# --enable-decoder=pcm_s16le \
# --enable-decoder=pcm_s8 \
# --enable-decoder=pcm_u16be \
# --enable-decoder=pcm_u16le \
# --enable-decoder=pcm_u8 \
# --enable-decoder=theora \
# --enable-decoder=vorbis \
# --enable-decoder=vp3 \
# --enable-decoder=vp8 \
# --disable-parsers \
# --enable-parser=vp3 \
# --enable-parser=vp8 \
# --disable-protocols \
# --disable-devices \
# --disable-vdpau \
# --disable-filters \
# --disable-bsfs
#
# try make
# try make install
#
# # try mkdir -p "$INSTALL/include/libswscale"
# # try cp libswscale/swscale.h "$INSTALL/include/libswscale"
#
# cd "$BUILD"
# touch built.avalt
# fi
#
# fi
CFLAGS="$OLD_CFLAGS"
CXXFLAGS="$OLD_CXXFLAGS"
if [ \! -e built.fribidi ]; then
export CFLAGS="$CFLAGS -DFRIBIDI_CHUNK_SIZE=4080"
try tar xvzf "$SOURCE/fribidi-0.19.2.tar.gz"
try cd "$BUILD/fribidi-0.19.2"
try ./configure --prefix="$INSTALL" --enable-static --disable-shared
if [ "x$MSYSTEM" != "x" ]; then
try patch -p0 < "$SOURCE/fribidi-windows.diff"
try python "$SOURCE/replace.py" "lib bin doc" "lib doc" Makefile
echo Did patch.
fi
try make
try make install
cd "$BUILD"
touch built.fribidi
fi
export CC=${CC:=gcc}
export CXX=${CXX:=g++}
export LD=${LD:=gcc}
export CXXLD=${CXXLD:=g++}
if [ \! -e built.glew -a -z "$RASPBERRY_PI" ]; then
try tar xzf "$SOURCE/glew-1.7.0.tgz"
try cd "$BUILD/glew-1.7.0"
try make install OPT="$CFLAGS $LDFLAGS" CC="$CC" LD="$LD" GLEW_DEST=$INSTALL
cd "$BUILD"
touch built.glew
fi
if [ $PLATFORM != "windows" ] ; then
if [ \! -e built.zsync ] ; then
try tar xjf "$SOURCE/zsync-0.6.2.tar.bz2"
try cd "$BUILD/zsync-0.6.2"
try patch -p1 < "$SOURCE/zsync-no-isastty.diff"
try patch -p0 < "$SOURCE/zsync-compress-5.diff"
try "./configure" --prefix="$INSTALL"
try make
try make install
cd "$BUILD"
touch built.zsync
fi
fi
if [ $PLATFORM = "linux" -a \! -e built.patchelf ]; then
try tar xzf "$SOURCE/patchelf-0.9.tar.gz"
try cd "$BUILD/patchelf-0.9"
try "./configure" --prefix="$INSTALL"
try make
try make install
cd "$BUILD"
touch built.patchelf
fi
echo
cat ../env.sh