untested fix for compiling waves audiobackend on case-sensitive FS with mingw.
[ardour.git] / tools / x-mingw.sh
1 #!/bin/bash
2 # this script creates a windows32 version of ardour3
3 # cross-compiled on GNU/Linux
4 #
5 # It is intended to run in a pristine chroot or VM of a minimal
6 # debian system. see http://wiki.debian.org/cowbuilder
7 #
8 ### Quick start: (host, setup cowbuilder)
9 #
10 # sudo apt-get install cowbuilder util-linux
11 # sudo mkdir -p /var/cache/pbuilder/jessie-i386/
12 #
13 # sudo i386 cowbuilder --create \
14 #     --basepath /var/cache/pbuilder/jessie-i386/base.cow \
15 #     --distribution jessie \
16 #     --debootstrapopts --arch --debootstrapopts i386
17 #
18 # sudo i386 cowbuilder --login --bindmounts /tmp \
19 #     --basepath /var/cache/pbuilder/jessie-i386/base.cow
20 #
21 ### inside cowbuilder (/tmp/ is shared wit host)
22 # /tmp/this_script.sh
23 #
24 ###############################################################################
25
26 : ${SRC=/usr/src}
27 : ${SRCDIR=/tmp/winsrc}
28 : ${PREFIX=$SRC/win-stack}
29 : ${BUILDD=$SRC/win-build}
30 : ${MAKEFLAGS=-j4}
31
32 if [ "$(id -u)" != "0" -a -z "$SUDO" ]; then
33         echo "This script must be run as root in pbuilder" 1>&2
34   echo "e.g sudo DIST=jessie ARCH=i386 linux32 cowbuilder --bindmounts /tmp --execute $0"
35         exit 1
36 fi
37
38 set -e
39
40 apt-get -y install build-essential \
41         gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools mingw32 \
42         wget git autoconf automake libtool pkg-config \
43         curl unzip ed yasm cmake zip
44
45 cd "$SRC"
46
47 ###############################################################################
48
49 mkdir -p ${SRCDIR}
50 mkdir -p ${PREFIX}
51 mkdir -p ${BUILDD}
52
53 unset PKG_CONFIG_PATH
54 export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
55 export PREFIX
56 export SRCDIR
57
58 function download {
59 echo "--- Downloading.. $2"
60 test -f ${SRCDIR}/$1 || curl -k -L -o ${SRCDIR}/$1 $2
61 }
62
63 function src {
64 download ${1}.${2} $3
65 cd ${BUILDD}
66 tar xf ${SRCDIR}/${1}.${2}
67 cd $1
68 }
69
70 function autoconfbuild {
71 set -e
72 echo "======= $(pwd) ======="
73 PATH=${PREFIX}/bin:/usr/bin:/bin:/usr/sbin:/sbin \
74         CPPFLAGS="-I${PREFIX}/include$CPPFLAGS" \
75         CFLAGS="-I${PREFIX}/include -O2$CFLAGS" \
76         CXXFLAGS="-I${PREFIX}/include -O2$CXXFLAGS" \
77         LDFLAGS="-L${PREFIX}/lib$LDFLAGS" \
78         ./configure --host=i686-w64-mingw32 --build=i386-linux \
79         --prefix=$PREFIX $@
80   make $MAKEFLAGS && make install
81 }
82
83 function wafbuild {
84 set -e
85 echo "======= $(pwd) ======="
86 PATH=${PREFIX}/bin:/usr/bin:/bin:/usr/sbin:/sbin \
87         CC=i686-w64-mingw32-gcc \
88         CXX=i686-w64-mingw32-c++ \
89         CPP=i686-w64-mingw32-cpp \
90         AR=i686-w64-mingw32-ar \
91         LD=i686-w64-mingw32-ld \
92         NM=i686-w64-mingw32-nm \
93         AS=i686-w64-mingw32-as \
94         STRIP=i686-w64-mingw32-strip \
95         RANLIB=i686-w64-mingw32-ranlib \
96         DLLTOOL=i686-w64-mingw32-dlltool \
97         ./waf configure --prefix=$PREFIX $@ \
98         && ./waf && ./waf install
99 }
100
101 ################################################################################
102 if test -z "$NOSTACK"; then
103 ################################################################################
104
105 download jack_win32.tar.xz http://robin.linuxaudio.org/jack_win32.tar.xz
106 cd "$PREFIX"
107 tar xf ${SRCDIR}/jack_win32.tar.xz
108 "$PREFIX"/update_pc_prefix.sh
109
110 download pthreads-w32-2-9-1-release.tar.gz ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.tar.gz
111 cd ${BUILDD}
112 tar xzf ${SRCDIR}/pthreads-w32-2-9-1-release.tar.gz
113 cd pthreads-w32-2-9-1-release
114 make clean GC CROSS=i686-w64-mingw32-
115 mkdir -p ${PREFIX}/bin
116 mkdir -p ${PREFIX}/lib
117 mkdir -p ${PREFIX}/include
118 cp -vf pthreadGC2.dll ${PREFIX}/bin/
119 cp -vf libpthreadGC2.a ${PREFIX}/lib/libpthread.a
120 cp -vf pthread.h sched.h ${PREFIX}/include
121
122 src zlib-1.2.7 tar.gz ftp://ftp.simplesystems.org/pub/libpng/png/src/history/zlib/zlib-1.2.7.tar.gz
123 make -fwin32/Makefile.gcc PREFIX=i686-w64-mingw32-
124 make install -fwin32/Makefile.gcc SHARED_MODE=1 \
125         INCLUDE_PATH=${PREFIX}/include \
126         LIBRARY_PATH=${PREFIX}/lib \
127         BINARY_PATH=${PREFIX}/bin
128
129 src tiff-4.0.1 tar.gz ftp://ftp.remotesensing.org/pub/libtiff/tiff-4.0.1.tar.gz
130 autoconfbuild
131
132 download jpegsrc.v9a.tar.gz http://www.ijg.org/files/jpegsrc.v9a.tar.gz
133 cd ${BUILDD}
134 tar xzf ${SRCDIR}/jpegsrc.v9a.tar.gz
135 cd jpeg-9a
136 autoconfbuild
137
138 src libogg-1.3.2 tar.gz http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz
139 autoconfbuild
140
141 src libvorbis-1.3.4 tar.gz http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz
142 autoconfbuild --disable-examples --with-ogg=${PREFIX}
143
144 src flac-1.2.1 tar.gz http://downloads.xiph.org/releases/flac/flac-1.2.1.tar.gz
145 ed Makefile.in << EOF
146 %s/examples / /
147 wq
148 EOF
149 autoconfbuild
150 # add -lwsock32 to /usr/src/win-stack/lib/pkgconfig/flac.pc ??
151
152 src libsndfile-1.0.25 tar.gz http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.25.tar.gz
153 ed Makefile.in << EOF
154 %s/ examples regtest tests programs//
155 wq
156 EOF
157 LDFLAGS=" -lFLAC -lwsock32 -lvorbis -logg -lwsock32" \
158 autoconfbuild
159 ed $PREFIX/lib/pkgconfig/sndfile.pc << EOF
160 %s/ -lsndfile/ -lsndfile -lvorbis -lvorbisenc -lFLAC -logg -lwsock32/
161 wq
162 EOF
163
164 src libsamplerate-0.1.8 tar.gz http://www.mega-nerd.com/SRC/libsamplerate-0.1.8.tar.gz
165 ed Makefile.in << EOF
166 %s/ examples tests//
167 wq
168 EOF
169 autoconfbuild
170
171 src expat-2.1.0 tar.gz http://prdownloads.sourceforge.net/expat/expat-2.1.0.tar.gz
172 autoconfbuild
173
174 src libiconv-1.14 tar.gz ftp://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
175 autoconfbuild --with-included-gettext --with-libiconv-prefix=$PREFIX
176
177 src libxml2-2.7.8 tar.gz ftp://xmlsoft.org/libxslt/libxml2-2.7.8.tar.gz
178 autoconfbuild --with-threads=no
179
180 src freetype-2.5.3 tar.gz http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gz
181 autoconfbuild -with-harfbuzz=no --with-png=no
182
183 #src harfbuzz-0.9.22 tar.bz2 http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.22.tar.bz2
184 #autoconfbuild
185
186 src fontconfig-2.11.0 tar.bz2 http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.11.0.tar.bz2
187 ed Makefile.in << EOF
188 %s/conf.d test /conf.d /
189 wq
190 EOF
191 autoconfbuild
192
193 #src libpng-1.6.12 tar.gz ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.12.tar.gz
194 src libpng-1.6.12 tar.gz https://downloads.sourceforge.net/project/libpng/libpng16/1.6.12/libpng-1.6.12.tar.gz
195 autoconfbuild
196
197 src pixman-0.30.2 tar.gz http://cgit.freedesktop.org/pixman/snapshot/pixman-0.30.2.tar.gz
198 ./autogen.sh
199 autoconfbuild
200
201 src cairo-1.12.16 tar.xz http://cairographics.org/releases/cairo-1.12.16.tar.xz
202 autoconfbuild
203
204 src libffi-3.0.10 tar.gz ftp://sourceware.org/pub/libffi/libffi-3.0.10.tar.gz
205 autoconfbuild
206
207 src gettext-0.18.2 tar.gz http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.2.tar.gz
208 autoconfbuild
209
210 ################################################################################
211 apt-get -y install python gettext libglib2.0-dev # /usr/bin/msgfmt , genmarshall
212 ################################################################################
213
214 src glib-2.42.0 tar.xz  http://ftp.gnome.org/pub/gnome/sources/glib/2.42/glib-2.42.0.tar.xz
215 LIBS="-lpthread" \
216 autoconfbuild --with-pcre=internal --disable-silent-rules --with-libiconv=no
217
218 ################################################################################
219 dpkg -P gettext python || true
220 export PATH=$PREFIX/bin:$PATH
221 rm -f ${PREFIX}/lib/pkgconfig/harfbuzz.pc  || true
222 ################################################################################
223
224 src pango-1.36.8 tar.xz http://ftp.gnome.org/pub/GNOME/sources/pango/1.36/pango-1.36.8.tar.xz
225 autoconfbuild --without-x --with-included-modules=yes
226
227 src atk-2.2.0 tar.bz2 http://ftp.gnome.org/pub/GNOME/sources/atk/2.2/atk-2.2.0.tar.bz2
228 autoconfbuild --disable-rebuilds
229
230 src gdk-pixbuf-2.25.2 tar.xz http://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/2.25/gdk-pixbuf-2.25.2.tar.xz
231 autoconfbuild --disable-modules --without-gdiplus --with-included-loaders=yes
232
233 src gtk+-2.24.24 tar.xz http://ftp.gnome.org/pub/gnome/sources/gtk+/2.24/gtk+-2.24.24.tar.xz
234 ed Makefile.in << EOF
235 %s/demos / /
236 wq
237 EOF
238 autoconfbuild --disable-modules --disable-rebuilds
239
240
241 #http://ardour.org/files/gtk-engines-2.21.0.tar.gz
242 #http://ftp.gnome.org/pub/GNOME/sources/gtk-engines/2.20/gtk-engines-2.20.2.tar.bz2
243
244 ################################################################################
245 dpkg -P libglib2.0-dev libpcre3-dev || true
246 ################################################################################
247
248 src lv2-1.10.0 tar.bz2 http://lv2plug.in/spec/lv2-1.10.0.tar.bz2
249 wafbuild --no-plugins
250
251 src serd-0.20.0 tar.bz2 http://download.drobilla.net/serd-0.20.0.tar.bz2
252 wafbuild
253
254 src sord-0.12.2 tar.bz2 http://download.drobilla.net/sord-0.12.2.tar.bz2
255 ed wscript << EOF
256 %s/pthread/lpthread/
257 wq
258 EOF
259 wafbuild
260
261 src sratom-0.4.6 tar.bz2 http://download.drobilla.net/sratom-0.4.6.tar.bz2
262 wafbuild
263
264 src lilv-0.20.0 tar.bz2 http://download.drobilla.net/lilv-0.20.0.tar.bz2
265 ed wscript << EOF
266 %s/'dl'//
267 %s/win32/linux/
268 wq
269 EOF
270 wafbuild
271 ed $PREFIX/lib/pkgconfig/lilv-0.pc << EOF
272 %s/-ldl//
273 wq
274 EOF
275
276 src suil-0.8.2 tar.bz2 http://download.drobilla.net/suil-0.8.2.tar.bz2
277 wafbuild
278
279 src curl-7.35.0 tar.bz2 http://curl.haxx.se/download/curl-7.35.0.tar.bz2
280 autoconfbuild
281
282 src libsigc++-2.4.0 tar.xz http://ftp.gnome.org/pub/GNOME/sources/libsigc++/2.4/libsigc++-2.4.0.tar.xz
283 autoconfbuild
284
285 src glibmm-2.32.0 tar.xz http://ftp.gnome.org/pub/GNOME/sources/glibmm/2.32/glibmm-2.32.0.tar.xz
286 autoconfbuild
287
288 src cairomm-1.10.0 tar.gz http://cairographics.org/releases/cairomm-1.10.0.tar.gz
289 autoconfbuild
290
291 src pangomm-2.28.4 tar.xz http://ftp.acc.umu.se/pub/gnome/sources/pangomm/2.28/pangomm-2.28.4.tar.xz
292 autoconfbuild
293
294 src atkmm-2.22.6 tar.xz http://ftp.gnome.org/pub/GNOME/sources/atkmm/2.22/atkmm-2.22.6.tar.xz
295 autoconfbuild
296
297 src gtkmm-2.24.4 tar.xz http://ftp.acc.umu.se/pub/GNOME/sources/gtkmm/2.24/gtkmm-2.24.4.tar.xz
298 autoconfbuild
299
300 src fftw-3.3.4 tar.gz http://www.fftw.org/fftw-3.3.4.tar.gz
301 autoconfbuild --enable-single --enable-float --enable-type-prefix --enable-sse --with-our-malloc --enable-avx --disable-mpi
302 make clean
303 autoconfbuild --enable-type-prefix --with-our-malloc --enable-avx --disable-mpi
304
305 ################################################################################
306 src taglib-1.9.1 tar.gz http://taglib.github.io/releases/taglib-1.9.1.tar.gz
307 ed CMakeLists.txt << EOF
308 0i
309 set(CMAKE_SYSTEM_NAME Windows)
310 set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
311 set(CMAKE_CXX_COMPILER i686-w64-mingw32-c++)
312 set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
313 .
314 wq
315 EOF
316 mkdir build && cd build
317         cmake \
318                 -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_RELEASE_TYPE=Release \
319                 -DCMAKE_SYSTEM_NAME=Windows -DZLIB_ROOT=$PREFIX \
320                 ..
321 make $MAKEFLAGS && make install
322
323 # windows target does not create .pc file...
324 cat > $PREFIX/lib/pkgconfig/taglib.pc << EOF
325 prefix=$PREFIX
326 exec_prefix=\${prefix}
327 libdir=\${exec_prefix}/lib
328 includedir=\${prefix}/include
329
330 Name: TagLib
331 Description: Audio meta-data library
332 Requires:
333 Version: 1.9.1
334 Libs: -L\${libdir}/lib -ltag
335 Cflags: -I\${includedir}/include/taglib
336 EOF
337
338 ################################################################################
339 #git://liblo.git.sourceforge.net/gitroot/liblo/liblo
340 src liblo-0.28 tar.gz http://downloads.sourceforge.net/liblo/liblo-0.28.tar.gz
341 PATH=${PREFIX}/bin:/usr/bin:/bin:/usr/sbin:/sbin \
342         CPPFLAGS="-I${PREFIX}/include" \
343         CFLAGS="-I${PREFIX}/include" \
344         CXXFLAGS="-I${PREFIX}/include" \
345         LDFLAGS="-L${PREFIX}/lib" \
346         ./configure --host=i686-w64-mingw32 --build=i386-linux --prefix=$PREFIX --enable-shared $@
347 ed src/Makefile << EOF
348 /noinst_PROGRAMS
349 .,+3d
350 wq
351 EOF
352 ed Makefile << EOF
353 %s/examples//
354 wq
355 EOF
356 make $MAKEFLAGS && make install
357
358 ################################################################################
359 src boost_1_49_0 tar.bz2 http://sourceforge.net/projects/boost/files/boost/1.49.0/boost_1_49_0.tar.bz2
360 ./bootstrap.sh --prefix=$PREFIX
361 echo "using gcc : 4.7 : i686-w64-mingw32-g++ :
362 <rc>i686-w64-mingw32-windres
363 <archiver>i686-w64-mingw32-ar
364 ;" > user-config.jam
365 #       PTW32_INCLUDE=${PREFIX}/include \
366 #       PTW32_LIB=${PREFIX}/lib  \
367         ./b2 --prefix=$PREFIX \
368         toolset=gcc \
369         target-os=windows \
370         variant=release \
371         threading=multi \
372         threadapi=win32 \
373         link=shared \
374         runtime-link=shared \
375         --with-exception \
376         --with-regex \
377         --layout=tagged \
378         --user-config=user-config.jam \
379   -j 4 install
380
381 ################################################################################
382 download ladspa.h http://www.ladspa.org/ladspa_sdk/ladspa.h.txt
383 cp ${SRCDIR}/ladspa.h $PREFIX/include/ladspa.h
384 ################################################################################
385
386 src vamp-plugin-sdk-2.5 tar.gz http://code.soundsoftware.ac.uk/attachments/download/690/vamp-plugin-sdk-2.5.tar.gz
387 ed Makefile.in << EOF
388 %s/= ar/= i686-w64-mingw32-ar/
389 %s/= ranlib/= i686-w64-mingw32-ranlib/
390 wq
391 EOF
392 MAKEFLAGS="sdk -j4" autoconfbuild
393 ed $PREFIX/lib/pkgconfig/vamp-hostsdk.pc << EOF
394 %s/-ldl//
395 wq
396 EOF
397
398 src rubberband-1.8.1 tar.bz2 http://code.breakfastquay.com/attachments/download/34/rubberband-1.8.1.tar.bz2
399 ed Makefile.in << EOF
400 %s/= ar/= i686-w64-mingw32-ar/
401 wq
402 EOF
403 autoconfbuild
404 ed $PREFIX/lib/pkgconfig/rubberband.pc << EOF
405 %s/ -lrubberband/ -lrubberband -lfftw3/
406 wq
407 EOF
408
409 src mingw-libgnurx-2.5.1 tar.gz http://sourceforge.net/projects/mingw/files/Other/UserContributed/regex/mingw-regex-2.5.1/mingw-libgnurx-2.5.1-src.tar.gz/download
410 autoconfbuild
411
412 src aubio-0.3.2 tar.gz http://aubio.org/pub/aubio-0.3.2 tar.gz
413 ed Makefile.in << EOF
414 %s/examples / /
415 wq
416 EOF
417 autoconfbuild
418 ed $PREFIX/lib/pkgconfig/aubio.pc << EOF
419 %s/ -laubio/ -laubio -lfftw3f/
420 wq
421 EOF
422
423 src portaudio tgz http://portaudio.com/archives/pa_stable_v19_20140130.tgz
424 autoconfbuild
425
426 ################################################################################
427 fi  # $NOSTACK
428 ################################################################################
429 ################################################################################
430
431
432 cd ${SRC}
433 ARDOURSRC=ardour-w32
434 git clone -b cairocanvas git://git.ardour.org/ardour/ardour.git $ARDOURSRC || true
435 cd ${ARDOURSRC}
436
437 export CC=i686-w64-mingw32-gcc
438 export CXX=i686-w64-mingw32-c++
439 export CPP=i686-w64-mingw32-cpp
440 export AR=i686-w64-mingw32-ar
441 export LD=i686-w64-mingw32-ld
442 export NM=i686-w64-mingw32-nm
443 export AS=i686-w64-mingw32-as
444 export STRIP=i686-w64-mingw32-strip
445 export RANLIB=i686-w64-mingw32-ranlib
446 export DLLTOOL=i686-w64-mingw32-dlltool
447
448 LDFLAGS="-L${PREFIX}/lib" ./waf configure \
449         --dist-target=mingw --windows-vst \
450         --also-include=${PREFIX}/include \
451         --with-dummy \
452         --prefix=${PREFIX}
453 ./waf
454 ./waf install
455
456 ################################################################################
457 ################################################################################
458 ################################################################################
459
460 # somewhat whacky solution to zip it all up..
461 # TODO: NSIS to the rescue
462
463 DESTDIR=/tmp/a3win
464 ALIBDIR=$DESTDIR/lib/ardour3
465
466 echo " === DEPLOY to $DESTDIR"
467
468 rm -rf $DESTDIR
469 mkdir -p $DESTDIR/bin
470 mkdir -p $DESTDIR/share/
471 mkdir -p $ALIBDIR/surfaces
472 mkdir -p $ALIBDIR/backends
473 mkdir -p $ALIBDIR/lv2
474 mkdir -p $ALIBDIR/panners
475 mkdir -p $ALIBDIR/fst
476
477 cp build/libs/gtkmm2ext/gtkmm2ext-0.dll $DESTDIR/bin/
478 cp build/libs/midi++2/midipp-4.dll $DESTDIR/bin/
479 cp build/libs/evoral/evoral-0.dll $DESTDIR/bin/
480 cp build/libs/ardour/ardour-3.dll $DESTDIR/bin/
481 cp build/libs/timecode/timecode.dll $DESTDIR/bin/
482 cp build/libs/qm-dsp/qmdsp-0.dll $DESTDIR/bin/
483 cp build/libs/canvas/canvas-0.dll $DESTDIR/bin/
484 cp build/libs/pbd/pbd-4.dll $DESTDIR/bin/
485 cp build/libs/audiographer/audiographer-0.dll $DESTDIR/bin/
486 cp build/libs/fst/ardour-vst-scanner.exe $ALIBDIR/fst/
487 cp build/gtk2_ardour/ardour-*.exe $DESTDIR/bin/ardour.exe
488 cp build/libs/clearlooks-newer/clearlooks.dll $DESTDIR/bin/
489
490 cp $PREFIX/bin/*dll $DESTDIR/bin/
491 cp $PREFIX/lib/*dll $DESTDIR/bin/
492 rm -rf $DESTDIR/bin/libjack.dll
493
494 cp `find build/libs/surfaces/ -iname "*.dll"` $ALIBDIR/surfaces/
495 cp `find build/libs/backends/ -iname "*.dll"` $ALIBDIR/backends/
496 cp `find build/libs/panners/ -iname "*.dll"` $ALIBDIR/panners/
497 cp -r build/libs/LV2/* $DESTDIR/lib/lv2/
498
499 mv $ALIBDIR/surfaces/ardourcp-4.dll $DESTDIR/bin/
500
501 # TODO use -static-libgcc -static-libstdc++
502 cp /usr/lib/gcc/i686-w64-mingw32/4.6/libgcc_s_sjlj-1.dll /$DESTDIR/bin/
503 cp /usr/lib/gcc/i686-w64-mingw32/4.6/libstdc++-6.dll /$DESTDIR/bin/
504
505 cp -r $PREFIX/share/ardour3 $DESTDIR/share/
506 cp -r $PREFIX/etc/ardour3/* $DESTDIR/share/ardour3/
507
508 # parser errors: "DOCTYPE improperly terminated" - probably '\r\n' ??
509 rm -rf $DESTDIR/share/ardour3/patchfiles
510 rm -rf $DESTDIR/share/ardour3/midi_maps
511
512 du -sch $DESTDIR
513
514 ################################################################################
515 cd /tmp/ ; rm -rf a3win.zip ; zip -r a3win.zip a3win/
516 ls -l a3win.zip