add a variable to specify windows build concurrency
[ardour.git] / tools / x-win / compile.sh
1 #!/bin/bash
2
3 # we assuem this script is <ardour-src>/tools/x-win/compile.sh
4 pushd "`/usr/bin/dirname \"$0\"`" > /dev/null; this_script_dir="`pwd`"; popd > /dev/null
5 cd $this_script_dir/../..
6 test -f gtk2_ardour/wscript || exit 1
7
8 : ${XARCH=i686} # or x86_64
9 : ${ROOT=/home/ardour}
10 : ${MAKEFLAGS=-j4}
11
12 if test "$XARCH" = "x86_64" -o "$XARCH" = "amd64"; then
13         echo "Target: 64bit Windows (x86_64)"
14         XPREFIX=x86_64-w64-mingw32
15         WARCH=w64
16         DEBIANPKGS="mingw-w64"
17 else
18         echo "Target: 32 Windows (i686)"
19         XPREFIX=i686-w64-mingw32
20         WARCH=w32
21         DEBIANPKGS="gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools mingw32"
22 fi
23
24 : ${PREFIX=${ROOT}/win-stack-$WARCH}
25
26 if test -z "${ARDOURCFG}"; then
27         ARDOURCFG="--with-dummy --windows-vst"
28         if test -f ${PREFIX}/include/pa_asio.h; then
29                 ARDOURCFG="$ARDOURCFG --with-wavesbackend"
30         fi
31 fi
32
33 if [ "$(id -u)" = "0" ]; then
34         apt-get -y install build-essential \
35                 ${DEBIANPKGS} \
36                 git autoconf automake libtool pkg-config yasm python
37
38         #fixup mingw64 ccache for now
39         if test -d /usr/lib/ccache -a -f /usr/bin/ccache; then
40                 export PATH="/usr/lib/ccache:${PATH}"
41                 cd /usr/lib/ccache
42                 test -L ${XPREFIX}-gcc || ln -s ../../bin/ccache ${XPREFIX}-gcc
43                 test -L ${XPREFIX}-g++ || ln -s ../../bin/ccache ${XPREFIX}-g++
44                 cd - > /dev/null
45         fi
46 fi
47
48 ################################################################################
49 set -e
50 unset PKG_CONFIG_PATH
51 export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
52
53 export CC=${XPREFIX}-gcc
54 export CXX=${XPREFIX}-g++
55 export CPP=${XPREFIX}-cpp
56 export AR=${XPREFIX}-ar
57 export LD=${XPREFIX}-ld
58 export NM=${XPREFIX}-nm
59 export AS=${XPREFIX}-as
60 export STRIP=${XPREFIX}-strip
61 export WINRC=${XPREFIX}-windres
62 export RANLIB=${XPREFIX}-ranlib
63 export DLLTOOL=${XPREFIX}-dlltool
64
65
66 CFLAGS="-mstackrealign" \
67 CXXFLAGS="-mstackrealign" \
68 LDFLAGS="-L${PREFIX}/lib" ./waf configure \
69         --dist-target=mingw \
70         --also-include=${PREFIX}/include \
71         $ARDOURCFG \
72         --prefix=${PREFIX}
73 ./waf ${CONCURRENCY}