-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.sh
executable file
·1975 lines (1829 loc) · 79.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
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
#!/bin/bash
# This script can be used to build Kid3 together with static libraries for the
# Windows and Mac versions of Kid3. Linux and BSD users do not need it because
# the libraries can be installed from their repositories, but they can use it
# to generate a self contained package with a minimum of dependencies.
#
# First you have to install the necessary tools:
#
# For Windows:
#
# Install Qt, you should use the MinGW which comes with Qt and add msys2
# to build the libraries. Additional dependencies can be installed using
# Chocolatey, e.g.
# choco install cmake docbook-bundle ninja python3 Wget xsltproc yasm
# Install additional packages in the MSYS2 MinGW 64-bit shell:
# pacman -S git patch autoconf automake make docbook-xsl mingw-w64-x86_64-make \
# mingw-w64-x86_64-ninja mingw-w64-x86_64-nasm mingw-w64-x86_64-libtool
# Start the msys shell, add Qt and cmake to the path and start this script.
#
# export QTPREFIX=/c/Qt/6.5.3/mingw_64
# test -z "${PATH##$QTPREFIX*}" ||
# PATH=$QTPREFIX/bin:$QTPREFIX/../../Tools/mingw1120_64/bin:$QTPREFIX/../../Tools/mingw1120_64/opt/bin:$PROGRAMFILES/CMake/bin:$PATH
# ../kid3/build.sh
#
# You can also build a Windows version from Linux using the MinGW cross
# compiler.
# COMPILER=cross-mingw QTPREFIX=/path/to/Qt6.5.3-mingw64/6.5.3/mingw_64 \
# QTBINARYDIR=/path/to/Qt6.5.3-linux/6.5.3/gcc_64/bin ../kid3/build.sh
#
# For Mac:
#
# The build dependencies can be installed with Homebrew, for instance:
# brew install cmake ninja autoconf automake libtool xz nasm docbook-xsl qt
# Then call from a build directory
# ../kid3/build.sh
#
# You can also build a macOS version from Linux using the osxcross toolchain.
# COMPILER=cross-macos QTPREFIX=/path/to/Qt6.5.3-mac/6.5.3/macos ../kid3/build.sh
# or
# COMPILER=cross-macos QTPREFIX=/path/to/Qt6.5.3-mac/6.5.3/macos \
# QTBINARYDIR=/path/to/Qt6.5.3-linux/6.5.3/gcc_64/bin ../kid3/build.sh
#
# For Android:
#
# Install Qt and a compatible Android SDK and NDK, for example Qt 5.9.7,
# NDK 10e or Qt 5.12.2, NDK 19c, or Qt 6.5.3, NDK 23.1.7779620.
# COMPILER=cross-android QTPREFIX=/path/to/Qt/6.5.3/android_armv7 \
# QTBINARYDIR=/path/to/Qt6.5.3-linux/6.5.3/gcc_64/bin \
# ANDROID_SDK_ROOT=/path/to/sdk ANDROID_NDK_ROOT=/path/to/ndk/23.1.7779620 \
# ../kid3/build.sh
#
# For Linux:
#
# To build a self-contained Linux package use
# COMPILER=gcc-self-contained QTPREFIX=/path/to/Qt6.5.3-linux/6.5.3/gcc_64 \
# ../kid3/build.sh
#
# When cross compiling make sure that the host Qt version is not larger than
# the target Qt version, otherwise moc and plugins will fail. To provide
# host Qt binaries of a suitable version, set the QTBINARYDIR environment
# variable.
#
# The source code for the libraries is downloaded from Debian and Ubuntu
# repositories. If the files are no longer available, use a later version,
# it should still work.
#
# build.sh will download, build and install zlib, libogg, libvorbis,
# flac, id3lib, taglib, ffmpeg, chromaprint, mp4v2. When the libraries
# are built, the Kid3 package is built. It is also possible to build only
# the libraries or only the Kid3 package.
#
# ../kid3/build.sh libs
# ../kid3/build.sh package
# Exit if an error occurs
set -eE
trap 'echo "Error on line $LINENO: $BASH_COMMAND"' ERR
shopt -s extglob
thisdir=$(pwd)
srcdir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
kernel=$(uname)
test ${kernel:0:5} = "MINGW" && kernel="MINGW"
qt_version=6.5.3
zlib_version=1.2.13
zlib_patchlevel=1
libogg_version=1.3.4
libogg_patchlevel=0.1
libvorbis_version=1.3.7
libvorbis_patchlevel=2
ffmpeg3_version=3.2.14
ffmpeg3_patchlevel=1~deb9u1
ffmpeg_version=5.1.6
ffmpeg_patchlevel=0+deb12u1
libflac_version=1.4.3+ds
libflac_patchlevel=2.1
id3lib_version=3.8.3
id3lib_patchlevel=18
taglib_version=2.0.2
chromaprint_version=1.5.1
chromaprint_patchlevel=6
mp4v2_version=2.1.3
utfcpp_version=4.0.5
verify_not_in_srcdir() {
if test -f CMakeLists.txt; then
echo "Do not run this script from the source directory!"
echo "Start it from a build directory at the same level as the source directory."
exit 1
fi
}
verify_in_srcdir() {
if ! test -f CMakeLists.txt; then
echo "Run this task from the source directory!"
exit 1
fi
}
# The environment variable KID3_HOMEBREW_PKGS can be set to install packages
# needed to build using Homebrew, if brew is not yet available a local instance
# is installed.
# Example: KID3_HOMEBREW_PKGS="cmake ninja autoconf automake libtool xz nasm docbook-xsl p7zip"
if test -n "$KID3_HOMEBREW_PKGS"; then
export HOMEBREW_NO_INSTALL_UPGRADE=1
if ! brew install $KID3_HOMEBREW_PKGS; then
mkdir -p tools/Homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C tools/Homebrew
eval "$(tools/Homebrew/bin/brew shellenv)"
brew install $KID3_HOMEBREW_PKGS
fi
fi
# Administrative subtasks
# Changes version and date strings in all known Kid3 files.
if test "$1" = "changeversion"; then
OLDVER=$2
NEWVER=$3
if test -z "$OLDVER" || test -z "$NEWVER"; then
echo "Usage: $0 $1 old-version-nr new-version-nr [--finalize], e.g. $0 $1 0.8 0.9"
exit 1
fi
echo "### Change version and date strings"
DATE=$(LC_TIME=C date)
DATE_R=$(date -R)
DATE_F=$(date +"%F")
DATE_Y=$(date +"%Y")
OLDMAJOR=$(echo $OLDVER | cut -f 1 -d .)
OLDMINOR=$(echo $OLDVER | cut -f 2 -d .)
OLDPATCH=$(echo $OLDVER | cut -f 3 -d .)
test -z $OLDPATCH && OLDPATCH=0
NEWMAJOR=$(echo $NEWVER | cut -f 1 -d .)
NEWMINOR=$(echo $NEWVER | cut -f 2 -d .)
NEWPATCH=$(echo $NEWVER | cut -f 3 -d .)
test -z $NEWPATCH && NEWPATCH=0
cd "$srcdir"
grep -qF "kid3 (${NEWVER}-0)" deb/changelog ||
sed -i "1 i\
kid3 (${NEWVER}-0) unstable; urgency=low\n\n * New upstream release.\n\n\
-- Urs Fleisch <[email protected]> ${DATE_R}\n" deb/changelog
grep -qF "<releaseinfo>${NEWVER}</releaseinfo>" doc/en/index.docbook ||
sed -i "s/^<releaseinfo>${OLDVER}<\/releaseinfo>$/<releaseinfo>${NEWVER}<\/releaseinfo>/; s/^<year>[0-9]\+<\/year>$/<year>${DATE_Y}<\/year>/; s/^<date>[0-9-]\+<\/date>$/<date>${DATE_F}<\/date>/" doc/en/index.docbook
sed -i "s/PROJECTVERSION=\"${OLDVER}\"/PROJECTVERSION=\"${NEWVER}\"/" translations/extract-merge.sh
# kid3.spec is used by f-droid to detect a new version, it should be updated exactly before the release.
if test "$4" = "--finalize"; then
sed -i "s/^\(Version: \+\).*$/\1${NEWVER}/" kid3.spec
OLDCODE=$(sed -n "s/ \+set(QT_ANDROID_APP_VERSION_CODE \([0-9]\+\))/\1/p" CMakeLists.txt)
NEWCODE=$[ $OLDCODE + 1 ]
sed -i "s/\( \+set(QT_ANDROID_APP_VERSION_CODE \)\([0-9]\+\))/\1$NEWCODE)/" CMakeLists.txt
fi
sed -i "s/^Copyright 2003-[0-9]\+ Urs Fleisch <[email protected]>$/Copyright 2003-${DATE_Y} Urs Fleisch <[email protected]>/" deb/copyright
grep -qF "* Release ${NEWVER}" ChangeLog ||
sed -i "1 i\
${DATE} Urs Fleisch <[email protected]>\n\n\t* Release ${NEWVER}\n" ChangeLog
sed -i "s/PROJECT_NUMBER = ${OLDVER}/PROJECT_NUMBER = ${NEWVER}/" Doxyfile
sed -i "s/set(CPACK_PACKAGE_VERSION_MAJOR ${OLDMAJOR})/set(CPACK_PACKAGE_VERSION_MAJOR ${NEWMAJOR})/; s/set(CPACK_PACKAGE_VERSION_MINOR ${OLDMINOR})/set(CPACK_PACKAGE_VERSION_MINOR ${NEWMINOR})/; s/set(CPACK_PACKAGE_VERSION_PATCH ${OLDPATCH})/set(CPACK_PACKAGE_VERSION_PATCH ${NEWPATCH})/; s/set(RELEASE_YEAR [0-9]\+)/set(RELEASE_YEAR ${DATE_Y})/" CMakeLists.txt
grep -qF "<release version=\"${NEWVER}\"" src/app/org.kde.kid3.appdata.xml ||
sed -i "s,^ <releases>.*,&\n <release version=\"${NEWVER}\" date=\"${DATE_F}\"/>," src/app/org.kde.kid3.appdata.xml
grep -q "for ver in .*'${NEWVER}'" packaging/craft/extragear/kid3/kid3.py ||
sed -i -r "s/(for ver in \[[^]]*'${OLDVER}')\]:/\1, '${NEWVER}']:/" packaging/craft/extragear/kid3/kid3.py
sed -i "s,https://download.kde.org/stable/kid3/${OLDVER}/kid3-${OLDVER}.tar.xz,https://download.kde.org/stable/kid3/${NEWVER}/kid3-${NEWVER}.tar.xz," packaging/flatpak/org.kde.kid3-stable.json
cd - >/dev/null
exit 0
fi # changeversion
if test "$1" = "cleanuppo"; then
echo "### Clean up .po files"
for f in $srcdir/translations/po/*/*.po; do
sed -i "/#, \(fuzzy, \)\?qt-\(plural-\)\?format/ d; /#, kde-format/ d; /^#~ msg/ d" $f
done
exit 0
fi # cleanuppo
if test "$1" = "makearchive"; then
VERSION=$2
if test -z "$VERSION"; then
VERSION=$(date +"%Y%m%d")
fi
DIR=kid3-$VERSION
TGZ=$DIR.tar.gz
if test -e "$TGZ"; then
echo "$TGZ already exists!"
exit 1
fi
cd $srcdir
git archive --format=tar --prefix=$DIR/ HEAD | gzip >$thisdir/$TGZ
cd - >/dev/null
exit 0
fi # makearchive
# Build a docker image to build binary Kid3 packages.
# The docker image can then be started using "rundocker".
# You can then build all packages using
# kid3/build.sh rundocker $HOME/projects/kid3/src/build-all.sh
# You need:
# - Kid3 project checked out in ~/projects/kid3/src/kid3
# - At least CMake 3.21 in /opt/cmake/bin/
# Linux:
# - Qt 6.5.3 Linux in ~/Development/Qt6.5.3-linux/6.5.3/gcc_64/
# Windows:
# - MinGW 11.2 cross compiler in /opt/mxe11/
# - Qt 6.5.3 MinGW64 in ~/Development/Qt6.5.3-mingw64/6.5.3/mingw_64/
# Mac:
# - Mac cross compiler in /opt/osxcross/
# - Qt 6.5.3 Mac in ~/Development/Qt6.5.3-mac/6.5.3/macos/
# Android:
# - Java JDK 17
# - Android SDK in ~/Development/android-sdk/
# - Android NDK in ~/Development/android-sdk/ndk/23.1.7779620/
# - Qt 6.5.3 Android in ~/Development/Qt6.5.3-android/6.5.3/android_armv7/
# - Sign key in ~/Development/ufleisch-release-key.keystore
# - Gradle cache in ~/.gradle/
if test "$1" = "makedocker"; then
verify_not_in_srcdir
if ! test -f build-all.sh; then
cat >build-all.sh <<"EOF"
#!/bin/bash
cd "$(dirname "${BASH_SOURCE[0]}")"
set -e
(cd linux_build && \
PATH=/opt/cmake/bin:$PATH \
COMPILER=gcc-self-contained \
QTPREFIX=$HOME/Development/Qt6.5.3-linux/6.5.3/gcc_64 \
../kid3/build.sh)
(cd mingw64_build && \
PATH=/opt/mxe11/usr/bin:/opt/cmake/bin:$PATH \
COMPILER=cross-mingw \
QTPREFIX=$HOME/Development/Qt6.5.3-mingw64/6.5.3/mingw_64 \
QTBINARYDIR=$HOME/Development/Qt6.5.3-linux/6.5.3/gcc_64/bin \
../kid3/build.sh)
(cd mingw64_qt5_build && \
PATH=/opt/mxe/usr/bin:$PATH \
COMPILER=cross-mingw \
QTPREFIX=$HOME/Development/Qt5.15.2-mingw64/5.15.2/mingw81_64 \
QTBINARYDIR=$HOME/Development/Qt5.15.2-linux/5.15.2/gcc_64/bin \
../kid3/build.sh && \
origzip=(kid3/*-x64.zip) && \
qt5zip=${origzip/-x64./-x64-Qt5.} && \
mv $origzip $qt5zip)
(cd macos_build && \
rm -f kid3/*-Darwin.dmg && \
PATH=/opt/cmake/bin:$PATH \
COMPILER=cross-macos \
QTPREFIX=$HOME/Development/Qt6.5.3-mac/6.5.3/macos \
OSXPREFIX=/opt/osxcross/target \
QTBINARYDIR=$HOME/Development/Qt6.5.3-linux/6.5.3/gcc_64/bin \
../kid3/build.sh && \
origdmg=(kid3/*-Darwin.dmg) && \
qt6dmg=${origdmg/-Darwin./-Darwin-amd64.} && \
mv $origdmg $qt6dmg)
(cd macos_qt5_build && \
rm -f kid3/*-Darwin.dmg && \
COMPILER=cross-macos \
QTPREFIX=$HOME/Development/Qt5.15.2-mac/5.15.2/clang_64 \
OSXPREFIX=/opt/osxcross/target \
../kid3/build.sh && \
origdmg=(kid3/*-Darwin.dmg) && \
qt5dmg=${origdmg/-Darwin./-Darwin-Qt5.} && \
mv $origdmg $qt5dmg)
(cd android_build && \
PATH=/opt/cmake/bin:$PATH \
COMPILER=cross-android \
QTPREFIX=$HOME/Development/Qt6.5.3-android/6.5.3/android_armv7 \
QTBINARYDIR=$HOME/Development/Qt6.5.3-linux/6.5.3/gcc_64/bin \
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 \
ANDROID_SDK_ROOT=$HOME/Development/android-sdk \
ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/23.1.7779620 \
../kid3/build.sh)
(cd android_arm64_build && \
PATH=/opt/cmake/bin:$PATH \
COMPILER=cross-android \
QTPREFIX=$HOME/Development/Development/Qt6.5.3-android64/6.5.3/android_arm64_v8a \
QTBINARYDIR=$HOME/Development/Qt6.5.3-linux/6.5.3/gcc_64/bin \
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 \
ANDROID_SDK_ROOT=$HOME/Development/android-sdk \
ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/23.1.7779620 \
../kid3/build.sh)
EOF
chmod +x build-all.sh
fi
mkdir -p docker_image_context
cd docker_image_context
echo "### Build docker image"
UNAME=$(uname)
if hash podman 2>/dev/null; then
DOCKER=podman
elif [ -z "${UNAME##MINGW*}" ] || [ -z "${UNAME##MSYS*}" ] || id -Gn | grep -qw "docker\(root\)\?"; then
DOCKER=docker
else
DOCKER="sudo docker"
fi
$DOCKER build --build-arg USER=${USER} --build-arg UID=$(id -u) -t ufleisch/kid3dev:bullseye . -f-<<"EOF"
FROM debian:bullseye-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
devscripts build-essential lintian debhelper extra-cmake-modules \
libkf5kio-dev libkf5doctools-dev qtmultimedia5-dev qtdeclarative5-dev \
qttools5-dev qttools5-dev-tools qtdeclarative5-dev-tools \
qml-module-qtquick2 cmake python libid3-3.8.3-dev libflac++-dev \
libvorbis-dev libtag1-dev libchromaprint-dev libavformat-dev \
libavcodec-dev docbook-xsl pkg-config libreadline-dev xsltproc \
debian-keyring dput-ng python3-distro-info sudo curl less \
locales ninja-build ccache p7zip-full genisoimage \
clang llvm nasm lib32z1 chrpath libpulse-mainloop-glib0 dmg2img archivemount \
openjdk-17-jre-headless libxcb-cursor0 libxrandr2
ARG USER
ARG UID
RUN adduser --quiet --disabled-password --uid $UID --gecos "User" $USER && \
echo "$USER:$USER" | chpasswd && usermod -aG sudo $USER && \
locale-gen en_US.UTF-8 && \
mkdir -p /home/$USER/projects/kid3 /home/$USER/Development && \
ln -s /proc/self/mounts /etc/mtab
USER $USER
CMD bash
EOF
exit 0
fi
# Run docker image created with "makedocker".
if test "$1" = "rundocker"; then
echo "### Run docker image"
shift
UNAME=$(uname)
if hash podman 2>/dev/null; then
DOCKER=podman
USERNSARG=--userns=keep-id
elif [ -z "${UNAME##MINGW*}" ] || [ -z "${UNAME##MSYS*}" ] || id -Gn | grep -qw "docker\(root\)\?"; then
DOCKER=docker
USERNSARG=
else
DOCKER="sudo docker"
USERNSARG=
fi
$DOCKER run $USERNSARG --rm -it -e LANG=C.UTF-8 \
--device /dev/fuse --cap-add SYS_ADMIN \
-v $HOME/projects/kid3:$HOME/projects/kid3 \
-v $HOME/.gradle:$HOME/.gradle \
-v $HOME/.gnupg:$HOME/.gnupg:ro \
-v /opt/cmake:/opt/cmake:ro \
-v /opt/osxcross:/opt/osxcross:ro \
-v /opt/mxe11:/opt/mxe11:ro \
-v /opt/mxe:/opt/mxe:ro \
-v $HOME/Development:$HOME/Development:ro ufleisch/kid3dev:bullseye "$@"
exit 0
fi
# Build flatpak
if test "$1" = "flatpak"; then
verify_not_in_srcdir
echo "### Build flatpak"
flatpak-builder --force-clean --ccache --repo=repo --subject="Build of org.kde.kid3 $(date --iso-8601=seconds)" app "$srcdir/packaging/flatpak/org.kde.kid3-local.json"
exit 0
fi
# Build Debian package.
if test "$1" = "deb"; then
verify_in_srcdir
echo "### Build Debian package"
shift
test -d debian && rm -rf debian
cp -R deb debian
# The PPA version (e.g. trusty1) can be given as a parameter to prepare
# a PPA upload. The source archive kid3_${version}.orig.tar.gz must be
# in the parent directory.
ppaversion=$1
if test -n "$ppaversion"; then
distribution=${ppaversion%%[0-9]*}
else
distribution=$(lsb_release -sc)
fi
if test -n "$ppaversion"; then
version=$(sed -e 's/^kid3 (\([0-9\.-]\+\).*$/\1/;q' debian/changelog)
DEBEMAIL="Urs Fleisch <[email protected]>" \
dch --newversion=${version}${ppaversion} --distribution=$distribution --urgency=low \
"No-change backport to $distribution."
sed -i -e 's/^Maintainer:.*$/Maintainer: Urs Fleisch <[email protected]>/;/^Uploaders:/,+1d' debian/control
debuild -S -sa &&
echo "PPA upload ready for $distribution. Use:" &&
echo "cd ..; dput ppa:ufleisch/kid3 kid3_${version}${ppaversion}_source.changes"
else
rm -rf debian/source debian/watch
debuild
fi
exit 0
fi
if test "$1" = "clean"; then
rm -rf zlib-${zlib_version}.dfsg libogg-${libogg_version} \
libvorbis-${libvorbis_version} flac-${libflac_version%+ds*} \
id3lib-${id3lib_version} taglib-${taglib_version} \
ffmpeg-${ffmpeg_version} chromaprint-${chromaprint_version} \
mp4v2-${mp4v2_version} utfcpp-${utfcpp_version} openssl-*
exit 0
fi
# End of subtasks
verify_not_in_srcdir
target=${*:-libs package}
# Try to find the configuration from an existing build.
if test -z "$COMPILER"; then
if test -f mingw.cmake; then
COMPILER=cross-mingw
QTPREFIX=$(sed -ne '1 s/set(QT_PREFIX \([^)]\+\))/\1/p' mingw.cmake)
elif test -f osxcross.cmake; then
COMPILER=cross-macos
QTPREFIX=$(sed -ne '1 s/set(QT_PREFIX \([^)]\+\))/\1/p' osxcross.cmake)
elif test $(ls openssl-*/Setenv-android.sh 2>/dev/null | wc -l) != "0"; then
COMPILER=cross-android
test -f kid3/CMakeCache.txt &&
QTPREFIX=$(sed -ne 's/^QT_QMAKE_EXECUTABLE[^=]*=\(.*\)\/bin\/qmake$/\1/p' kid3/CMakeCache.txt)
elif grep -q "CMAKE_CXX_COMPILER.*g++-4\.8" kid3/CMakeCache.txt 2>/dev/null; then
COMPILER=gcc-self-contained
QTPREFIX=$(sed -ne 's/^QT_QMAKE_EXECUTABLE[^=]*=\(.*\)\/bin\/qmake$/\1/p' kid3/CMakeCache.txt)
elif grep -q "^CMAKE_BUILD_TYPE.*=Debug$" kid3/CMakeCache.txt 2>/dev/null; then
COMPILER=gcc-debug
QTPREFIX=$(sed -ne 's/^QT_QMAKE_EXECUTABLE[^=]*=\(.*\)\/bin\/qmake$/\1/p' kid3/CMakeCache.txt)
fi
fi
compiler=${COMPILER:-gcc}
echo -n "### Building $target with $compiler"
if test -n "$QTPREFIX"; then
echo -n " using $QTPREFIX"
fi
echo "."
if [[ "$QTPREFIX" =~ /([0-9]+)\.([0-9]+)\.([0-9]+)/ ]]; then
qt_nr=$(printf "%d%02d%02d" ${BASH_REMATCH[1]} ${BASH_REMATCH[2]} ${BASH_REMATCH[3]})
qt_version=$(printf "%d.%d.%d" ${BASH_REMATCH[1]} ${BASH_REMATCH[2]} ${BASH_REMATCH[3]})
qt_version_major=${BASH_REMATCH[1]}
else
echo "Could not extract Qt version from $QTPREFIX, assuming $qt_version"
if [[ "$qt_version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
qt_nr=$(printf "%d%02d%02d" ${BASH_REMATCH[1]} ${BASH_REMATCH[2]} ${BASH_REMATCH[3]})
qt_version_major=${BASH_REMATCH[1]}
fi
fi
if test "$compiler" = "cross-android" -o "$compiler" = "gcc-self-contained" && test "$qt_nr" -ge 60000; then
openssl_version=3.0.9
elif test "$qt_nr" -ge 51204; then
# Since Qt 5.12.4, OpenSSL 1.1.1 is supported
openssl_version=1.1.1g
else
openssl_version=1.0.2u
fi
if test "$compiler" = "gcc-self-contained"; then
if test "$qt_nr" -lt 51500; then
gcc_self_contained_cc="gcc-4.8"
gcc_self_contained_cxx="g++-4.8"
else
gcc_self_contained_cc="gcc"
gcc_self_contained_cxx="g++"
fi
fi
if test "$compiler" = "cross-mingw"; then
if test -n "$QTPREFIX" && test -z "${QTPREFIX%%*64?(/)}"; then
cross_host="x86_64-w64-mingw32"
if hash ${cross_host}-gcc-posix 2>/dev/null; then
_crossprefix=${cross_host}-
# Qt uses posix threads, but x86_64-w64-mingw32-gcc uses win32 thread model.
_crosssuffix=-posix
elif hash ${cross_host}.shared-gcc 2>/dev/null; then
_crossprefix=${cross_host}.shared-
_crosssuffix=
fi
else
cross_host="i686-w64-mingw32"
_crossprefix=${cross_host}-
_crosssuffix=
# FFmpeg > 3 is not compatible with Windows XP
ffmpeg_version=$ffmpeg3_version
ffmpeg_patchlevel=$ffmpeg3_patchlevel
fi
elif test "$compiler" = "cross-macos"; then
osxprefix=${OSXPREFIX:-/opt/osxcross/target}
# e.g. x86_64-apple-darwin17
cross_host=$($osxprefix/bin/o64-clang --version | grep Target | cut -d' ' -f2)
_crossprefix=${cross_host}-
# e.g. $osxprefix/SDK/MacOSX10.13.sdk
osxsdk=($osxprefix/SDK/*.sdk)
fi
if test "$compiler" = "cross-android"; then
_java_root=${JAVA_HOME:-/usr/lib/jvm/java-8-openjdk-amd64}
_android_sdk_root=${ANDROID_SDK_ROOT:-/opt/android/sdk}
_android_ndk_root=${ANDROID_NDK_ROOT:-$_android_sdk_root/ndk-bundle}
_android_platform=${ANDROID_PLATFORM:-23}
_android_ccache=$(which ccache || true)
_android_qt_root=${QTPREFIX:-/opt/qt5/5.9.7/android_armv7}
_android_toolchain_cmake=$_android_ndk_root/build/cmake/android.toolchain.cmake
test -f $_android_toolchain_cmake ||
_android_toolchain_cmake=$srcdir/android/qt-android-cmake/toolchain/android.toolchain.cmake
if test -z "${_android_qt_root%%*x86}"; then
_android_abi=x86
_android_prefix=i686-linux-android
elif test -z "${_android_qt_root%%*x86_64}"; then
_android_abi=x86_64
_android_prefix=x86_64-linux-android
elif test -z "${_android_qt_root%%*arm64_v8a}"; then
_android_abi=arm64-v8a
_android_prefix=aarch64-linux-android
else
_android_abi=armeabi-v7a
_android_prefix=arm-linux-androideabi
fi
fi
_chocoInstall=${ChocolateyInstall//\\/\/}
_chocoInstall=${_chocoInstall/C:/\/c}
for d in "$DOCBOOK_XSL_DIR" /usr/share/xml/docbook/stylesheet/nwalsh /usr/share/xml/docbook/xsl-stylesheets-* /usr/local/Cellar/docbook-xsl/*/docbook-xsl /opt/homebrew/Cellar/docbook-xsl/*/docbook-xsl $HOMEBREW_CELLAR/docbook-xsl/*/docbook-xsl /opt/local/share/xsl/docbook-xsl $_chocoInstall/lib/docbook-bundle/docbook-xsl-*; do
if test -e $d/xhtml/docbook.xsl; then
_docbook_xsl_dir=$d
break
fi
done
if test "$compiler" = "gcc-debug"; then
export CFLAGS="-fPIC"
export CXXFLAGS="-fPIC"
FLAC_BUILD_OPTION="--enable-debug=yes"
ID3LIB_BUILD_OPTION="--enable-debug=minimum"
AV_BUILD_OPTION="--enable-debug=3 --enable-pic --extra-ldexeflags=-pie"
CMAKE_BUILD_OPTION="-DCMAKE_BUILD_TYPE=Debug"
elif test "$compiler" = "gcc-self-contained"; then
export CC=$gcc_self_contained_cc
export CXX=$gcc_self_contained_cxx
export CFLAGS="-O2 -fPIC"
export CXXFLAGS="-O2 -fPIC"
FLAC_BUILD_OPTION="--enable-debug=info CFLAGS=-O2 CXXFLAGS=-O2"
ID3LIB_BUILD_OPTION="--enable-debug=minimum"
AV_BUILD_OPTION="--enable-debug=1 --enable-pic --extra-ldexeflags=-pie"
CMAKE_BUILD_OPTION="-DCMAKE_BUILD_TYPE=RelWithDebInfo"
else
FLAC_BUILD_OPTION="--enable-debug=info CFLAGS=-O2 CXXFLAGS=-O2"
ID3LIB_BUILD_OPTION="--enable-debug=minimum"
AV_BUILD_OPTION="--enable-debug=1"
CMAKE_BUILD_OPTION="-DCMAKE_BUILD_TYPE=RelWithDebInfo"
fi
if ! which cmake >/dev/null; then
echo "cmake not found."
return 2>/dev/null
exit 1
fi
if test $kernel = "MSYS_NT-6.1"; then
kernel="MINGW"
CONFIGURE_OPTIONS="--build=x86_64-w64-mingw32 --target=i686-w64-mingw32"
fi
if test $kernel = "MINGW"; then
# Use mingw from Qt
if test -n "$QTPREFIX"; then
test -z "${PATH##$QTPREFIX*}" || PATH=$QTPREFIX/bin:$QTPREFIX/../../Tools/mingw492_32/bin:$QTPREFIX/../../Tools/mingw492_32/opt/bin:$PATH
else
echo "QTPREFIX is not set"
exit 1
fi
CMAKE_OPTIONS="-GNinja -DCMAKE_INSTALL_PREFIX=/usr/local"
CONFIGURE_OPTIONS+=" --prefix=/usr/local"
elif test $kernel = "Darwin"; then
CMAKE_OPTIONS="-GNinja"
_macosx_version_min=10.7
else
CMAKE_OPTIONS="-GNinja"
fi
if test "$compiler" = "cross-mingw"; then
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_TOOLCHAIN_FILE=$thisdir/mingw.cmake"
CONFIGURE_OPTIONS="--host=${cross_host}"
if test "$cross_host" = "x86_64-w64-mingw32"; then
export CC=${_crossprefix}gcc${_crosssuffix}
export CXX=${_crossprefix}g++${_crosssuffix}
fi
elif test "$compiler" = "cross-macos"; then
if test "$qt_nr" -ge 60500; then
_macosx_version_min=10.15
else
_macosx_version_min=10.7
fi
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_TOOLCHAIN_FILE=$thisdir/osxcross.cmake -DCMAKE_C_FLAGS=\"-O2 -mmacosx-version-min=${_macosx_version_min}\" -DCMAKE_CXX_FLAGS=\"-O2 -mmacosx-version-min=${_macosx_version_min} -fvisibility=hidden -fvisibility-inlines-hidden -stdlib=libc++\" -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_MODULE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_SHARED_LINKER_FLAGS=-stdlib=libc++"
CONFIGURE_OPTIONS="--host=${cross_host}"
export CC=${_crossprefix}clang
export CXX=${_crossprefix}clang++
export AR=${_crossprefix}ar
export CFLAGS="-O2 $ARCH_FLAG -mmacosx-version-min=${_macosx_version_min}"
export CXXFLAGS="-O2 $ARCH_FLAG -mmacosx-version-min=${_macosx_version_min} -stdlib=libc++"
export LDFLAGS="$ARCH_FLAG -mmacosx-version-min=${_macosx_version_min} -stdlib=libc++"
fi
if test $kernel = "MINGW" || test "$compiler" = "cross-mingw"; then
# Build zlib only for Windows.
ZLIB_ROOT_PATH="$thisdir/buildroot/usr/local"
TAGLIB_ZLIB_ROOT_OPTION="-DZLIB_ROOT=${ZLIB_ROOT_PATH}"
CHROMAPRINT_ZLIB_OPTION="-DEXTRA_LIBS=\"-L${ZLIB_ROOT_PATH}/lib -lz\""
fi
if test $kernel = "Darwin"; then
MACHINE_ARCH=$(uname -m)
#MACHINE_ARCH=i386
if test "$MACHINE_ARCH" = "i386"; then
# To build a 32-bit Mac OS X version of Kid3 use:
# cmake -GNinja -DCMAKE_CXX_FLAGS="-arch i386" -DCMAKE_C_FLAGS="-arch i386" -DCMAKE_EXE_LINKER_FLAGS="-arch i386" -DQT_QMAKE_EXECUTABLE=/usr/local/Trolltech/Qt-${qt_version}-i386/bin/qmake -DCMAKE_BUILD_TYPE=Release -DWITH_FFMPEG=ON -DCMAKE_INSTALL_PREFIX= ../kid3
# Building multiple architectures needs ARCH_FLAG="-arch i386 -arch x86_64",
# CONFIGURE_OPTIONS="--disable-dependency-tracking", but it fails with libav.
ARCH=$MACHINE_ARCH
ARCH_FLAG="-arch i386"
export CC=gcc
export CXX=g++
elif test "$MACHINE_ARCH" = "arm64"; then
# On Apple silicon, we can build for Intel or ARM. The environment variable
# ARCH=x86_64 or ARCH=arm64 can be passed to this script.
if test "$ARCH" != "x86_64"; then
ARCH=$MACHINE_ARCH
fi
_macosx_version_min=10.15
ARCH_FLAG="-arch $ARCH"
else
ARCH=$MACHINE_ARCH
ARCH_FLAG="-Xarch_x86_64"
fi
if [[ $(sw_vers -productVersion) = 10.1* || $(sw_vers -productVersion) =~ ^1[1-9]\..*$ ]]; then
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_C_FLAGS=\"-O2 $ARCH_FLAG -mmacosx-version-min=${_macosx_version_min}\" -DCMAKE_CXX_FLAGS=\"-O2 $ARCH_FLAG -mmacosx-version-min=${_macosx_version_min} -fvisibility=hidden -fvisibility-inlines-hidden -stdlib=libc++\" -DCMAKE_EXE_LINKER_FLAGS=\"$ARCH_FLAG -stdlib=libc++\" -DCMAKE_MODULE_LINKER_FLAGS=\"$ARCH_FLAG -stdlib=libc++\" -DCMAKE_SHARED_LINKER_FLAGS=\"$ARCH_FLAG -stdlib=libc++\""
export CFLAGS="-O2 $ARCH_FLAG -mmacosx-version-min=${_macosx_version_min}"
export CXXFLAGS="-O2 $ARCH_FLAG -mmacosx-version-min=${_macosx_version_min} -stdlib=libc++"
export LDFLAGS="$ARCH_FLAG -mmacosx-version-min=${_macosx_version_min} -stdlib=libc++"
else
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_C_FLAGS=\"-O2 $ARCH_FLAG -mmacosx-version-min=10.5\" -DCMAKE_CXX_FLAGS=\"-O2 $ARCH_FLAG -mmacosx-version-min=10.5 -fvisibility=hidden -fvisibility-inlines-hidden\""
export CFLAGS="-O2 $ARCH_FLAG -mmacosx-version-min=10.5"
export CXXFLAGS="-O2 $ARCH_FLAG -mmacosx-version-min=10.5"
export LDFLAGS="$ARCH_FLAG -mmacosx-version-min=10.5"
fi
fi # Darwin
if which wget >/dev/null; then
DOWNLOAD=wget
else
DOWNLOAD="curl -skfLO"
fi
test -d buildroot || mkdir buildroot
BUILDROOT=`pwd`/buildroot/
fixcmakeinst() {
if test -d inst && test $kernel = "MINGW"; then
cd inst
if test -d prg; then
rm -rf usr
mv prg/msys usr
rmdir prg
elif test -d msys; then
rm -rf usr
mv msys/1.0 usr
rmdir msys
elif test -d MinGW; then
mv MinGW usr
elif test -d msys64; then
rm -rf usr
mv msys64/usr .
rmdir msys64
elif test -d msys32; then
rm -rf usr
mv msys32/usr .
rmdir msys32
fi
cd ..
fi
}
create_binary_archive() {
if test -d "$2"; then
find "$2" -type f -exec touch {} +
tar czf "$1" "$2"
fi
}
extract_binary_archive() {
if test -f "$1"; then
tar xzf "$1" -C $BUILDROOT
fi
}
if test "$compiler" = "cross-mingw" || test "$compiler" = "cross-macos"; then
if test -n "$QTBINARYDIR"; then
_qt_bin_dir=$QTBINARYDIR
else
for d in $thisdir/qtbase5-dev-tools* /usr/lib/${HOSTTYPE/i686/i386}-linux-gnu/qt5/bin /usr/bin; do
if test -x $d/moc; then
_qt_bin_dir=$d
break
fi
done
fi
if test -n "$QTPREFIX"; then
_qt_prefix=$QTPREFIX
else
if test "$compiler" = "cross-mingw"; then
for d in /windows/Qt/${qt_version}/mingw* /windows/Qt/Qt${qt_version}/${qt_version}/mingw* $thisdir/Qt*-mingw/${qt_version}/mingw*; do
if test -d $d; then
_qt_prefix=$d
break
fi
done
elif test "$compiler" = "cross-macos"; then
for d in $thisdir/Qt*-mac/${qt_version}/clang_64 $HOME/Development/Qt*-mac/${qt_version}/clang_64; do
if test -d $d; then
_qt_prefix=$d
break
fi
done
fi
fi
fi # cross-mingw || cross-macos
if test "$compiler" = "cross-mingw"; then
if ! test -f $thisdir/mingw.cmake; then
cat >$thisdir/mingw.cmake <<EOF
set(QT_PREFIX ${_qt_prefix})
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER ${_crossprefix}gcc${_crosssuffix})
set(CMAKE_CXX_COMPILER ${_crossprefix}g++${_crosssuffix})
set(CMAKE_RC_COMPILER ${_crossprefix}windres)
set(CMAKE_FIND_ROOT_PATH /usr/${cross_host} \${QT_PREFIX} $thisdir/buildroot/usr/local ${ZLIB_ROOT_PATH})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
EOF
if test "$qt_version_major" = "6"; then
_qt_libexec_dir=${_qt_bin_dir%bin}libexec
cat >>$thisdir/mingw.cmake <<EOF
set(QT_BINARY_DIR ${_qt_bin_dir})
set(QT_LIBEXEC_DIR ${_qt_libexec_dir})
set(QT_LIBRARY_DIR \${QT_PREFIX}/lib)
set(QT_QTCORE_LIBRARY \${QT_PREFIX}/lib/libQt${qt_version_major}Core.a)
set(QT_QTCORE_INCLUDE_DIR \${QT_PREFIX}/include/QtCore)
set(QT_MKSPECS_DIR \${QT_PREFIX}/mkspecs)
set(QT_MOC_EXECUTABLE \${QT_LIBEXEC_DIR}/moc)
set(QT_UIC_EXECUTABLE \${QT_LIBEXEC_DIR}/uic)
foreach (_exe moc rcc uic tracegen cmake_automoc_parser qlalr lprodump lrelease-pro lupdate-pro tracepointgen)
if (NOT TARGET Qt${qt_version_major}::\${_exe})
add_executable(Qt${qt_version_major}::\${_exe} IMPORTED)
set_target_properties(Qt${qt_version_major}::\${_exe} PROPERTIES
IMPORTED_LOCATION \${QT_LIBEXEC_DIR}/\${_exe}
)
endif ()
endforeach (_exe)
foreach (_exe lupdate lrelease windeployqt qtpaths androiddeployqt androidtestrunner lconvert)
if (NOT TARGET Qt${qt_version_major}::\${_exe})
add_executable(Qt${qt_version_major}::\${_exe} IMPORTED)
set_target_properties(Qt${qt_version_major}::\${_exe} PROPERTIES
IMPORTED_LOCATION \${QT_BINARY_DIR}/\${_exe}
)
endif ()
endforeach (_exe)
foreach (_exe qmake)
if (NOT TARGET Qt${qt_version_major}::\${_exe})
add_executable(Qt${qt_version_major}::\${_exe} IMPORTED)
set_target_properties(Qt${qt_version_major}::\${_exe} PROPERTIES
IMPORTED_LOCATION \${QT_PREFIX}/bin/\${_exe}
)
endif ()
endforeach (_exe)
EOF
else
cat >>$thisdir/mingw.cmake <<EOF
set(QT_BINARY_DIR ${_qt_bin_dir})
set(QT_LIBRARY_DIR \${QT_PREFIX}/lib)
set(QT_QTCORE_LIBRARY \${QT_PREFIX}/lib/libQt${qt_version_major}Core.a)
set(QT_QTCORE_INCLUDE_DIR \${QT_PREFIX}/include/QtCore)
set(QT_MKSPECS_DIR \${QT_PREFIX}/mkspecs)
set(QT_MOC_EXECUTABLE \${QT_BINARY_DIR}/moc)
set(QT_UIC_EXECUTABLE \${QT_BINARY_DIR}/uic)
foreach (_exe moc rcc lupdate lrelease uic)
if (NOT TARGET Qt${qt_version_major}::\${_exe})
add_executable(Qt${qt_version_major}::\${_exe} IMPORTED)
set_target_properties(Qt${qt_version_major}::\${_exe} PROPERTIES
IMPORTED_LOCATION \${QT_BINARY_DIR}/\${_exe}
)
endif ()
endforeach (_exe)
EOF
fi
fi
elif test "$compiler" = "cross-macos"; then
test -z ${PATH##$osxprefix/*} || PATH=$osxprefix/bin:$osxsdk/usr/bin:$PATH
if ! test -f $thisdir/osxcross.cmake; then
cat >$thisdir/osxcross.cmake <<EOF
if (POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
endif (POLICY CMP0025)
set(QT_PREFIX $_qt_prefix)
set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_C_COMPILER $osxprefix/lib/ccache/bin/${_crossprefix}clang)
set(CMAKE_CXX_COMPILER $osxprefix/lib/ccache/bin/${_crossprefix}clang++)
set(CMAKE_FIND_ROOT_PATH $osxprefix/${cross_host};$osxsdk/usr;$osxprefix/${cross_host};$osxsdk;$osxsdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers;\${QT_PREFIX};$thisdir/buildroot/usr/local)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_AR:FILEPATH ${_crossprefix}ar)
set(CMAKE_RANLIB:FILEPATH ${_crossprefix}ranlib)
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
EOF
if test "$qt_version_major" = "6"; then
_qt_libexec_dir=${_qt_bin_dir%bin}libexec
cat >>$thisdir/osxcross.cmake <<EOF
set(QT_INCLUDE_DIRS_NO_SYSTEM ON)
set(QT_BINARY_DIR ${_qt_bin_dir})
set(QT_LIBEXEC_DIR ${_qt_libexec_dir})
set(QT_LIBRARY_DIR \${QT_PREFIX}/lib)
set(Qt${qt_version_major}Core_DIR \${QT_PREFIX}/lib/cmake/Qt${qt_version_major}Core)
set(QT_MKSPECS_DIR \${QT_PREFIX}/mkspecs)
set(QT_MOC_EXECUTABLE \${QT_LIBEXEC_DIR}/moc)
set(QT_UIC_EXECUTABLE \${QT_LIBEXEC_DIR}/uic)
foreach (_exe moc rcc uic tracegen cmake_automoc_parser qlalr lprodump lrelease-pro lupdate-pro tracepointgen)
if (NOT TARGET Qt${qt_version_major}::\${_exe})
add_executable(Qt${qt_version_major}::\${_exe} IMPORTED)
set_target_properties(Qt${qt_version_major}::\${_exe} PROPERTIES
IMPORTED_LOCATION \${QT_LIBEXEC_DIR}/\${_exe}
)
endif ()
endforeach (_exe)
foreach (_exe lupdate lrelease macdeployqt qtpaths androiddeployqt androidtestrunner lconvert)
if (NOT TARGET Qt${qt_version_major}::\${_exe})
add_executable(Qt${qt_version_major}::\${_exe} IMPORTED)
set_target_properties(Qt${qt_version_major}::\${_exe} PROPERTIES
IMPORTED_LOCATION \${QT_BINARY_DIR}/\${_exe}
)
endif ()
endforeach (_exe)
foreach (_exe qmake)
if (NOT TARGET Qt${qt_version_major}::\${_exe})
add_executable(Qt${qt_version_major}::\${_exe} IMPORTED)
set_target_properties(Qt${qt_version_major}::\${_exe} PROPERTIES
IMPORTED_LOCATION \${QT_PREFIX}/bin/\${_exe}
)
endif ()
endforeach (_exe)
EOF
else
cat >>$thisdir/osxcross.cmake <<EOF
set(QT_INCLUDE_DIRS_NO_SYSTEM ON)
set(QT_BINARY_DIR ${_qt_bin_dir})
set(QT_LIBRARY_DIR \${QT_PREFIX}/lib)
set(Qt${qt_version_major}Core_DIR \${QT_PREFIX}/lib/cmake/Qt${qt_version_major}Core)
set(QT_MKSPECS_DIR \${QT_PREFIX}/mkspecs)
set(QT_MOC_EXECUTABLE \${QT_BINARY_DIR}/moc)
set(QT_UIC_EXECUTABLE \${QT_BINARY_DIR}/uic)
foreach (_exe moc rcc lupdate lrelease uic)
if (NOT TARGET Qt${qt_version_major}::\${_exe})
add_executable(Qt${qt_version_major}::\${_exe} IMPORTED)
set_target_properties(Qt${qt_version_major}::\${_exe} PROPERTIES
IMPORTED_LOCATION \${QT_BINARY_DIR}/\${_exe}
)
endif ()
endforeach (_exe)
EOF
fi
fi
fi # cross-mingw, cross-macos
if [[ $target = *"libs"* ]]; then
# Download sources
test -d ${SRC_ARCHIVE_DIR:=$thisdir/source} || mkdir -p $SRC_ARCHIVE_DIR
download_taglib() {
cd $SRC_ARCHIVE_DIR
if test -n "${taglib_githash}"; then
# Download an archive for a git hash
if ! test -f taglib-${taglib_githash}.tar.gz; then
$DOWNLOAD https://github.com/taglib/taglib/archive/${taglib_githash}.tar.gz
mv ${taglib_githash}.tar.gz taglib-${taglib_githash}.tar.gz
fi
elif test -n "${taglib_version##v*}"; then
test -f taglib-${taglib_version}.tar.gz ||
$DOWNLOAD http://taglib.github.io/releases/taglib-${taglib_version}.tar.gz
else
# Download an archive for a git tag
if ! test -f taglib-${taglib_version##v}.tar.gz; then
$DOWNLOAD https://github.com/taglib/taglib/archive/${taglib_version}.tar.gz
mv ${taglib_version}.tar.gz taglib-${taglib_version##v}.tar.gz
fi
taglib_version=${taglib_version##v}
fi
cd -
}
download_utfcpp() {
cd $SRC_ARCHIVE_DIR
if ! test -f utfcpp-${utfcpp_version}.tar.gz; then
$DOWNLOAD https://github.com/nemtrif/utfcpp/archive/refs/tags/v${utfcpp_version}.tar.gz
mv v${utfcpp_version}.tar.gz utfcpp-${utfcpp_version}.tar.gz
fi
cd -
}
download_libflac() {
cd $SRC_ARCHIVE_DIR
test -f flac_${libflac_version}-${libflac_patchlevel}.debian.tar.xz ||
$DOWNLOAD http://ftp.de.debian.org/debian/pool/main/f/flac/flac_${libflac_version}-${libflac_patchlevel}.debian.tar.xz
test -f flac_${libflac_version}.orig.tar.xz ||
$DOWNLOAD http://ftp.de.debian.org/debian/pool/main/f/flac/flac_${libflac_version}.orig.tar.xz
cd -
}
download_id3lib() {
cd $SRC_ARCHIVE_DIR
test -f id3lib3.8.3_${id3lib_version}-${id3lib_patchlevel}.debian.tar.xz ||
$DOWNLOAD http://ftp.de.debian.org/debian/pool/main/i/id3lib3.8.3/id3lib3.8.3_${id3lib_version}-${id3lib_patchlevel}.debian.tar.xz
test -f id3lib3.8.3_${id3lib_version}.orig.tar.gz ||
$DOWNLOAD http://ftp.de.debian.org/debian/pool/main/i/id3lib3.8.3/id3lib3.8.3_${id3lib_version}.orig.tar.gz
cd -
}
download_libogg() {
cd $SRC_ARCHIVE_DIR
test -f libogg_${libogg_version}-${libogg_patchlevel}.diff.gz ||
$DOWNLOAD http://ftp.de.debian.org/debian/pool/main/libo/libogg/libogg_${libogg_version}-${libogg_patchlevel}.diff.gz
test -f libogg_${libogg_version}.orig.tar.gz ||
$DOWNLOAD http://ftp.de.debian.org/debian/pool/main/libo/libogg/libogg_${libogg_version}.orig.tar.gz
cd -
}
download_libvorbis() {
cd $SRC_ARCHIVE_DIR
test -f libvorbis_${libvorbis_version}-${libvorbis_patchlevel}.debian.tar.xz ||
$DOWNLOAD http://ftp.de.debian.org/debian/pool/main/libv/libvorbis/libvorbis_${libvorbis_version}-${libvorbis_patchlevel}.debian.tar.xz
test -f libvorbis_${libvorbis_version}.orig.tar.gz ||
$DOWNLOAD http://ftp.de.debian.org/debian/pool/main/libv/libvorbis/libvorbis_${libvorbis_version}.orig.tar.gz
cd -
}
download_zlib() {
cd $SRC_ARCHIVE_DIR
if test -n "$ZLIB_ROOT_PATH"; then
test -f zlib_${zlib_version}.dfsg-${zlib_patchlevel}.debian.tar.xz ||
$DOWNLOAD http://ftp.de.debian.org/debian/pool/main/z/zlib/zlib_${zlib_version}.dfsg-${zlib_patchlevel}.debian.tar.xz
test -f zlib_${zlib_version}.dfsg.orig.tar.bz2 ||
$DOWNLOAD http://ftp.de.debian.org/debian/pool/main/z/zlib/zlib_${zlib_version}.dfsg.orig.tar.bz2
fi
cd -
}
download_ffmpeg() {
cd $SRC_ARCHIVE_DIR
test -f ffmpeg_${ffmpeg_version}.orig.tar.xz ||
$DOWNLOAD http://ftp.de.debian.org/debian/pool/main/f/ffmpeg/ffmpeg_${ffmpeg_version}.orig.tar.xz
test -f ffmpeg_${ffmpeg_version}-${ffmpeg_patchlevel}.debian.tar.xz ||
$DOWNLOAD http://ftp.de.debian.org/debian/pool/main/f/ffmpeg/ffmpeg_${ffmpeg_version}-${ffmpeg_patchlevel}.debian.tar.xz
cd -
}
download_chromaprint() {
cd $SRC_ARCHIVE_DIR
test -f chromaprint_${chromaprint_version}.orig.tar.gz ||