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