]> sigrok.org Git - sigrok-util.git/blame - cross-compile/mingw/sigrok-cross-mingw
sigrok-cross-mingw: Ship/use all our firmware files.
[sigrok-util.git] / cross-compile / mingw / sigrok-cross-mingw
CommitLineData
91d4c754
UH
1#!/bin/bash
2##
3## This file is part of the sigrok-util project.
4##
5## Copyright (C) 2013 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
d0793c36
ML
22set -e
23
91d4c754
UH
24# The path where your MXE directory is located.
25MXE=$HOME/mxe-git
26
27# The path where the cross-compiled packages will be installed.
28PREFIX=$HOME/sr_mingw
29
30# The path where to download files to and where to build packages.
31BUILDDIR=./sr_mingw_build
32
33# You usually don't need to change anything below this line.
34
35# -----------------------------------------------------------------------------
36
91d4c754
UH
37# We need to find tools in the toolchain and in the install directory.
38export PATH=$PREFIX/bin:$MXE/usr/bin:$PATH
39
40P="$PREFIX/lib/pkgconfig"
41P2="$MXE/usr/i686-pc-mingw32/lib/pkgconfig"
42C="--host=i686-pc-mingw32 --prefix=$PREFIX"
43CM="-DCMAKE_TOOLCHAIN_FILE=$MXE/usr/i686-pc-mingw32/share/cmake/mxe-conf.cmake"
44L="--disable-shared --enable-static"
45
46# Remove build directory contents (if any) and create a new build dir.
47rm -rf $BUILDDIR
48mkdir $BUILDDIR
49cd $BUILDDIR
50
51# -----------------------------------------------------------------------------
52
91d4c754
UH
53# Python3
54# Cross-compiling Python is highly non-trivial, so we avoid it for now.
55# The download below is a repackaged tarball of the official Python 3.2.3 MSI
56# installer for Windows: http://python.org/ftp/python/3.2.3/python-3.2.3.msi
57# The MSI file has been installed on a Windows box and then the c:\Python32
58# files have been stored in the Python32.tar.gz tarball.
59mkdir -p $PREFIX
60wget http://www.sigrok.org/tmp/Python32.tar.gz -O $PREFIX/Python32.tar.gz
61tar xzf $PREFIX/Python32.tar.gz -C $PREFIX
62
63# Create a dummy python3-config that points to Python32 above.
64mkdir -p $PREFIX/bin
65cat >$PREFIX/bin/python3-config <<EOF
66#!/usr/bin/python3
67import sys
68import getopt
69valid_opts = ['includes', 'cflags', 'libs', 'ldflags']
70opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
71opt_flags = [flag for (flag, val) in opts]
72for opt in opt_flags:
73 if opt in ('--includes', '--cflags'):
74 print('-I$PREFIX/Python32/include')
75 elif opt in ('--libs', '--ldflags'):
76 print('-L$PREFIX/Python32/libs -lpython32')
77EOF
78chmod 755 $PREFIX/bin/python3-config
79
6ba97136
UH
80# Download the Python 3.2.3 MSI installer (needed for NSIS runs).
81wget -c http://python.org/ftp/python/3.2.3/python-3.2.3.msi \
82 -O $PREFIX/python-3.2.3.msi
83
43ffde97
UH
84# libserialport
85git clone git://sigrok.org/libserialport
86cd libserialport
87./autogen.sh
88PKG_CONFIG_PATH_i686_pc_mingw32=$P ./configure $C $L && make install
89cd ..
90
91d4c754
UH
91# libsigrok
92git clone git://sigrok.org/libsigrok
93cd libsigrok
0e3c8b38 94patch -p1 < ../../libsigrok_firmwaredir.patch
91d4c754 95./autogen.sh
eb5279c7 96PKG_CONFIG_PATH_i686_pc_mingw32=$P ./configure $C $L && make install
91d4c754
UH
97cd ..
98
99# libsigrokdecode
100git clone git://sigrok.org/libsigrokdecode
101cd libsigrokdecode
102./autogen.sh
103PYTHON3_CONFIG=$PREFIX/bin/python3-config PKG_CONFIG_PATH_i686_pc_mingw32=$P ./configure $C $L && make install
104cd ..
105
885dc089
UH
106# sigrok-firmware
107git clone git://sigrok.org/sigrok-firmware
108cd sigrok-firmware
109./autogen.sh
110# Nothing gets cross-compiled here, we just need 'make install' basically.
111./configure --prefix=$PREFIX
112make install
113cd ..
114
115# sigrok-firmware-fx2lafw
116git clone git://sigrok.org/sigrok-firmware-fx2lafw
117cd sigrok-firmware-fx2lafw
118./autogen.sh
119# We're building the fx2lafw firmware on the host, no need to cross-compile.
120./configure --prefix=$PREFIX
121make
122make install
123cd ..
124
91d4c754
UH
125# sigrok-cli
126git clone git://sigrok.org/sigrok-cli
127cd sigrok-cli
0e3c8b38 128patch -p1 < ../../sigrok_cli_decodersdir.patch
91d4c754
UH
129./autogen.sh
130PKG_CONFIG_PATH_i686_pc_mingw32=$P:$P2 ./configure $C && make install
57d08419 131makensis -DHOME=$HOME contrib/sigrok-cli_cross.nsi
91d4c754
UH
132cd ..
133
91d4c754
UH
134# PulseView
135git clone git://sigrok.org/pulseview
136cd pulseview
22838903 137patch -p1 < ../../pulseview_linkfix.patch
0e3c8b38 138patch -p1 < ../../pulseview_decodersdir.patch
cf28c06c 139PKG_CONFIG_PATH_i686_pc_mingw32=$P:$P2 cmake $CM -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -DDISABLE_WERROR=y . && make install VERBOSE=1
57d08419 140makensis -DHOME=$HOME contrib/pulseview_cross.nsi
91d4c754
UH
141cd ..
142