]> sigrok.org Git - sigrok-util.git/blame - cross-compile/mingw/sigrok-cross-mingw
sigrok-cross-mingw: Get libusb0.dll from libusb-win32.
[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
50d4aefd
UH
37VER_LIBUSB_WIN32=1.2.6.0
38
39SF_MIRROR=switch.dl.sourceforge.net
40
41# -----------------------------------------------------------------------------
42
91d4c754
UH
43# We need to find tools in the toolchain and in the install directory.
44export PATH=$PREFIX/bin:$MXE/usr/bin:$PATH
45
46P="$PREFIX/lib/pkgconfig"
47P2="$MXE/usr/i686-pc-mingw32/lib/pkgconfig"
48C="--host=i686-pc-mingw32 --prefix=$PREFIX"
49CM="-DCMAKE_TOOLCHAIN_FILE=$MXE/usr/i686-pc-mingw32/share/cmake/mxe-conf.cmake"
50L="--disable-shared --enable-static"
51
52# Remove build directory contents (if any) and create a new build dir.
53rm -rf $BUILDDIR
54mkdir $BUILDDIR
55cd $BUILDDIR
56
57# -----------------------------------------------------------------------------
58
91d4c754
UH
59# Python3
60# Cross-compiling Python is highly non-trivial, so we avoid it for now.
61# The download below is a repackaged tarball of the official Python 3.2.3 MSI
62# installer for Windows: http://python.org/ftp/python/3.2.3/python-3.2.3.msi
63# The MSI file has been installed on a Windows box and then the c:\Python32
64# files have been stored in the Python32.tar.gz tarball.
65mkdir -p $PREFIX
66wget http://www.sigrok.org/tmp/Python32.tar.gz -O $PREFIX/Python32.tar.gz
67tar xzf $PREFIX/Python32.tar.gz -C $PREFIX
68
cd6c7174
UH
69# Create a dummy python3.pc file so that pkg-config finds Python 3.
70mkdir -p $PREFIX/lib/pkgconfig
71cat >$PREFIX/lib/pkgconfig/python3.pc <<EOF
72prefix=$PREFIX
73exec_prefix=\${prefix}
74libdir=\${exec_prefix}/lib
75includedir=\${prefix}/include
76Name: Python
77Description: Python library
78Version: 3.2
79Libs: -L$PREFIX/Python32/libs -lpython32
80Cflags: -I$PREFIX/Python32/include
91d4c754 81EOF
91d4c754 82
6ba97136
UH
83# Download the Python 3.2.3 MSI installer (needed for NSIS runs).
84wget -c http://python.org/ftp/python/3.2.3/python-3.2.3.msi \
85 -O $PREFIX/python-3.2.3.msi
86
50d4aefd
UH
87# libusb0.dll (needs to be shipped with frontends)
88wget -c http://$SF_MIRROR/project/libusb-win32/libusb-win32-releases/$VER_LIBUSB_WIN32/libusb-win32-bin-$VER_LIBUSB_WIN32.zip
89unzip libusb-win32-bin-$VER_LIBUSB_WIN32.zip
90cp -f libusb-win32-bin-$VER_LIBUSB_WIN32/bin/x86/libusb0_x86.dll $PREFIX/libusb0.dll
91
43ffde97
UH
92# libserialport
93git clone git://sigrok.org/libserialport
94cd libserialport
95./autogen.sh
96PKG_CONFIG_PATH_i686_pc_mingw32=$P ./configure $C $L && make install
97cd ..
98
91d4c754
UH
99# libsigrok
100git clone git://sigrok.org/libsigrok
101cd libsigrok
0e3c8b38 102patch -p1 < ../../libsigrok_firmwaredir.patch
91d4c754 103./autogen.sh
eb5279c7 104PKG_CONFIG_PATH_i686_pc_mingw32=$P ./configure $C $L && make install
91d4c754
UH
105cd ..
106
107# libsigrokdecode
108git clone git://sigrok.org/libsigrokdecode
109cd libsigrokdecode
110./autogen.sh
cd6c7174 111PKG_CONFIG_PATH_i686_pc_mingw32=$P ./configure $C $L && make install
91d4c754
UH
112cd ..
113
885dc089
UH
114# sigrok-firmware
115git clone git://sigrok.org/sigrok-firmware
116cd sigrok-firmware
117./autogen.sh
118# Nothing gets cross-compiled here, we just need 'make install' basically.
119./configure --prefix=$PREFIX
120make install
121cd ..
122
123# sigrok-firmware-fx2lafw
124git clone git://sigrok.org/sigrok-firmware-fx2lafw
125cd sigrok-firmware-fx2lafw
126./autogen.sh
127# We're building the fx2lafw firmware on the host, no need to cross-compile.
128./configure --prefix=$PREFIX
129make
130make install
131cd ..
132
91d4c754
UH
133# sigrok-cli
134git clone git://sigrok.org/sigrok-cli
135cd sigrok-cli
0e3c8b38 136patch -p1 < ../../sigrok_cli_decodersdir.patch
91d4c754
UH
137./autogen.sh
138PKG_CONFIG_PATH_i686_pc_mingw32=$P:$P2 ./configure $C && make install
57d08419 139makensis -DHOME=$HOME contrib/sigrok-cli_cross.nsi
91d4c754
UH
140cd ..
141
91d4c754
UH
142# PulseView
143git clone git://sigrok.org/pulseview
144cd pulseview
22838903 145patch -p1 < ../../pulseview_linkfix.patch
0e3c8b38 146patch -p1 < ../../pulseview_decodersdir.patch
2929463b 147PKG_CONFIG_PATH_i686_pc_mingw32=$P:$P2 cmake $CM -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -DDISABLE_WERROR=y -DENABLE_DECODE=y . && make install VERBOSE=1
57d08419 148makensis -DHOME=$HOME contrib/pulseview_cross.nsi
91d4c754
UH
149cd ..
150