3 # This script cross compiles aubio for windows using mingw, four times:
5 # - 32 and 64 bits with no external dependencies
6 # - 32 and 64 bits against ffmpeg
8 # On debian or ubuntu, you will want to 'apt-get install gcc-mingw-w64'
13 python this_version.py -v
14 VERSION=`python $PWD/this_version.py -v`
16 FFMPEG_BUILDS_URL="https://ffmpeg.zeranoe.com/builds"
17 FFMPEG_DEFAULT="3.3.3"
19 # define some default CFLAGS
20 DEF_CFLAGS="-Os -I/usr/share/mingw-w64"
24 # disable external deps to make sure we don't try to use the host package
25 WAFOPTS+=" --disable-samplerate --disable-jack --disable-sndfile"
27 WAFOPTS+=" --disable-avcodec"
28 # install without a prefix
29 WAFOPTS+=" --prefix=/"
30 # compile the tests, but fake running them
31 # passing this option WAFOPTS fails (escaping?), added in actual waf call below
32 #WAFOPTS+=" --testcmd='echo %s'"
37 #WAFOPTS+=" --notests"
39 function fetch_ffpmeg() {
40 ## manually add ffmpeg (no pkg-config .pc files in bins)
41 [ -n "$FFMPEG_VERSION" ] || FFMPEG_VERSION=$FFMPEG_DEFAULT
42 FFMPEG_TARBALL="$PWD/ffmpeg-$FFMPEG_VERSION-$TARGET-dev.zip"
43 FFMPEG_BINARIES="${FFMPEG_TARBALL%%.zip}"
44 if [ ! -d "$FFMPEG_BINARIES" ]
46 if [ ! -f "$FFMPEG_TARBALL" ]
48 curl -O $FFMPEG_BUILDS_URL/$TARGET/dev/ffmpeg-$FFMPEG_VERSION-$TARGET-dev.zip
50 echo "using $FFMPEG_TARBALL"
52 unzip -x $FFMPEG_TARBALL
54 echo "using $FFMPEG_BINARIES"
58 function get_cflags() {
60 LDFLAGS="$DEF_LDFLAGS"
61 if [ -n "$WITH_FFMEG" ]
64 CFLAGS+=" -DHAVE_LIBAV=1 -DHAVE_SWRESAMPLE=1"
65 CFLAGS+=" -I$FFMPEG_BINARIES/include"
66 LDFLAGS+=" -lavcodec -lavformat -lavutil -lswresample"
67 LDFLAGS+=" -L$FFMPEG_BINARIES/lib"
71 function build_mingw() {
72 DESTDIR="$PWD/aubio-$VERSION-$TARGET"
73 [ -n "$WITH_FFMEG" ] && DESTDIR+="-ffmpeg"
74 [ -f $DESTDIR.zip ] && echo "Remove existing $DESTDIR.zip first" && exit 1
75 [ -d $DESTDIR ] && rm -rf $DESTDIR
76 WAFOPTS_TGT="$WAFOPTS --destdir=$DESTDIR"
77 WAFOPTS_TGT+=" --with-target-platform=$TARGET"
79 CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
80 ./waf distclean configure build install $WAFOPTS_TGT --testcmd='echo %s'
81 # fix dll location (see https://github.com/waf-project/waf/issues/1860)
82 mv $DESTDIR/lib/libaubio-5.dll $DESTDIR/bin
83 mv $DESTDIR/lib/libaubio-5.def $DESTDIR/bin
84 zip -r $DESTDIR.zip `basename $DESTDIR`
86 sha256sum $DESTDIR.zip > $DESTDIR.zip.sha256
89 function build_mingw32() {
91 export CC=i686-w64-mingw32-gcc
92 export NM=i686-w64-mingw32-nm
96 function build_mingw64() {
98 export CC=x86_64-w64-mingw32-gcc
99 export NM=x86_64-w64-mingw32-nm
103 # fetch waf if needed
104 [ -f "waf" ] || make getwaf
106 # first build without ffmpeg
110 # then build against ffmpeg
117 echo "All done! The following files were generated:"