[6b7f54d] | 1 | #! /bin/bash |
---|
| 2 | |
---|
[4309424] | 3 | # This script cross compiles aubio for windows using mingw, four times: |
---|
| 4 | # |
---|
| 5 | # - 32 and 64 bits with no external dependencies |
---|
| 6 | # - 32 and 64 bits against ffmpeg |
---|
| 7 | # |
---|
[6b7f54d] | 8 | # On debian or ubuntu, you will want to 'apt-get install gcc-mingw-w64' |
---|
| 9 | |
---|
| 10 | set -e |
---|
| 11 | set -x |
---|
| 12 | |
---|
[4309424] | 13 | source VERSION |
---|
| 14 | VERSION="$AUBIO_MAJOR_VERSION.$AUBIO_MINOR_VERSION.$AUBIO_PATCH_VERSION" |
---|
| 15 | VERSION+="$AUBIO_VERSION_STATUS" |
---|
| 16 | |
---|
| 17 | FFMPEG_BUILDS_URL="https://ffmpeg.zeranoe.com/builds" |
---|
| 18 | FFMPEG_DEFAULT="20170315-6c4665d" |
---|
| 19 | |
---|
| 20 | # define some default CFLAGS |
---|
| 21 | DEF_CFLAGS="-Os -I/usr/share/mingw-w64" |
---|
| 22 | DEF_LDFLAGS="" |
---|
| 23 | |
---|
| 24 | WAFOPTS="" |
---|
| 25 | # disable external deps to make sure we don't try to use the host package |
---|
| 26 | WAFOPTS+=" --disable-samplerate --disable-jack --disable-sndfile" |
---|
| 27 | # enable ffmpeg build |
---|
| 28 | WAFOPTS+=" --disable-avcodec" |
---|
| 29 | # install without a prefix |
---|
| 30 | WAFOPTS+=" --prefix=/" |
---|
| 31 | # compile the tests, but fake running them |
---|
| 32 | # passing this option WAFOPTS fails (escaping?), added in actual waf call below |
---|
| 33 | #WAFOPTS+=" --testcmd='echo %s'" |
---|
| 34 | |
---|
| 35 | # debugging |
---|
| 36 | #WAFOPTS+=" -v" |
---|
| 37 | #WAFOPTS+=" -j1" |
---|
| 38 | #WAFOPTS+=" --notests" |
---|
| 39 | |
---|
| 40 | function fetch_ffpmeg() { |
---|
| 41 | ## manually add ffmpeg (no pkg-config .pc files in bins) |
---|
| 42 | [ -n "$FFMPEG_VERSION" ] || FFMPEG_VERSION=$FFMPEG_DEFAULT |
---|
| 43 | FFMPEG_TARBALL="$PWD/ffmpeg-$FFMPEG_VERSION-$TARGET-dev.zip" |
---|
| 44 | FFMPEG_BINARIES="${FFMPEG_TARBALL%%.zip}" |
---|
| 45 | if [ ! -d "$FFMPEG_BINARIES" ] |
---|
| 46 | then |
---|
| 47 | if [ ! -f "$FFMPEG_TARBALL" ] |
---|
| 48 | then |
---|
| 49 | curl -O $FFMPEG_BUILDS_URL/$TARGET/dev/ffmpeg-$FFMPEG_VERSION-$TARGET-dev.zip |
---|
| 50 | else |
---|
| 51 | echo "using $FFMPEG_TARBALL" |
---|
| 52 | fi |
---|
| 53 | unzip -x $FFMPEG_TARBALL |
---|
| 54 | else |
---|
| 55 | echo "using $FFMPEG_BINARIES" |
---|
| 56 | fi |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | function get_cflags() { |
---|
| 60 | CFLAGS="$DEF_CFLAGS" |
---|
| 61 | LDFLAGS="$DEF_LDFLAGS" |
---|
| 62 | if [ -n "$WITH_FFMEG" ] |
---|
| 63 | then |
---|
| 64 | fetch_ffpmeg |
---|
| 65 | CFLAGS+=" -DHAVE_LIBAV=1 -DHAVE_SWRESAMPLE=1" |
---|
| 66 | CFLAGS+=" -I$FFMPEG_BINARIES/include" |
---|
| 67 | LDFLAGS+=" -lavcodec -lavformat -lavutil -lswresample" |
---|
| 68 | LDFLAGS+=" -L$FFMPEG_BINARIES/lib" |
---|
| 69 | fi |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | function build_mingw() { |
---|
| 73 | DESTDIR="$PWD/aubio-$VERSION-$TARGET" |
---|
| 74 | [ -n "$WITH_FFMEG" ] && DESTDIR+="-ffmpeg" |
---|
[4f64069] | 75 | [ -f $DESTDIR.zip ] && echo "Remove existing $DESTDIR.zip first" && exit 1 |
---|
| 76 | [ -d $DESTDIR ] && rm -rf $DESTDIR |
---|
[4309424] | 77 | WAFOPTS_TGT="$WAFOPTS --destdir=$DESTDIR" |
---|
| 78 | WAFOPTS_TGT+=" --with-target-platform=$TARGET" |
---|
| 79 | get_cflags |
---|
| 80 | CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \ |
---|
| 81 | ./waf distclean configure build install $WAFOPTS_TGT --testcmd='echo %s' |
---|
| 82 | zip -r $DESTDIR.zip `basename $DESTDIR` |
---|
| 83 | rm -rf $DESTDIR |
---|
| 84 | sha256sum $DESTDIR.zip > $DESTDIR.zip.sha256 |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | function build_mingw32() { |
---|
| 88 | TARGET=win32 |
---|
| 89 | export CC=i686-w64-mingw32-gcc |
---|
| 90 | build_mingw |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | function build_mingw64() { |
---|
| 94 | TARGET=win64 |
---|
| 95 | export CC=x86_64-w64-mingw32-gcc |
---|
| 96 | build_mingw |
---|
| 97 | } |
---|
[6b7f54d] | 98 | |
---|
[4309424] | 99 | # fetch waf if needed |
---|
| 100 | [ -f "waf" ] || make getwaf |
---|
[6b7f54d] | 101 | |
---|
[4309424] | 102 | # first build without ffmpeg |
---|
| 103 | build_mingw32 |
---|
| 104 | build_mingw64 |
---|
[6b7f54d] | 105 | |
---|
[4309424] | 106 | # then build against ffmpeg |
---|
| 107 | WITH_FFMEG=1 |
---|
| 108 | build_mingw32 |
---|
| 109 | build_mingw64 |
---|
[4f64069] | 110 | |
---|
| 111 | set +x |
---|
| 112 | echo "" |
---|
| 113 | echo "All done! The following files were generated:" |
---|
| 114 | echo "" |
---|
| 115 | ls -lart aubio*.zip* |
---|