]> sigrok.org Git - sigrok-util.git/blob - cross-compile/msys2/sigrok-native-msys2
sigrok-native-appimage: Add local copy of 'excludelist'.
[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 REPO_BASE="git://sigrok.org"
62
63 # Remove build directory contents (if any) and create a new build dir.
64 rm -rf $BUILDDIR
65 mkdir $BUILDDIR
66 cd $BUILDDIR
67
68 # -----------------------------------------------------------------------------
69
70 if [ "x$1" = "xprepare" ]; then
71   # Update package list, install/update all requirements.
72   pacman -Sy
73   pacman -S \
74         autoconf automake libtool make pkg-config wget patch \
75         $W-toolchain $W-glib2 $W-glibmm $W-libusb $W-check $W-boost \
76         $W-libzip $W-doxygen $W-python3 $W-python3-numpy $W-python3-gobject \
77         $W-python3-setuptools $W-swig $W-qt5-static $W-cmake
78   exit
79 fi
80
81 # -----------------------------------------------------------------------------
82
83 # libusb
84 $GIT_CLONE git://github.com/dickens/libusb -b event-abstraction-v4
85 cd libusb
86 ./bootstrap.sh
87 ./configure $C $L
88 make -j1 $V
89 make install $V
90 cd ..
91
92 # libserialport
93 $GIT_CLONE $REPO_BASE/libserialport
94 cd libserialport
95 ./autogen.sh
96 mkdir build
97 cd build
98 ../configure $C $L
99 $SB make $PARALLEL $V
100 make install $V
101 cd ../..
102
103 # libsigrok
104 mkdir -p $PYPATH
105 $GIT_CLONE $REPO_BASE/libsigrok
106 cd libsigrok
107 ./autogen.sh
108 mkdir build
109 cd build
110 PKG_CONFIG_PATH=$P ../configure $C $L --disable-python
111 $SB make $PARALLEL $V
112 PYTHONPATH=$PYPATH $SB make install $V
113 # $SB make check $V # TODO
114 cd ../..
115
116 # libsigrokdecode
117 $GIT_CLONE $REPO_BASE/libsigrokdecode
118 cd libsigrokdecode
119 ./autogen.sh
120 mkdir build
121 cd build
122 PKG_CONFIG_PATH=$P ../configure $C $L
123 $SB make $PARALLEL $V
124 make install $V
125 # $SB make check $V # TODO
126 cd ../..
127
128 # sigrok-firmware
129 $GIT_CLONE $REPO_BASE/sigrok-firmware
130 cd sigrok-firmware
131 ./autogen.sh
132 mkdir build
133 cd build
134 # Nothing gets cross-compiled here, we just need 'make install' basically.
135 ../configure $C
136 make install $V
137 cd ../..
138
139 # sigrok-firmware-fx2lafw
140 $WGET http://sigrok.org/download/binary/sigrok-firmware-fx2lafw/sigrok-firmware-fx2lafw-bin-$VER_SIGROK_FIRMWARE_FX2LAFW.tar.gz
141 tar xfz sigrok-firmware-fx2lafw-bin-$VER_SIGROK_FIRMWARE_FX2LAFW.tar.gz
142 cd sigrok-firmware-fx2lafw-bin-$VER_SIGROK_FIRMWARE_FX2LAFW
143 cp *.fw $PREFIX/share/sigrok-firmware/
144 cd ..
145
146 # TODO: Doesn't build, libsigrokdecode linking errors.
147 # # sigrok-cli
148 # $GIT_CLONE $REPO_BASE/sigrok-cli
149 # cd sigrok-cli
150 # ./autogen.sh
151 # mkdir build
152 # cd build
153 # PKG_CONFIG_PATH=$P ../configure $C $L
154 # $SB make $PARALLEL $V
155 # make install $V
156 # # makensis -DHOME=$HOME contrib/sigrok-cli_cross.nsi # TODO
157 # cd ../..
158
159 # TODO: Doesn't build, various linking errors.
160 # PulseView
161 $GIT_CLONE $REPO_BASE/pulseview
162 cd pulseview
163 mkdir build
164 cd build
165 PKG_CONFIG_PATH=$P $SB cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -DDISABLE_WERROR=y -DENABLE_TESTS=n ..
166 $SB make $PARALLEL $V
167 make install $V
168 # $SB make test $V # TODO
169 # makensis -DHOME=$HOME contrib/pulseview_cross.nsi # TODO
170 cd ../..
171