]> sigrok.org Git - sigrok-util.git/blob - cross-compile/mingw/sigrok-cross-mingw
sigrok-cross-mingw: Abort on error.
[sigrok-util.git] / cross-compile / mingw / sigrok-cross-mingw
1 #!/bin/bash
2 ##
3 ## This file is part of the sigrok-util project.
4 ##
5 ## Copyright (C) 2013 Uwe Hermann <uwe@hermann-uwe.de>
6 ##
7 ## This program is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ## GNU General Public License for more details.
16 ##
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program; if not, write to the Free Software
19 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
20 ##
21
22 set -e
23
24 # The path where your MXE directory is located.
25 MXE=$HOME/mxe-git
26
27 # The path where the cross-compiled packages will be installed.
28 PREFIX=$HOME/sr_mingw
29
30 # The path where to download files to and where to build packages.
31 BUILDDIR=./sr_mingw_build
32
33 # You usually don't need to change anything below this line.
34
35 # -----------------------------------------------------------------------------
36
37 SF_MIRROR=switch.dl.sourceforge.net
38
39 VER_LIBUSBX=1.0.17
40
41 # -----------------------------------------------------------------------------
42
43 # We need to find tools in the toolchain and in the install directory.
44 export PATH=$PREFIX/bin:$MXE/usr/bin:$PATH
45
46 P="$PREFIX/lib/pkgconfig"
47 P2="$MXE/usr/i686-pc-mingw32/lib/pkgconfig"
48 C="--host=i686-pc-mingw32 --prefix=$PREFIX"
49 CM="-DCMAKE_TOOLCHAIN_FILE=$MXE/usr/i686-pc-mingw32/share/cmake/mxe-conf.cmake"
50 L="--disable-shared --enable-static"
51
52 # Remove build directory contents (if any) and create a new build dir.
53 rm -rf $BUILDDIR
54 mkdir $BUILDDIR
55 cd $BUILDDIR
56
57 # -----------------------------------------------------------------------------
58
59 # Python3
60 # Cross-compiling Python is highly non-trivial, so we avoid it for now.
61 # The download below is a repackaged tarball of the official Python 3.2.3 MSI
62 # installer for Windows: http://python.org/ftp/python/3.2.3/python-3.2.3.msi
63 # The MSI file has been installed on a Windows box and then the c:\Python32
64 # files have been stored in the Python32.tar.gz tarball.
65 mkdir -p $PREFIX
66 wget http://www.sigrok.org/tmp/Python32.tar.gz -O $PREFIX/Python32.tar.gz
67 tar xzf $PREFIX/Python32.tar.gz -C $PREFIX
68
69 # Create a dummy python3-config that points to Python32 above.
70 mkdir -p $PREFIX/bin
71 cat >$PREFIX/bin/python3-config <<EOF 
72 #!/usr/bin/python3
73 import sys
74 import getopt
75 valid_opts = ['includes', 'cflags', 'libs', 'ldflags']
76 opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
77 opt_flags = [flag for (flag, val) in opts]
78 for opt in opt_flags: 
79     if opt in ('--includes', '--cflags'):
80         print('-I$PREFIX/Python32/include')
81     elif opt in ('--libs', '--ldflags'):
82         print('-L$PREFIX/Python32/libs -lpython32')
83 EOF
84 chmod 755 $PREFIX/bin/python3-config
85
86 # Download the Python 3.2.3 MSI installer (needed for NSIS runs).
87 wget -c http://python.org/ftp/python/3.2.3/python-3.2.3.msi \
88      -O $PREFIX/python-3.2.3.msi
89
90 # libusbx
91 wget http://$SF_MIRROR/project/libusbx/releases/$VER_LIBUSBX/source/libusbx-$VER_LIBUSBX.tar.bz2
92 tar xfj libusbx-$VER_LIBUSBX.tar.bz2
93 cd libusbx-$VER_LIBUSBX
94 PKG_CONFIG_PATH_i686_pc_mingw32=$P ./configure $C $L && make install
95 cd ..
96
97 # libserialport
98 git clone git://sigrok.org/libserialport
99 cd libserialport
100 ./autogen.sh
101 PKG_CONFIG_PATH_i686_pc_mingw32=$P ./configure $C $L && make install
102 cd ..
103
104 # libsigrok
105 git clone git://sigrok.org/libsigrok
106 cd libsigrok
107 ./autogen.sh
108 PKG_CONFIG_PATH_i686_pc_mingw32=$P ./configure $C $L && make install
109 cd ..
110
111 # libsigrokdecode
112 git clone git://sigrok.org/libsigrokdecode
113 cd libsigrokdecode
114 ./autogen.sh
115 PYTHON3_CONFIG=$PREFIX/bin/python3-config PKG_CONFIG_PATH_i686_pc_mingw32=$P ./configure $C $L && make install
116 cd ..
117
118 # sigrok-cli
119 git clone git://sigrok.org/sigrok-cli
120 cd sigrok-cli
121 ./autogen.sh
122 PKG_CONFIG_PATH_i686_pc_mingw32=$P:$P2 ./configure $C && make install
123 makensis -DHOME=$HOME contrib/sigrok-cli_cross.nsi
124 cd ..
125
126 # PulseView
127 git clone git://sigrok.org/pulseview
128 cd pulseview
129 patch -p1 < ../../pulseview.patch
130 PKG_CONFIG_PATH_i686_pc_mingw32=$P:$P2 cmake $CM -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -DDISABLE_WERROR=y . && make install VERBOSE=1
131 makensis -DHOME=$HOME contrib/pulseview_cross.nsi
132 cd ..
133