-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
1265 lines (1066 loc) · 35.1 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
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# MIT License
#
# Copyright (c) 2017-2018 Maxim Biro <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Known issues:
# - Doesn't build qTox updater, because it wasn't ported to cmake yet and
# because it requires static Qt, which means we'd need to build Qt twice, and
# building Qt takes really long time.
set -euo pipefail
# Common directory paths
readonly WORKSPACE_DIR="/workspace"
readonly QTOX_SRC_DIR="/qtox"
# Make sure we run in an expected environment
if [ ! -f /etc/os-release ] || ! cat /etc/os-release | grep -qi 'stretch'
then
echo "Error: This script should be run on Debian Stretch."
exit 1
fi
if [ ! -d "$WORKSPACE_DIR" ] || [ ! -d "$QTOX_SRC_DIR" ]
then
echo "Error: At least one of $WORKSPACE_DIR or $QTOX_SRC_DIR directories is missing."
exit 1
fi
if [ ! -d "$QTOX_SRC_DIR/src" ]
then
echo "Error: $QTOX_SRC_DIR/src directory is missing, make sure $QTOX_SRC_DIR contains qTox source code."
exit 1
fi
if [[ "$(id -u)" != "0" ]]
then
echo "Error: This script must be run as root."
exit 1
fi
# Check arguments
readonly ARCH=$1
readonly BUILD_TYPE=$2
if [ -z "$ARCH" ]
then
echo "Error: No architecture was specified. Please specify either 'i686' or 'x86_64', case sensitive, as the first argument to the script."
exit 1
fi
if [[ "$ARCH" != "i686" ]] && [[ "$ARCH" != "x86_64" ]]
then
echo "Error: Incorrect architecture was specified. Please specify either 'i686' or 'x86_64', case sensitive, as the first argument to the script."
exit 1
fi
if [ -z "$BUILD_TYPE" ]
then
echo "Error: No build type was specified. Please specify either 'release' or 'debug', case sensitive, as the second argument to the script."
exit 1
fi
if [[ "$BUILD_TYPE" != "release" ]] && [[ "$BUILD_TYPE" != "debug" ]]
then
echo "Error: Incorrect build type was specified. Please specify either 'release' or 'debug', case sensitive, as the second argument to the script."
exit 1
fi
# More directory variables
readonly BUILD_DIR="/build"
readonly DEP_DIR="$WORKSPACE_DIR/$ARCH/dep-cache"
readonly APT_CACHE_DIR="$WORKSPACE_DIR/$ARCH/apt_cache"
# Create the expected directory structure
# Just make sure those exist
mkdir -p "$WORKSPACE_DIR"
mkdir -p "$DEP_DIR"
mkdir -p "$APT_CACHE_DIR"
# Build dir should be empty
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
set -x
echo "Restoring package cache"
# ensure at least one file exists
touch "$APT_CACHE_DIR"/dummy
# restore apt cache
cp -r "$APT_CACHE_DIR"/* /var/cache/
# remove docker specific config file, this file prevents usage of the package cache
rm -f /etc/apt/apt.conf.d/docker-clean
readonly WGET_OPTIONS="--timeout=10"
# Get packages
apt-get update
apt-get install -y --no-install-recommends \
autoconf \
automake \
build-essential \
bsdtar \
ca-certificates \
cmake \
git \
libtool \
pkg-config \
tclsh \
unzip \
wget \
yasm \
zip
if [[ "$ARCH" == "i686" ]]
then
apt-get install -y --no-install-recommends \
g++-mingw-w64-i686 \
gcc-mingw-w64-i686
elif [[ "$ARCH" == "x86_64" ]]
then
apt-get install -y --no-install-recommends \
g++-mingw-w64-x86-64 \
gcc-mingw-w64-x86-64
fi
# Install wine to run qTox tests in
set +u
if [[ "$TRAVIS_CI_STAGE" == "stage3" ]]
then
dpkg --add-architecture i386
apt-get update
apt-get install -y wine wine32 wine64
fi
set -u
# Use all cores for building
MAKEFLAGS=j$(nproc)
export MAKEFLAGS
# Helper functions
# We check sha256 of all tarballs we download
check_sha256()
{
if ! ( echo "$1 $2" | sha256sum -c --status - )
then
echo "Error: sha256 of $2 doesn't match the known one."
echo "Expected: $1 $2"
echo -n "Got: "
sha256sum "$2"
exit 1
else
echo "sha256 matches the expected one: $1"
fi
}
# If it's not a tarball but a git repo, let's check a hash of a file containing hashes of all files
check_sha256_git()
{
# There shoudl be .git directory
if [ ! -d ".git" ]
then
echo "Error: this function should be called in the root of a git repository."
exit 1
fi
# Create a file listing hashes of all the files except .git/*
find . -type f | grep -v "^./.git" | LC_COLLATE=C sort --stable --ignore-case | xargs sha256sum > /tmp/hashes.sha
check_sha256 "$1" "/tmp/hashes.sha"
}
# Strip binaries to reduce file size, we don't need this information anyway
strip_all()
{
set +e
for PREFIX_DIR in $DEP_DIR/*; do
strip --strip-unneeded $PREFIX_DIR/bin/*
$ARCH-w64-mingw32-strip --strip-unneeded $PREFIX_DIR/bin/*
$ARCH-w64-mingw32-strip --strip-unneeded $PREFIX_DIR/lib/*
done
set -e
}
# Store apt cache
store_apt_cache()
{
# prevent old packages from polluting the cache
apt-get autoclean
cp -r /var/cache/apt/ "$APT_CACHE_DIR"
}
# OpenSSL
OPENSSL_PREFIX_DIR="$DEP_DIR/libopenssl"
OPENSSL_VERSION=1.0.2s
# hash from https://www.openssl.org/source/
OPENSSL_HASH="cabd5c9492825ce5bd23f3c3aeed6a97f8142f606d893df216411f07d1abab96"
OPENSSL_FILENAME="openssl-$OPENSSL_VERSION.tar.gz"
if [ ! -f "$OPENSSL_PREFIX_DIR/done" ]
then
rm -rf "$OPENSSL_PREFIX_DIR"
mkdir -p "$OPENSSL_PREFIX_DIR"
wget $WGET_OPTIONS "https://www.openssl.org/source/$OPENSSL_FILENAME"
check_sha256 "$OPENSSL_HASH" "$OPENSSL_FILENAME"
bsdtar --no-same-owner --no-same-permissions -xf "$OPENSSL_FILENAME"
rm $OPENSSL_FILENAME
cd openssl*
CONFIGURE_OPTIONS="--prefix=$OPENSSL_PREFIX_DIR shared"
if [[ "$ARCH" == "x86_64" ]]
then
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS mingw64 --cross-compile-prefix=x86_64-w64-mingw32-"
elif [[ "$ARCH" == "i686" ]]
then
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS mingw --cross-compile-prefix=i686-w64-mingw32-"
fi
./Configure $CONFIGURE_OPTIONS
make
make install
echo -n $OPENSSL_VERSION > $OPENSSL_PREFIX_DIR/done
CONFIGURE_OPTIONS=""
cd ..
rm -rf ./openssl*
else
echo "Using cached build of OpenSSL `cat $OPENSSL_PREFIX_DIR/done`"
fi
# Qt
QT_PREFIX_DIR="$DEP_DIR/libqt5"
QT_MAJOR=5
QT_MINOR=9
QT_PATCH=8
QT_VERSION=$QT_MAJOR.$QT_MINOR.$QT_PATCH
# hash from https://download.qt.io/archive/qt/5.9/5.9.8/single/qt-everywhere-opensource-src-5.9.8.tar.xz.mirrorlist
QT_HASH="86aca7dc37f161fc730a9d4f6bddf684962ca560327682e282ff61bf8b859c36"
QT_FILENAME="qt-everywhere-opensource-src-$QT_VERSION.tar.xz"
if [ ! -f "$QT_PREFIX_DIR/done" ]
then
rm -rf "$QT_PREFIX_DIR"
mkdir -p "$QT_PREFIX_DIR"
wget $WGET_OPTIONS "https://download.qt.io/official_releases/qt/$QT_MAJOR.$QT_MINOR/$QT_VERSION/single/$QT_FILENAME"
check_sha256 "$QT_HASH" "$QT_FILENAME"
bsdtar --no-same-owner --no-same-permissions -xf $QT_FILENAME
rm $QT_FILENAME
cd qt*
export PKG_CONFIG_PATH="$OPENSSL_PREFIX_DIR/lib/pkgconfig"
export OPENSSL_LIBS="$(pkg-config --libs openssl)"
# So, apparently Travis CI terminates a build if it generates more than 4mb of stdout output
# which happens when building Qt
CONFIGURE_EXTRA=""
set +u
if [[ "$TRAVIS_CI_STAGE" == "stage1" ]]
then
CONFIGURE_EXTRA="-silent"
fi
set -u
./configure -prefix $QT_PREFIX_DIR \
-release \
-shared \
-device-option CROSS_COMPILE=$ARCH-w64-mingw32- \
-xplatform win32-g++ \
-openssl \
$(pkg-config --cflags openssl) \
-opensource -confirm-license \
-pch \
-nomake examples \
-nomake tools \
-nomake tests \
-skip 3d \
-skip activeqt \
-skip androidextras \
-skip canvas3d \
-skip charts \
-skip connectivity \
-skip datavis3d \
-skip declarative \
-skip doc \
-skip enginio \
-skip gamepad \
-skip graphicaleffects \
-skip imageformats \
-skip location \
-skip macextras \
-skip multimedia \
-skip networkauth \
-skip purchasing \
-skip quickcontrols \
-skip quickcontrols2 \
-skip remoteobjects \
-skip script \
-skip scxml \
-skip sensors \
-skip serialbus \
-skip serialport \
-skip speech \
-skip translations \
-skip virtualkeyboard \
-skip wayland \
-skip webchannel \
-skip webengine \
-skip websockets \
-skip webview \
-skip x11extras \
-skip xmlpatterns \
-no-dbus \
-no-icu \
-no-qml-debug \
-no-compile-examples \
-qt-libjpeg \
-qt-libpng \
-qt-zlib \
-qt-pcre \
-opengl desktop $CONFIGURE_EXTRA
make
make install
echo -n $QT_VERSION > $QT_PREFIX_DIR/done
unset PKG_CONFIG_PATH
unset OPENSSL_LIBS
cd ..
rm -rf ./qt*
else
echo "Using cached build of Qt `cat $QT_PREFIX_DIR/done`"
fi
# Stop here if running the first stage on Travis CI
set +u
if [[ "$TRAVIS_CI_STAGE" == "stage1" ]]
then
# Strip to reduce cache size
strip_all
store_apt_cache
# Chmod since everything is root:root
chmod 777 -R "$WORKSPACE_DIR"
exit 0
fi
set -u
# SQLCipher
SQLCIPHER_PREFIX_DIR="$DEP_DIR/libsqlcipher"
SQLCIPHER_VERSION=v4.2.0
SQLCIPHER_HASH="105c1b813f848da038c03647a8bfc9d42fb46865e6aaf4edfd46ff3b18cdccfc"
SQLCIPHER_FILENAME="$SQLCIPHER_VERSION.tar.gz"
if [ ! -f "$SQLCIPHER_PREFIX_DIR/done" ]
then
rm -rf "$SQLCIPHER_PREFIX_DIR"
mkdir -p "$SQLCIPHER_PREFIX_DIR"
wget $WGET_OPTIONS "https://github.com/sqlcipher/sqlcipher/archive/$SQLCIPHER_FILENAME"
check_sha256 "$SQLCIPHER_HASH" "$SQLCIPHER_FILENAME"
bsdtar --no-same-owner --no-same-permissions -xf "$SQLCIPHER_FILENAME"
rm $SQLCIPHER_FILENAME
cd sqlcipher*
sed -i s/'LIBS="-lcrypto $LIBS"'/'LIBS="-lcrypto -lgdi32 $LIBS"'/g configure
sed -i s/'LIBS="-lcrypto $LIBS"'/'LIBS="-lcrypto -lgdi32 $LIBS"'/g configure
sed -i s/'if test "$TARGET_EXEEXT" = ".exe"'/'if test ".exe" = ".exe"'/g configure
sed -i 's|exec $PWD/mksourceid manifest|exec $PWD/mksourceid.exe manifest|g' tool/mksqlite3h.tcl
# Do not remove trailing whitespace and dont replace tabs with spaces in the patch below,
# otherwise the patch will fail to apply
> Makefile.in-patch cat << "EOF"
--- Makefile.in 2017-07-24 04:33:46.944080013 +0000
+++ Makefile.in-patch 2017-07-24 04:50:47.340596990 +0000
@@ -1074,7 +1074,7 @@
$(TOP)/ext/fts5/fts5_varint.c \
$(TOP)/ext/fts5/fts5_vocab.c \
-fts5parse.c: $(TOP)/ext/fts5/fts5parse.y lemon
+fts5parse.c: $(TOP)/ext/fts5/fts5parse.y lemon$(BEXE)
cp $(TOP)/ext/fts5/fts5parse.y .
rm -f fts5parse.h
./lemon$(BEXE) $(OPTS) fts5parse.y
EOF
patch -l < Makefile.in-patch
./configure --host="$ARCH-w64-mingw32" \
--prefix="$SQLCIPHER_PREFIX_DIR" \
--disable-shared \
--enable-tempstore=yes \
CFLAGS="-O2 -g0 -DSQLITE_HAS_CODEC -I$OPENSSL_PREFIX_DIR/include/" \
LDFLAGS="$OPENSSL_PREFIX_DIR/lib/libcrypto.a -lcrypto -lgdi32 -L$OPENSSL_PREFIX_DIR/lib/"
sed -i s/"TEXE = $"/"TEXE = .exe"/ Makefile
make
make install
echo -n $SQLCIPHER_VERSION > $SQLCIPHER_PREFIX_DIR/done
cd ..
rm -rf ./sqlcipher*
else
echo "Using cached build of SQLCipher `cat $SQLCIPHER_PREFIX_DIR/done`"
fi
# FFmpeg
FFMPEG_PREFIX_DIR="$DEP_DIR/libffmpeg"
FFMPEG_VERSION=4.1.3
FFMPEG_HASH="0c3020452880581a8face91595b239198078645e7d7184273b8bcc7758beb63d"
FFMPEG_FILENAME="ffmpeg-$FFMPEG_VERSION.tar.xz"
if [ ! -f "$FFMPEG_PREFIX_DIR/done" ]
then
rm -rf "$FFMPEG_PREFIX_DIR"
mkdir -p "$FFMPEG_PREFIX_DIR"
wget $WGET_OPTIONS "https://www.ffmpeg.org/releases/$FFMPEG_FILENAME"
check_sha256 "$FFMPEG_HASH" "$FFMPEG_FILENAME"
bsdtar --no-same-owner --no-same-permissions -xf $FFMPEG_FILENAME
rm $FFMPEG_FILENAME
cd ffmpeg*
if [[ "$ARCH" == "x86_64"* ]]
then
CONFIGURE_OPTIONS="--arch=x86_64"
elif [[ "$ARCH" == "i686" ]]
then
CONFIGURE_OPTIONS="--arch=x86"
fi
./configure $CONFIGURE_OPTIONS \
--enable-gpl \
--prefix="$FFMPEG_PREFIX_DIR" \
--target-os="mingw32" \
--cross-prefix="$ARCH-w64-mingw32-" \
--pkg-config="pkg-config" \
--extra-cflags="-static -O2 -g0" \
--extra-ldflags="-lm -static" \
--pkg-config-flags="--static" \
--disable-debug \
--disable-shared \
--disable-programs \
--disable-protocols \
--disable-doc \
--disable-sdl2 \
--disable-avfilter \
--disable-avresample \
--disable-filters \
--disable-iconv \
--disable-network \
--disable-muxers \
--disable-postproc \
--disable-swresample \
--disable-swscale-alpha \
--disable-dct \
--disable-dwt \
--disable-lsp \
--disable-lzo \
--disable-mdct \
--disable-rdft \
--disable-fft \
--disable-faan \
--disable-vaapi \
--disable-vdpau \
--disable-zlib \
--disable-xlib \
--disable-bzlib \
--disable-lzma \
--disable-encoders \
--disable-decoders \
--disable-demuxers \
--disable-parsers \
--disable-bsfs \
--enable-demuxer=h264 \
--enable-demuxer=mjpeg \
--enable-parser=h264 \
--enable-parser=mjpeg \
--enable-decoder=h264 \
--enable-decoder=mjpeg \
--enable-decoder=rawvideo
make
make install
echo -n $FFMPEG_VERSION > $FFMPEG_PREFIX_DIR/done
CONFIGURE_OPTIONS=""
cd ..
rm -rf ./ffmpeg*
else
echo "Using cached build of FFmpeg `cat $FFMPEG_PREFIX_DIR/done`"
fi
# Openal-soft (irungentoo's fork)
OPENAL_PREFIX_DIR="$DEP_DIR/libopenal"
OPENAL_VERSION=b80570bed017de60b67c6452264c634085c3b148
OPENAL_HASH="734ef00895a9c1eb1505c11d638030b73593376df75da66ac5db6aa3e2f76807"
if [ ! -f "$OPENAL_PREFIX_DIR/done" ]
then
rm -rf "$OPENAL_PREFIX_DIR"
mkdir -p "$OPENAL_PREFIX_DIR"
git clone https://github.com/irungentoo/openal-soft-tox openal-soft-tox
cd openal*
git checkout $OPENAL_VERSION
check_sha256_git "$OPENAL_HASH"
mkdir -p build
cd build
echo "
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_C_COMPILER $ARCH-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER $ARCH-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER $ARCH-w64-mingw32-windres)
SET(CMAKE_FIND_ROOT_PATH /usr/$ARCH-w64-mingw32)
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
" > toolchain.cmake
CFLAGS="-fPIC" cmake -DCMAKE_INSTALL_PREFIX="$OPENAL_PREFIX_DIR" \
-DCMAKE_BUILD_TYPE=Release \
-DALSOFT_UTILS=OFF \
-DALSOFT_EXAMPLES=OFF \
-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
-DDSOUND_INCLUDE_DIR=/usr/$ARCH-w64-mingw32/include \
-DDSOUND_LIBRARY=/usr/$ARCH-w64-mingw32/lib/libdsound.a \
..
make
make install
echo -n $OPENAL_VERSION > $OPENAL_PREFIX_DIR/done
cd ..
cd ..
rm -rf ./openal*
else
echo "Using cached build of irungentoo's OpenAL-Soft fork `cat $OPENAL_PREFIX_DIR/done`"
fi
# Filteraudio
FILTERAUDIO_PREFIX_DIR="$DEP_DIR/libfilteraudio"
FILTERAUDIO_VERSION=ada2f4fdc04940cdeee47caffe43add4fa017096
FILTERAUDIO_HASH="cf481e87c860aaf28b50d125195d84556f36d0ebb529d7ebdac39f8cc497256a"
if [ ! -f "$FILTERAUDIO_PREFIX_DIR/done" ]
then
rm -rf "$FILTERAUDIO_PREFIX_DIR"
mkdir -p "$FILTERAUDIO_PREFIX_DIR"
git clone https://github.com/irungentoo/filter_audio filter_audio
cd filter*
git checkout $FILTERAUDIO_VERSION
check_sha256_git "$FILTERAUDIO_HASH"
$ARCH-w64-mingw32-gcc -O2 -g0 -c \
aec/aec_core.c \
aec/aec_core_sse2.c \
aec/aec_rdft.c \
aec/aec_rdft_sse2.c \
aec/aec_resampler.c \
aec/echo_cancellation.c \
agc/analog_agc.c \
agc/digital_agc.c \
ns/ns_core.c \
ns/nsx_core_c.c \
ns/nsx_core.c \
ns/noise_suppression_x.c \
ns/noise_suppression.c \
other/get_scaling_square.c \
other/resample_by_2.c \
other/spl_sqrt.c \
other/delay_estimator.c \
other/complex_bit_reverse.c \
other/dot_product_with_scale.c \
other/cross_correlation.c \
other/min_max_operations.c \
other/resample_48khz.c \
other/high_pass_filter.c \
other/energy.c \
other/randomization_functions.c \
other/speex_resampler.c \
other/copy_set_operations.c \
other/downsample_fast.c \
other/complex_fft.c \
other/vector_scaling_operations.c \
other/resample_by_2_internal.c \
other/delay_estimator_wrapper.c \
other/real_fft.c \
other/spl_sqrt_floor.c \
other/resample_fractional.c \
other/ring_buffer.c \
other/splitting_filter.c \
other/fft4g.c \
other/division_operations.c \
other/spl_init.c \
other/float_util.c \
zam/filters.c \
vad/vad_sp.c \
vad/vad_core.c \
vad/webrtc_vad.c \
vad/vad_gmm.c \
vad/vad_filterbank.c \
filter_audio.c \
-lpthread \
-lm
ar rcs libfilteraudio.a \
aec_core.o \
aec_core_sse2.o \
aec_rdft.o \
aec_rdft_sse2.o \
aec_resampler.o \
echo_cancellation.o \
analog_agc.o \
digital_agc.o \
ns_core.o \
nsx_core_c.o \
nsx_core.o \
noise_suppression_x.o \
noise_suppression.o \
get_scaling_square.o \
resample_by_2.o \
spl_sqrt.o \
delay_estimator.o \
complex_bit_reverse.o \
dot_product_with_scale.o \
cross_correlation.o \
min_max_operations.o \
resample_48khz.o \
high_pass_filter.o \
energy.o \
randomization_functions.o \
speex_resampler.o \
copy_set_operations.o \
downsample_fast.o \
complex_fft.o \
vector_scaling_operations.o \
resample_by_2_internal.o \
delay_estimator_wrapper.o \
real_fft.o \
spl_sqrt_floor.o \
resample_fractional.o \
ring_buffer.o \
splitting_filter.o \
fft4g.o \
division_operations.o \
spl_init.o \
float_util.o \
filters.o \
vad_sp.o \
vad_core.o \
webrtc_vad.o \
vad_gmm.o \
vad_filterbank.o \
filter_audio.o
mkdir $FILTERAUDIO_PREFIX_DIR/include
mkdir $FILTERAUDIO_PREFIX_DIR/lib
cp filter_audio.h $FILTERAUDIO_PREFIX_DIR/include
cp libfilteraudio.a $FILTERAUDIO_PREFIX_DIR/lib
echo -n $FILTERAUDIO_VERSION > $FILTERAUDIO_PREFIX_DIR/done
cd ..
rm -rf ./filter*
else
echo "Using cached build of Filteraudio `cat $FILTERAUDIO_PREFIX_DIR/done`"
fi
# QREncode
QRENCODE_PREFIX_DIR="$DEP_DIR/libqrencode"
QRENCODE_VERSION=4.0.2
QRENCODE_HASH="c9cb278d3b28dcc36b8d09e8cad51c0eca754eb004cb0247d4703cb4472b58b4"
QRENCODE_FILENAME="qrencode-$QRENCODE_VERSION.tar.bz2"
if [ ! -f "$QRENCODE_PREFIX_DIR/done" ]
then
rm -rf "$QRENCODE_PREFIX_DIR"
mkdir -p "$QRENCODE_PREFIX_DIR"
wget $WGET_OPTIONS https://fukuchi.org/works/qrencode/$QRENCODE_FILENAME
check_sha256 "$QRENCODE_HASH" "$QRENCODE_FILENAME"
bsdtar --no-same-owner --no-same-permissions -xf "$QRENCODE_FILENAME"
rm $QRENCODE_FILENAME
cd qrencode*
CFLAGS="-O2 -g0" ./configure --host="$ARCH-w64-mingw32" \
--prefix="$QRENCODE_PREFIX_DIR" \
--disable-shared \
--enable-static \
--disable-sdltest \
--without-tools \
--without-debug
make
make install
echo -n $QRENCODE_VERSION > $QRENCODE_PREFIX_DIR/done
cd ..
rm -rf ./qrencode*
else
echo "Using cached build of QREncode `cat $QRENCODE_PREFIX_DIR/done`"
fi
# Exif
EXIF_PREFIX_DIR="$DEP_DIR/libexif"
EXIF_VERSION=0.6.21
EXIF_HASH="16cdaeb62eb3e6dfab2435f7d7bccd2f37438d21c5218ec4e58efa9157d4d41a"
EXIF_FILENAME=libexif-$EXIF_VERSION.tar.bz2
if [ ! -f "$EXIF_PREFIX_DIR/done" ]
then
rm -rf "$EXIF_PREFIX_DIR"
mkdir -p "$EXIF_PREFIX_DIR"
wget $WGET_OPTIONS https://sourceforge.net/projects/libexif/files/libexif/$EXIF_VERSION/$EXIF_FILENAME
check_sha256 "$EXIF_HASH" "$EXIF_FILENAME"
bsdtar --no-same-owner --no-same-permissions -xf $EXIF_FILENAME
rm $EXIF_FILENAME
cd libexif*
CFLAGS="-O2 -g0" ./configure --host="$ARCH-w64-mingw32" \
--prefix="$EXIF_PREFIX_DIR" \
--disable-shared \
--enable-static \
--disable-docs \
--disable-nls
make
make install
echo -n $EXIF_VERSION > $EXIF_PREFIX_DIR/done
cd ..
rm -rf ./libexif*
else
echo "Using cached build of Exif `cat $EXIF_PREFIX_DIR/done`"
fi
# Opus
OPUS_PREFIX_DIR="$DEP_DIR/libopus"
OPUS_VERSION=1.3.1
# https://archive.mozilla.org/pub/opus/SHA256SUMS.txt
OPUS_HASH="65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d"
OPUS_FILENAME="opus-$OPUS_VERSION.tar.gz"
if [ ! -f "$OPUS_PREFIX_DIR/done" ]
then
rm -rf "$OPUS_PREFIX_DIR"
mkdir -p "$OPUS_PREFIX_DIR"
wget $WGET_OPTIONS "https://archive.mozilla.org/pub/opus/$OPUS_FILENAME"
check_sha256 "$OPUS_HASH" "$OPUS_FILENAME"
bsdtar --no-same-owner --no-same-permissions -xf "$OPUS_FILENAME"
rm $OPUS_FILENAME
cd opus*
CFLAGS="-O2 -g0" ./configure --host="$ARCH-w64-mingw32" \
--prefix="$OPUS_PREFIX_DIR" \
--disable-shared \
--enable-static \
--disable-extra-programs \
--disable-doc
make
make install
echo -n $OPUS_VERSION > $OPUS_PREFIX_DIR/done
cd ..
rm -rf ./opus*
else
echo "Using cached build of Opus `cat $OPUS_PREFIX_DIR/done`"
fi
# Sodium
SODIUM_PREFIX_DIR="$DEP_DIR/libsodium"
SODIUM_VERSION=1.0.18
SODIUM_HASH="6f504490b342a4f8a4c4a02fc9b866cbef8622d5df4e5452b46be121e46636c1"
SODIUM_FILENAME="libsodium-$SODIUM_VERSION.tar.gz"
if [ ! -f "$SODIUM_PREFIX_DIR/done" ]
then
rm -rf "$SODIUM_PREFIX_DIR"
mkdir -p "$SODIUM_PREFIX_DIR"
wget $WGET_OPTIONS "https://download.libsodium.org/libsodium/releases/$SODIUM_FILENAME"
check_sha256 "$SODIUM_HASH" "$SODIUM_FILENAME"
bsdtar --no-same-owner --no-same-permissions -xf "$SODIUM_FILENAME"
rm "$SODIUM_FILENAME"
cd libsodium*
./configure --host="$ARCH-w64-mingw32" \
--prefix="$SODIUM_PREFIX_DIR" \
--disable-shared \
--enable-static \
--with-pic
make
make install
echo -n $SODIUM_VERSION > $SODIUM_PREFIX_DIR/done
cd ..
rm -rf ./libsodium*
else
echo "Using cached build of Sodium `cat $SODIUM_PREFIX_DIR/done`"
fi
# VPX
VPX_PREFIX_DIR="$DEP_DIR/libvpx"
VPX_VERSION=v1.8.0
VPX_HASH="86df18c694e1c06cc8f83d2d816e9270747a0ce6abe316e93a4f4095689373f6"
VPX_FILENAME="libvpx-$VPX_VERSION.tar.gz"
if [ ! -f "$VPX_PREFIX_DIR/done" ]
then
rm -rf "$VPX_PREFIX_DIR"
mkdir -p "$VPX_PREFIX_DIR"
wget $WGET_OPTIONS https://github.com/webmproject/libvpx/archive/$VPX_VERSION.tar.gz -O $VPX_FILENAME
check_sha256 "$VPX_HASH" "$VPX_FILENAME"
bsdtar --no-same-owner --no-same-permissions -xf "$VPX_FILENAME"
rm $VPX_FILENAME
cd libvpx*
if [[ "$ARCH" == "x86_64" ]]
then
VPX_TARGET=x86_64-win64-gcc
elif [[ "$ARCH" == "i686" ]]
then
VPX_TARGET=x86-win32-gcc
fi
CROSS="$ARCH-w64-mingw32-" ./configure --target="$VPX_TARGET" \
--prefix="$VPX_PREFIX_DIR" \
--disable-shared \
--enable-static \
--disable-examples \
--disable-tools \
--disable-docs \
--disable-unit-tests
make
make install
echo -n $VPX_VERSION > $VPX_PREFIX_DIR/done
cd ..
rm -rf ./libvpx*
else
echo "Using cached build of VPX `cat $VPX_PREFIX_DIR/done`"
fi
# Toxcore
TOXCORE_PREFIX_DIR="$DEP_DIR/libtoxcore"
TOXCORE_VERSION=0.2.10
TOXCORE_HASH="5ccc4ecd79b95c367efe8341b06bf2a81f853032e6fcd7cb2bc0ad0ef7419d40"
TOXCORE_FILENAME="c-toxcore-$TOXCORE_VERSION.tar.gz"
if [ ! -f "$TOXCORE_PREFIX_DIR/done" ]
then
rm -rf "$TOXCORE_PREFIX_DIR"
mkdir -p "$TOXCORE_PREFIX_DIR"
wget $WGET_OPTIONS https://github.com/TokTok/c-toxcore/archive/v$TOXCORE_VERSION.tar.gz -O $TOXCORE_FILENAME
check_sha256 "$TOXCORE_HASH" "$TOXCORE_FILENAME"
bsdtar --no-same-owner --no-same-permissions -xf "$TOXCORE_FILENAME"
rm "$TOXCORE_FILENAME"
cd c-toxcore*
mkdir -p build
cd build
export PKG_CONFIG_PATH="$OPUS_PREFIX_DIR/lib/pkgconfig:$SODIUM_PREFIX_DIR/lib/pkgconfig:$VPX_PREFIX_DIR/lib/pkgconfig"
export PKG_CONFIG_LIBDIR="/usr/$ARCH-w64-mingw32"
echo "
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_C_COMPILER $ARCH-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER $ARCH-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER $ARCH-w64-mingw32-windres)
SET(CMAKE_FIND_ROOT_PATH /usr/$ARCH-w64-mingw32 $OPUS_PREFIX_DIR $SODIUM_PREFIX_DIR $VPX_PREFIX_DIR)
" > toolchain.cmake
cmake -DCMAKE_INSTALL_PREFIX=$TOXCORE_PREFIX_DIR \
-DBOOTSTRAP_DAEMON=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_STATIC=ON \
-DENABLE_SHARED=OFF \
-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
..
make
make install
echo -n $TOXCORE_VERSION > $TOXCORE_PREFIX_DIR/done
unset PKG_CONFIG_PATH
unset PKG_CONFIG_LIBDIR
cd ..
cd ..
rm -rf ./c-toxcore*
else
echo "Using cached build of Toxcore `cat $TOXCORE_PREFIX_DIR/done`"
fi
# mingw-w64-debug-scripts
MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR="$DEP_DIR/mingw-w64-debug-scripts"
MINGW_W64_DEBUG_SCRIPTS_VERSION=7341e1ffdea352e5557f3fcae51569f13e1ef270
MINGW_W64_DEBUG_SCRIPTS_HASH="a92883ddfe83780818347fda4ac07bce61df9226818df2f52fe4398fe733e204"
if [ ! -f "$MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/done" ]
then
rm -rf "$MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR"
mkdir -p "$MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR"
# Get dbg executable and the debug scripts
git clone https://github.com/nurupo/mingw-w64-debug-scripts mingw-w64-debug-scripts
cd mingw-w64-debug-scripts
git checkout $MINGW_W64_DEBUG_SCRIPTS_VERSION
check_sha256_git "$MINGW_W64_DEBUG_SCRIPTS_HASH"
make $ARCH EXE_NAME=qtox.exe
mkdir -p "$MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/bin"
mv output/$ARCH/* "$MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/bin/"
echo -n $MINGW_W64_DEBUG_SCRIPTS_VERSION > $MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/done
cd ..
rm -rf ./mingw-w64-debug-scripts
else
echo "Using cached build of mingw-w64-debug-scripts `cat $MINGW_W64_DEBUG_SCRIPTS_PREFIX_DIR/done`"
fi
# NSIS
NSIS_PREFIX_DIR="$DEP_DIR/nsis"
NSIS_VERSION="Debian Unstable"
#NSIS_HASH=
if [ ! -f "$NSIS_PREFIX_DIR/done" ]
then
rm -rf "$NSIS_PREFIX_DIR"
mkdir -p "$NSIS_PREFIX_DIR"
# We want to use NSIS 3, instead of NSIS 2, because it added Windows 8 and 10