]> sigrok.org Git - sigrok-util.git/blob - cross-compile/mingw/sigrok-cross-mingw
sigrok-cross-mingw: Use VERBOSE=1 for PulseView.
[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 # The path where your MXE directory is located.
23 MXE=$HOME/mxe-git
24
25 # The path where the cross-compiled packages will be installed.
26 PREFIX=$HOME/sr_mingw
27
28 # The path where to download files to and where to build packages.
29 BUILDDIR=./sr_mingw_build
30
31 # You usually don't need to change anything below this line.
32
33 # -----------------------------------------------------------------------------
34
35 VER_LIBUSB_1_0=1.0.9
36
37 SF_MIRROR=switch.dl.sourceforge.net
38
39 # -----------------------------------------------------------------------------
40
41 # We need to find tools in the toolchain and in the install directory.
42 export PATH=$PREFIX/bin:$MXE/usr/bin:$PATH
43
44 P="$PREFIX/lib/pkgconfig"
45 P2="$MXE/usr/i686-pc-mingw32/lib/pkgconfig"
46 C="--host=i686-pc-mingw32 --prefix=$PREFIX"
47 CM="-DCMAKE_TOOLCHAIN_FILE=$MXE/usr/i686-pc-mingw32/share/cmake/mxe-conf.cmake"
48 L="--disable-shared --enable-static"
49
50 # Remove build directory contents (if any) and create a new build dir.
51 rm -rf $BUILDDIR
52 mkdir $BUILDDIR
53 cd $BUILDDIR
54
55 # -----------------------------------------------------------------------------
56
57 # libusb-1.0
58 wget http://$SF_MIRROR/project/libusb/libusb-1.0/libusb-$VER_LIBUSB_1_0/libusb-$VER_LIBUSB_1_0.tar.bz2
59 tar xfj libusb-$VER_LIBUSB_1_0.tar.bz2
60 cd libusb-$VER_LIBUSB_1_0
61 ./configure $C $L && make install
62 cd ..
63
64 # Python3
65 # Cross-compiling Python is highly non-trivial, so we avoid it for now.
66 # The download below is a repackaged tarball of the official Python 3.2.3 MSI
67 # installer for Windows: http://python.org/ftp/python/3.2.3/python-3.2.3.msi
68 # The MSI file has been installed on a Windows box and then the c:\Python32
69 # files have been stored in the Python32.tar.gz tarball.
70 mkdir -p $PREFIX
71 wget http://www.sigrok.org/tmp/Python32.tar.gz -O $PREFIX/Python32.tar.gz
72 tar xzf $PREFIX/Python32.tar.gz -C $PREFIX
73
74 # Create a dummy python3-config that points to Python32 above.
75 mkdir -p $PREFIX/bin
76 cat >$PREFIX/bin/python3-config <<EOF 
77 #!/usr/bin/python3
78 import sys
79 import getopt
80 valid_opts = ['includes', 'cflags', 'libs', 'ldflags']
81 opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
82 opt_flags = [flag for (flag, val) in opts]
83 for opt in opt_flags: 
84     if opt in ('--includes', '--cflags'):
85         print('-I$PREFIX/Python32/include')
86     elif opt in ('--libs', '--ldflags'):
87         print('-L$PREFIX/Python32/libs -lpython32')
88 EOF
89 chmod 755 $PREFIX/bin/python3-config
90
91 # libsigrok
92 git clone git://sigrok.org/libsigrok
93 cd libsigrok
94 ./autogen.sh
95 PKG_CONFIG_PATH_i686_pc_mingw32=$P ./configure $C $L && make install
96 cd ..
97
98 # libsigrokdecode
99 git clone git://sigrok.org/libsigrokdecode
100 cd libsigrokdecode
101 ./autogen.sh
102 PYTHON3_CONFIG=$PREFIX/bin/python3-config PKG_CONFIG_PATH_i686_pc_mingw32=$P ./configure $C $L && make install
103 cd ..
104
105 # sigrok-cli
106 git clone git://sigrok.org/sigrok-cli
107 cd sigrok-cli
108 ./autogen.sh
109 PKG_CONFIG_PATH_i686_pc_mingw32=$P:$P2 ./configure $C && make install
110 cd ..
111
112 ## TODO: Doesn't fully work, yet.
113 ## # sigrok-qt
114 ## git clone git://sigrok.org/sigrok-qt
115 ## cd sigrok-qt
116 ## PKG_CONFIG_PATH_i686_pc_mingw32=$P:$P2 qmake -spec win32-g++
117 ## make
118 ## # TODO: make install
119 ## cd ..
120
121 # # sigrok-gtk
122 # git clone git://sigrok.org/sigrok-gtk
123 # cd sigrok-gtk
124 # ./autogen.sh
125 # PKG_CONFIG_PATH_i686_pc_mingw32=$P:$P2 ./configure $C && make install
126 # cd ..
127
128 # PulseView
129 git clone git://sigrok.org/pulseview
130 cd pulseview
131 # TODO: Append (not prepend) "-llzma -llcms" to the linker.
132 PKG_CONFIG_PATH_i686_pc_mingw32=$P:$P2 cmake $CM -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -DDISABLE_WERROR=y . && make install VERBOSE=1
133 cd ..
134