]> sigrok.org Git - sigrok-util.git/blob - cross-compile/msys2/sigrok-native-msys2
81532124d88fe4c426079fe02f3de7d175e475c7
[sigrok-util.git] / cross-compile / msys2 / sigrok-native-msys2
1 #!/bin/sh
2 ##
3 ## This file is part of the sigrok-util project.
4 ##
5 ## Copyright (C) 2016 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, see <http://www.gnu.org/licenses/>.
19 ##
20
21 set -e
22
23 # Build target: "i686" (32bit) or "x86_64" (64bit).
24 TARGET="i686"
25
26 # The path where the compiled packages will be installed.
27 PREFIX=$HOME/sr_msys2
28
29 # The path where to download files to and where to build packages.
30 BUILDDIR=./build
31
32 # The path where the libsigrok Python bindings will be installed.
33 PYPATH=$PREFIX/lib/python2.7/site-packages
34
35 # Edit this to control verbose build output.
36 # V="V=1 VERBOSE=1"
37
38 # Edit this to enable/disable/modify parallel compiles.
39 PARALLEL="-j 2"
40
41 # You usually don't need to change anything below this line.
42
43 # -----------------------------------------------------------------------------
44
45 VER_SIGROK_FIRMWARE_FX2LAFW=0.1.3
46
47 # -----------------------------------------------------------------------------
48
49 P="$PREFIX/lib/pkgconfig"
50 C="$C --prefix=$PREFIX"
51 L="--disable-shared --enable-static"
52
53 # Path to Qt binaries (needed for cmake to find the Qt libs).
54 PATH="/mingw32/qt5-static/bin:$PATH"
55
56 W="mingw-w64-$TARGET"
57
58 WGET="wget -c --quiet"
59 GIT_CLONE="git clone --depth=1"
60
61 # Remove build directory contents (if any) and create a new build dir.
62 rm -rf $BUILDDIR
63 mkdir $BUILDDIR
64 cd $BUILDDIR
65
66 # -----------------------------------------------------------------------------
67
68 if [ "x$1" = "xprepare" ]; then
69   # Update package list, install/update all requirements.
70   pacman -Sy
71   pacman -S \
72         autoconf automake libtool make pkg-config wget patch \
73         $W-toolchain $W-glib2 $W-glibmm $W-libusb $W-check $W-boost \
74         $W-libzip $W-doxygen $W-python3 $W-python3-numpy $W-python3-gobject \
75         $W-python3-setuptools $W-swig $W-qt5-static $W-cmake
76   exit
77 fi
78
79 # -----------------------------------------------------------------------------
80
81 # libusb
82 $GIT_CLONE git://github.com/dickens/libusb -b event-abstraction-v4
83 cd libusb
84 ./bootstrap.sh
85 ./configure $C $L
86 make -j1 $V
87 make install $V
88 cd ..
89
90 # libserialport
91 $GIT_CLONE git://sigrok.org/libserialport
92 cd libserialport
93 ./autogen.sh
94 mkdir build
95 cd build
96 ../configure $C $L
97 $SB make $PARALLEL $V
98 make install $V
99 cd ../..
100
101 # libsigrok
102 mkdir -p $PYPATH
103 $GIT_CLONE git://sigrok.org/libsigrok
104 cd libsigrok
105 ./autogen.sh
106 mkdir build
107 cd build
108 PKG_CONFIG_PATH=$P ../configure $C $L --disable-python
109 $SB make $PARALLEL $V
110 PYTHONPATH=$PYPATH $SB make install $V
111 # $SB make check $V # TODO
112 cd ../..
113
114 # libsigrokdecode
115 $GIT_CLONE git://sigrok.org/libsigrokdecode
116 cd libsigrokdecode
117 ./autogen.sh
118 mkdir build
119 cd build
120 PKG_CONFIG_PATH=$P ../configure $C $L
121 $SB make $PARALLEL $V
122 make install $V
123 # $SB make check $V # TODO
124 cd ../..
125
126 # sigrok-firmware
127 $GIT_CLONE git://sigrok.org/sigrok-firmware
128 cd sigrok-firmware
129 ./autogen.sh
130 mkdir build
131 cd build
132 # Nothing gets cross-compiled here, we just need 'make install' basically.
133 ../configure $C
134 make install $V
135 cd ../..
136
137 # sigrok-firmware-fx2lafw
138 $WGET http://sigrok.org/download/binary/sigrok-firmware-fx2lafw/sigrok-firmware-fx2lafw-bin-$VER_SIGROK_FIRMWARE_FX2LAFW.tar.gz
139 tar xfz sigrok-firmware-fx2lafw-bin-$VER_SIGROK_FIRMWARE_FX2LAFW.tar.gz
140 cd sigrok-firmware-fx2lafw-bin-$VER_SIGROK_FIRMWARE_FX2LAFW
141 cp *.fw $PREFIX/share/sigrok-firmware/
142 cd ..
143
144 # TODO: Doesn't build, libsigrokdecode linking errors.
145 # # sigrok-cli
146 # $GIT_CLONE git://sigrok.org/sigrok-cli
147 # cd sigrok-cli
148 # ./autogen.sh
149 # mkdir build
150 # cd build
151 # PKG_CONFIG_PATH=$P ../configure $C $L
152 # $SB make $PARALLEL $V
153 # make install $V
154 # # makensis -DHOME=$HOME contrib/sigrok-cli_cross.nsi # TODO
155 # cd ../..
156
157 # TODO: Doesn't build, various linking errors.
158 # PulseView
159 $GIT_CLONE git://sigrok.org/pulseview
160 cd pulseview
161 mkdir build
162 cd build
163 PKG_CONFIG_PATH=$P $SB cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -DDISABLE_WERROR=y -DENABLE_TESTS=n ..
164 $SB make $PARALLEL $V
165 make install $V
166 # $SB make test $V # TODO
167 # makensis -DHOME=$HOME contrib/pulseview_cross.nsi # TODO
168 cd ../..
169