#! /bin/bash # This script cross compiles aubio for windows using mingw, four times: # # - 32 and 64 bits with no external dependencies # - 32 and 64 bits against ffmpeg # # On debian or ubuntu, you will want to 'apt-get install gcc-mingw-w64' set -e set -x source VERSION VERSION="$AUBIO_MAJOR_VERSION.$AUBIO_MINOR_VERSION.$AUBIO_PATCH_VERSION" VERSION+="$AUBIO_VERSION_STATUS" FFMPEG_BUILDS_URL="https://ffmpeg.zeranoe.com/builds" FFMPEG_DEFAULT="20170315-6c4665d" # define some default CFLAGS DEF_CFLAGS="-Os -I/usr/share/mingw-w64" DEF_LDFLAGS="" WAFOPTS="" # disable external deps to make sure we don't try to use the host package WAFOPTS+=" --disable-samplerate --disable-jack --disable-sndfile" # enable ffmpeg build WAFOPTS+=" --disable-avcodec" # install without a prefix WAFOPTS+=" --prefix=/" # compile the tests, but fake running them # passing this option WAFOPTS fails (escaping?), added in actual waf call below #WAFOPTS+=" --testcmd='echo %s'" # debugging #WAFOPTS+=" -v" #WAFOPTS+=" -j1" #WAFOPTS+=" --notests" function fetch_ffpmeg() { ## manually add ffmpeg (no pkg-config .pc files in bins) [ -n "$FFMPEG_VERSION" ] || FFMPEG_VERSION=$FFMPEG_DEFAULT FFMPEG_TARBALL="$PWD/ffmpeg-$FFMPEG_VERSION-$TARGET-dev.zip" FFMPEG_BINARIES="${FFMPEG_TARBALL%%.zip}" if [ ! -d "$FFMPEG_BINARIES" ] then if [ ! -f "$FFMPEG_TARBALL" ] then curl -O $FFMPEG_BUILDS_URL/$TARGET/dev/ffmpeg-$FFMPEG_VERSION-$TARGET-dev.zip else echo "using $FFMPEG_TARBALL" fi unzip -x $FFMPEG_TARBALL else echo "using $FFMPEG_BINARIES" fi } function get_cflags() { CFLAGS="$DEF_CFLAGS" LDFLAGS="$DEF_LDFLAGS" if [ -n "$WITH_FFMEG" ] then fetch_ffpmeg CFLAGS+=" -DHAVE_LIBAV=1 -DHAVE_SWRESAMPLE=1" CFLAGS+=" -I$FFMPEG_BINARIES/include" LDFLAGS+=" -lavcodec -lavformat -lavutil -lswresample" LDFLAGS+=" -L$FFMPEG_BINARIES/lib" fi } function build_mingw() { DESTDIR="$PWD/aubio-$VERSION-$TARGET" [ -n "$WITH_FFMEG" ] && DESTDIR+="-ffmpeg" [ -d $DESTDIR ] && rm -rf $DESTDIR $DESTDIR.zip WAFOPTS_TGT="$WAFOPTS --destdir=$DESTDIR" WAFOPTS_TGT+=" --with-target-platform=$TARGET" get_cflags CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \ ./waf distclean configure build install $WAFOPTS_TGT --testcmd='echo %s' zip -r $DESTDIR.zip `basename $DESTDIR` rm -rf $DESTDIR sha256sum $DESTDIR.zip > $DESTDIR.zip.sha256 } function build_mingw32() { TARGET=win32 export CC=i686-w64-mingw32-gcc build_mingw } function build_mingw64() { TARGET=win64 export CC=x86_64-w64-mingw32-gcc build_mingw } # fetch waf if needed [ -f "waf" ] || make getwaf # first build without ffmpeg build_mingw32 build_mingw64 # then build against ffmpeg WITH_FFMEG=1 build_mingw32 build_mingw64