]>
Commit | Line | Data |
---|---|---|
18b280b7 UH |
1 | #!/bin/sh |
2 | ## | |
3 | ## This file is part of the sigrok-util project. | |
4 | ## | |
87b10530 | 5 | ## Copyright (C) 2016-2018 Uwe Hermann <uwe@hermann-uwe.de> |
18b280b7 UH |
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 | |
b65a0b06 | 18 | ## along with this program; if not, see <http://www.gnu.org/licenses/>. |
18b280b7 UH |
19 | ## |
20 | ||
21 | set -e | |
22 | ||
87b10530 C |
23 | # The base path prefix where the compiled packages will be installed. |
24 | PREFIXBASE=$HOME/sr_msys2 | |
18b280b7 | 25 | |
87b10530 C |
26 | # The base path prefix where to download files to and where to build packages. |
27 | BUILDBASE=./build | |
18b280b7 | 28 | |
87b10530 C |
29 | # The $PREFIX subdir where the libsigrok Python bindings will be installed. |
30 | PYBASE=lib/python2.7/site-packages | |
18b280b7 UH |
31 | |
32 | # Edit this to control verbose build output. | |
33 | # V="V=1 VERBOSE=1" | |
34 | ||
35 | # Edit this to enable/disable/modify parallel compiles. | |
36 | PARALLEL="-j 2" | |
37 | ||
87b10530 C |
38 | # Edit this to enable/disable debug builds. |
39 | DEBUG=0 | |
40 | ||
18b280b7 UH |
41 | # You usually don't need to change anything below this line. |
42 | ||
43 | # ----------------------------------------------------------------------------- | |
44 | ||
8708cd82 | 45 | # Abort if the user runs the script in an "MSYS2 MSYS" shell. |
9dcc756a | 46 | if [ $MSYSTEM = "MSYS" ]; then |
8708cd82 UH |
47 | echo "Building in an 'MSYS2 MSYS' shell will not work, aborting." |
48 | echo "Please use the 'MSYS2 MinGW 64-bit' (or 32-bit) shell." | |
49 | exit | |
50 | fi | |
51 | ||
87b10530 C |
52 | # The build target type: "i686" (32bit) or "x86_64" (64bit). |
53 | # This is selected based on which MSYS2 shell is being used to do the build. | |
54 | TARGET=$MSYSTEM_CARCH | |
55 | ||
cbb27416 | 56 | VER_SIGROK_FIRMWARE_FX2LAFW=0.1.6 |
18b280b7 | 57 | |
87b10530 C |
58 | WGET="wget -c --quiet" |
59 | GIT_CLONE="git clone --depth=1" | |
60 | ||
61 | REPO_BASE="git://sigrok.org" | |
18b280b7 | 62 | |
87b10530 C |
63 | # Construct the build and install directory pathnames. |
64 | if [ $TARGET = "i686" ]; then | |
65 | SUFFIX="32" | |
66 | else | |
67 | SUFFIX="64" | |
68 | fi | |
682d505b | 69 | if [ $DEBUG = 1 ]; then |
87b10530 | 70 | # CFLAGS/CXXFLAGS contains "-g" per default for autotools projects. |
682d505b | 71 | BUILD_TYPE="Debug" |
87b10530 C |
72 | PREFIX=$PREFIXBASE"_debug_"$SUFFIX |
73 | BUILDDIR=$BUILDBASE"_debug_"$SUFFIX | |
682d505b C |
74 | else |
75 | BUILD_TYPE="Release" | |
87b10530 C |
76 | PREFIX=$PREFIXBASE"_release_"$SUFFIX |
77 | BUILDDIR=$BUILDBASE"_release_"$SUFFIX | |
682d505b C |
78 | fi |
79 | ||
87b10530 C |
80 | PYPATH=$PREFIX/$PYBASE |
81 | ||
9085e553 C |
82 | # Eliminate the host Python path environment variable, if any is set. |
83 | export PYTHONPATH= | |
84 | ||
87b10530 C |
85 | # ----------------------------------------------------------------------------- |
86 | ||
0b0d0cc0 | 87 | P="$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH" |
18b280b7 UH |
88 | C="$C --prefix=$PREFIX" |
89 | L="--disable-shared --enable-static" | |
90 | ||
91 | # Path to Qt binaries (needed for cmake to find the Qt libs). | |
92 | PATH="/mingw32/qt5-static/bin:$PATH" | |
93 | ||
94 | W="mingw-w64-$TARGET" | |
95 | ||
87b10530 | 96 | mkdir -p $PYPATH |
9bcef9f4 | 97 | |
18b280b7 UH |
98 | # Remove build directory contents (if any) and create a new build dir. |
99 | rm -rf $BUILDDIR | |
100 | mkdir $BUILDDIR | |
101 | cd $BUILDDIR | |
102 | ||
103 | # ----------------------------------------------------------------------------- | |
104 | ||
105 | if [ "x$1" = "xprepare" ]; then | |
106 | # Update package list, install/update all requirements. | |
107 | pacman -Sy | |
108 | pacman -S \ | |
fc936858 | 109 | autoconf automake autoconf-archive libtool make pkg-config wget patch \ |
34a60103 | 110 | $W-toolchain $W-glib2 $W-glibmm $W-libusb $W-libftdi $W-check $W-boost \ |
18b280b7 | 111 | $W-libzip $W-doxygen $W-python3 $W-python3-numpy $W-python3-gobject \ |
2ab8646d UH |
112 | $W-python3-setuptools $W-swig $W-qt5-static $W-cmake $W-nsis \ |
113 | $W-hidapi | |
18b280b7 UH |
114 | exit |
115 | fi | |
116 | ||
117 | # ----------------------------------------------------------------------------- | |
118 | ||
119 | # libusb | |
120 | $GIT_CLONE git://github.com/dickens/libusb -b event-abstraction-v4 | |
121 | cd libusb | |
122 | ./bootstrap.sh | |
123 | ./configure $C $L | |
124 | make -j1 $V | |
125 | make install $V | |
126 | cd .. | |
127 | ||
128 | # libserialport | |
9bcef9f4 | 129 | $GIT_CLONE $REPO_BASE/libserialport |
18b280b7 UH |
130 | cd libserialport |
131 | ./autogen.sh | |
132 | mkdir build | |
133 | cd build | |
134 | ../configure $C $L | |
135 | $SB make $PARALLEL $V | |
136 | make install $V | |
137 | cd ../.. | |
138 | ||
139 | # libsigrok | |
9bcef9f4 | 140 | $GIT_CLONE $REPO_BASE/libsigrok |
18b280b7 UH |
141 | cd libsigrok |
142 | ./autogen.sh | |
143 | mkdir build | |
144 | cd build | |
a4846659 | 145 | PKG_CONFIG_PATH=$P PYTHON=python3 ../configure $C $L --disable-python |
18b280b7 UH |
146 | $SB make $PARALLEL $V |
147 | PYTHONPATH=$PYPATH $SB make install $V | |
148 | # $SB make check $V # TODO | |
149 | cd ../.. | |
150 | ||
151 | # libsigrokdecode | |
9bcef9f4 | 152 | $GIT_CLONE $REPO_BASE/libsigrokdecode |
18b280b7 UH |
153 | cd libsigrokdecode |
154 | ./autogen.sh | |
155 | mkdir build | |
156 | cd build | |
157 | PKG_CONFIG_PATH=$P ../configure $C $L | |
158 | $SB make $PARALLEL $V | |
159 | make install $V | |
160 | # $SB make check $V # TODO | |
161 | cd ../.. | |
162 | ||
163 | # sigrok-firmware | |
9bcef9f4 | 164 | $GIT_CLONE $REPO_BASE/sigrok-firmware |
18b280b7 UH |
165 | cd sigrok-firmware |
166 | ./autogen.sh | |
167 | mkdir build | |
168 | cd build | |
169 | # Nothing gets cross-compiled here, we just need 'make install' basically. | |
170 | ../configure $C | |
171 | make install $V | |
172 | cd ../.. | |
173 | ||
174 | # sigrok-firmware-fx2lafw | |
175 | $WGET http://sigrok.org/download/binary/sigrok-firmware-fx2lafw/sigrok-firmware-fx2lafw-bin-$VER_SIGROK_FIRMWARE_FX2LAFW.tar.gz | |
176 | tar xfz sigrok-firmware-fx2lafw-bin-$VER_SIGROK_FIRMWARE_FX2LAFW.tar.gz | |
177 | cd sigrok-firmware-fx2lafw-bin-$VER_SIGROK_FIRMWARE_FX2LAFW | |
178 | cp *.fw $PREFIX/share/sigrok-firmware/ | |
179 | cd .. | |
180 | ||
181 | # TODO: Doesn't build, libsigrokdecode linking errors. | |
182 | # # sigrok-cli | |
9bcef9f4 | 183 | # $GIT_CLONE $REPO_BASE/sigrok-cli |
18b280b7 UH |
184 | # cd sigrok-cli |
185 | # ./autogen.sh | |
186 | # mkdir build | |
187 | # cd build | |
188 | # PKG_CONFIG_PATH=$P ../configure $C $L | |
189 | # $SB make $PARALLEL $V | |
190 | # make install $V | |
191 | # # makensis -DHOME=$HOME contrib/sigrok-cli_cross.nsi # TODO | |
192 | # cd ../.. | |
193 | ||
194 | # TODO: Doesn't build, various linking errors. | |
195 | # PulseView | |
9bcef9f4 | 196 | $GIT_CLONE $REPO_BASE/pulseview |
18b280b7 UH |
197 | cd pulseview |
198 | mkdir build | |
199 | cd build | |
682d505b C |
200 | PKG_CONFIG_PATH=$P $SB cmake \ |
201 | -G "Unix Makefiles" \ | |
202 | -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX \ | |
203 | -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ | |
204 | -DDISABLE_WERROR=y \ | |
87b10530 | 205 | -DENABLE_TESTS=n \ |
682d505b | 206 | .. |
18b280b7 UH |
207 | $SB make $PARALLEL $V |
208 | make install $V | |
209 | # $SB make test $V # TODO | |
210 | # makensis -DHOME=$HOME contrib/pulseview_cross.nsi # TODO | |
211 | cd ../.. |