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