The return of the w64 debug build
[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         if test -f ${PREFIX}/include/pa_asio.h; then
28                 ARDOURCFG="--windows-vst --with-backends=jack,dummy,wavesaudio"
29         else
30                 ARDOURCFG="--windows-vst --with-backends=jack,dummy"
31         fi
32 fi
33
34 if [ "$(id -u)" = "0" ]; then
35         apt-get -qq -y install build-essential \
36                 ${DEBIANPKGS} \
37                 git autoconf automake libtool pkg-config yasm python
38
39         #fixup mingw64 ccache for now
40         if test -d /usr/lib/ccache -a -f /usr/bin/ccache; then
41                 export PATH="/usr/lib/ccache:${PATH}"
42                 cd /usr/lib/ccache
43                 test -L ${XPREFIX}-gcc || ln -s ../../bin/ccache ${XPREFIX}-gcc
44                 test -L ${XPREFIX}-g++ || ln -s ../../bin/ccache ${XPREFIX}-g++
45                 cd - > /dev/null
46         fi
47 fi
48
49 ################################################################################
50 set -e
51 unset PKG_CONFIG_PATH
52 export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
53
54 export CC=${XPREFIX}-gcc
55 export CXX=${XPREFIX}-g++
56 export CPP=${XPREFIX}-cpp
57 export AR=${XPREFIX}-ar
58 export LD=${XPREFIX}-ld
59 export NM=${XPREFIX}-nm
60 export AS=${XPREFIX}-as
61 export STRIP=${XPREFIX}-strip
62 export WINRC=${XPREFIX}-windres
63 export RANLIB=${XPREFIX}-ranlib
64 export DLLTOOL=${XPREFIX}-dlltool
65
66 if grep -q optimize <<<"$ARDOURCFG"; then
67         OPT=""
68 else
69         #debug-build luabindings.cc, has > 60k symbols.
70         # -Wa,-mbig-obj has an unreasonable long build-time
71         # -Og to the rescue.
72         OPT=" -Og"
73 fi
74
75 CFLAGS="-mstackrealign$BIGOBJ" \
76 CXXFLAGS="-mstackrealign$BIGOBJ" \
77 LDFLAGS="-L${PREFIX}/lib" ./waf configure \
78         --keepflags \
79         --dist-target=mingw \
80         --also-include=${PREFIX}/include \
81         $ARDOURCFG \
82         --prefix=${PREFIX}
83 ./waf ${CONCURRENCY}
84
85 if [ "$(id -u)" = "0" ]; then
86         apt-get -qq -y install gettext
87 fi
88 echo " === build complete, creating translations"
89 ./waf i18n
90 echo " === done"