--- /dev/null
+/*
+_____________________________________________________________________________
+
+ File Association
+_____________________________________________________________________________
+
+ Based on code taken from http://nsis.sourceforge.net/File_Association
+
+ Usage in script:
+ 1. !include "FileAssociation.nsh"
+ 2. [Section|Function]
+ ${FileAssociationFunction} "Param1" "Param2" "..." $var
+ [SectionEnd|FunctionEnd]
+
+ FileAssociationFunction=[RegisterExtension|UnRegisterExtension]
+
+_____________________________________________________________________________
+
+ ${RegisterExtension} "[executable]" "[extension]" "[description]"
+
+"[executable]" ; executable which opens the file format
+ ;
+"[extension]" ; extension, which represents the file format to open
+ ;
+"[description]" ; description for the extension. This will be display in Windows Explorer.
+ ;
+
+
+ ${UnRegisterExtension} "[extension]" "[description]"
+
+"[extension]" ; extension, which represents the file format to open
+ ;
+"[description]" ; description for the extension. This will be display in Windows Explorer.
+ ;
+
+_____________________________________________________________________________
+
+ Macros
+_____________________________________________________________________________
+
+ Change log window verbosity (default: 3=no script)
+
+ Example:
+ !include "FileAssociation.nsh"
+ !insertmacro RegisterExtension
+ ${FileAssociation_VERBOSE} 4 # all verbosity
+ !insertmacro UnRegisterExtension
+ ${FileAssociation_VERBOSE} 3 # no script
+*/
+
+
+!ifndef FileAssociation_INCLUDED
+!define FileAssociation_INCLUDED
+
+!include Util.nsh
+
+!verbose push
+!verbose 3
+!ifndef _FileAssociation_VERBOSE
+ !define _FileAssociation_VERBOSE 3
+!endif
+!verbose ${_FileAssociation_VERBOSE}
+!define FileAssociation_VERBOSE `!insertmacro FileAssociation_VERBOSE`
+!verbose pop
+
+!macro FileAssociation_VERBOSE _VERBOSE
+ !verbose push
+ !verbose 3
+ !undef _FileAssociation_VERBOSE
+ !define _FileAssociation_VERBOSE ${_VERBOSE}
+ !verbose pop
+!macroend
+
+
+
+!macro RegisterExtensionCall _EXECUTABLE _EXTENSION _DESCRIPTION
+ !verbose push
+ !verbose ${_FileAssociation_VERBOSE}
+ Push `${_DESCRIPTION}`
+ Push `${_EXTENSION}`
+ Push `${_EXECUTABLE}`
+ ${CallArtificialFunction} RegisterExtension_
+ !verbose pop
+!macroend
+
+!macro UnRegisterExtensionCall _EXTENSION _DESCRIPTION
+ !verbose push
+ !verbose ${_FileAssociation_VERBOSE}
+ Push `${_EXTENSION}`
+ Push `${_DESCRIPTION}`
+ ${CallArtificialFunction} UnRegisterExtension_
+ !verbose pop
+!macroend
+
+
+
+!define RegisterExtension `!insertmacro RegisterExtensionCall`
+!define un.RegisterExtension `!insertmacro RegisterExtensionCall`
+
+!macro RegisterExtension
+!macroend
+
+!macro un.RegisterExtension
+!macroend
+
+!macro RegisterExtension_
+ !verbose push
+ !verbose ${_FileAssociation_VERBOSE}
+
+ Exch $R2 ;exe
+ Exch
+ Exch $R1 ;ext
+ Exch
+ Exch 2
+ Exch $R0 ;desc
+ Exch 2
+ Push $0
+ Push $1
+
+ ReadRegStr $1 HKCR $R1 "" ; read current file association
+ StrCmp "$1" "" NoBackup ; is it empty
+ StrCmp "$1" "$R0" NoBackup ; is it our own
+ WriteRegStr HKCR $R1 "backup_val" "$1" ; backup current value
+NoBackup:
+ WriteRegStr HKCR $R1 "" "$R0" ; set our file association
+
+ ReadRegStr $0 HKCR $R0 ""
+ StrCmp $0 "" 0 Skip
+ WriteRegStr HKCR "$R0" "" "$R0"
+ WriteRegStr HKCR "$R0\shell" "" "open"
+ WriteRegStr HKCR "$R0\DefaultIcon" "" "$R2,0"
+Skip:
+ WriteRegStr HKCR "$R0\shell\open\command" "" '"$R2" "%1"'
+ WriteRegStr HKCR "$R0\shell\edit" "" "Edit $R0"
+ WriteRegStr HKCR "$R0\shell\edit\command" "" '"$R2" "%1"'
+
+ Pop $1
+ Pop $0
+ Pop $R2
+ Pop $R1
+ Pop $R0
+
+ !verbose pop
+!macroend
+
+
+
+!define UnRegisterExtension `!insertmacro UnRegisterExtensionCall`
+!define un.UnRegisterExtension `!insertmacro UnRegisterExtensionCall`
+
+!macro UnRegisterExtension
+!macroend
+
+!macro un.UnRegisterExtension
+!macroend
+
+!macro UnRegisterExtension_
+ !verbose push
+ !verbose ${_FileAssociation_VERBOSE}
+
+ Exch $R1 ;desc
+ Exch
+ Exch $R0 ;ext
+ Exch
+ Push $0
+ Push $1
+
+ ReadRegStr $1 HKCR $R0 ""
+ StrCmp $1 $R1 0 NoOwn ; only do this if we own it
+ ReadRegStr $1 HKCR $R0 "backup_val"
+ StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key
+ DeleteRegKey HKCR $R0
+ Goto NoOwn
+
+Restore:
+ WriteRegStr HKCR $R0 "" $1
+ DeleteRegValue HKCR $R0 "backup_val"
+ DeleteRegKey HKCR $R1 ;Delete key with association name settings
+
+NoOwn:
+
+ Pop $1
+ Pop $0
+ Pop $R1
+ Pop $R0
+
+ !verbose pop
+!macroend
+
+!endif # !FileAssociation_INCLUDED
--- /dev/null
+Fix for bug #1195.
+
+Patch taken from the MSYS2 MINGW-packages repo, filename
+0110-MINGW-translate-gcc-internal-defines-to-python-platf.patch,
+but applied to pyconfig.h instead of pyport.h.
+
+Without this, Py_ssize_t ends up being 4 on 64bit Windows (where it
+should be 8) and all kinds of weird issues happen as a result,
+including 4GB allocations for no apparent reason, and none of the
+protocol decoders working (at all).
+
+The respective Py_ssize_t related code is in pyport.h.
+
+--- pyconfig.h.orig 2018-09-29 18:06:33.625204450 +0200
++++ pyconfig.h 2018-09-29 18:34:09.165488139 +0200
+@@ -1,6 +1,21 @@
+ #ifndef Py_CONFIG_H\r
+ #define Py_CONFIG_H\r
+ \r
++#ifdef __MINGW32__\r
++/* Translate GCC[mingw*] platform specific defines to those\r
++ * used in python code.\r
++ */\r
++#if !defined(MS_WIN64) && defined(_WIN64)\r
++# define MS_WIN64\r
++#endif\r
++#if !defined(MS_WIN32) && defined(_WIN32)\r
++# define MS_WIN32\r
++#endif\r
++#if !defined(MS_WINDOWS) && defined(MS_WIN32)\r
++# define MS_WINDOWS\r
++#endif\r
++#endif /* __MINGW32__*/\r
++\r
+ /* pyconfig.h. NOT Generated automatically by configure.\r
+ \r
+ This is a manually maintained version used for the Watcom,\r
--- /dev/null
+#!/bin/sh
+##
+## This file is part of the sigrok-util project.
+##
+## Copyright (C) 2013-2018 Uwe Hermann <uwe@hermann-uwe.de>
+## Copyright (C) 2018-2023 Frank Stettner <frank-stettner@gmx.net>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, see <http://www.gnu.org/licenses/>.
+##
+
+set -e
+
+mkdir -p "$INSTALL_DIR"
+
+BUILD_DIR=./build
+mkdir -p $BUILD_DIR
+cd $BUILD_DIR
+
+# Cross-compiling Python is highly non-trivial, so we avoid it for now.
+# The download below is a repackaged tarball of the official Python 3.4.4 MSI
+# installer for Windows:
+# - https://www.python.org/ftp/python/3.4.4/python-3.4.4.msi
+# - https://www.python.org/ftp/python/3.4.4/python-3.4.4.amd64.msi
+# The MSI file has been installed on a Windows box and then c:\Python34\libs
+# and c:\Python34\include have been stored in the Python34_*.tar.gz tarball.
+$WGET https://sigrok.org/tmp/Python34_$TARGET.tar.gz -O "$INSTALL_DIR"/Python34.tar.gz
+tar xzf "$INSTALL_DIR"/Python34.tar.gz -C "$INSTALL_DIR"
+
+# Fix for bug #1195.
+if [ "$TARGET" = "x86_64" ]; then
+ patch -p1 "$INSTALL_DIR"/Python34/include/pyconfig.h < ../contrib-mxe/pyconfig.patch
+fi
+
+# Create a dummy python3.pc file so that pkg-config finds Python 3.
+mkdir -p "$INSTALL_DIR"/lib/pkgconfig
+cat > "$INSTALL_DIR"/lib/pkgconfig/python3.pc <<EOF
+prefix=$INSTALL_DIR
+exec_prefix=\${prefix}
+libdir=\${exec_prefix}/Python34/libs
+includedir=\${prefix}/Python34/include
+Name: Python
+Description: Python library
+Version: 3.4.4
+Libs: -L\${libdir} -lpython34
+Cflags: -I\${includedir}
+EOF
+
+# The python34.dll and python34.zip files will be shipped in the NSIS
+# Windows installers (required for SmuView Python scripts to work).
+# The file python34.dll (NOT the same as python3.dll) is copied from an
+# installed Python 3.4.4 (see above) from c:\Windows\system32\python34.dll.
+# The file python34.zip contains all files from the 'DLLs', 'Lib', and 'libs'
+# subdirectories from an installed Python on Windows (c:\python34), i.e. some
+# libraries and all Python stdlib modules.
+$WGET https://sigrok.org/tmp/python34_$TARGET.dll -O "$INSTALL_DIR"/python34.dll
+$WGET https://sigrok.org/tmp/python34_$TARGET.zip -O "$INSTALL_DIR"/python34.zip
+
+# In order to link against Python we need libpython34.a.
+# The upstream Python 32bit installer ships this, the x86_64 installer
+# doesn't. Thus, we generate the file manually here.
+if [ "$TARGET" = "x86_64" ]; then
+ cp "$INSTALL_DIR"/python34.dll .
+ "$MXE_DIR"/usr/$TARGET-w64-mingw32.static.posix/bin/gendef python34.dll
+ "$MXE_DIR"/usr/bin/$TARGET-w64-mingw32.static.posix-dlltool \
+ --dllname python34.dll --def python34.def \
+ --output-lib libpython34.a
+ mv -f libpython34.a "$INSTALL_DIR"/Python34/libs
+ rm -f python34.dll
+fi
+
+# We need to include the *.pyd files from python34.zip into the installers,
+# otherwise importing certain modules (e.g. ctypes) won't work (bug #1409).
+unzip -q "$INSTALL_DIR"/python34.zip *.pyd -d "$INSTALL_DIR"
+
+# libserialport
+$GIT_CLONE $LIBSERIALPORT_REPO libserialport
+cd libserialport
+./autogen.sh
+./configure $C $L
+make $PARALLEL $V
+make install $V
+cd ..
+
+# libsigrok
+$GIT_CLONE -b ${LIBSIGROK_BRANCH:-master} $LIBSIGROK_REPO libsigrok
+cd libsigrok
+./autogen.sh
+./configure $C $L
+make $PARALLEL $V
+make install $V
+cd ..
+
+# libsigrokdecode
+$GIT_CLONE $LIBSIGROKDECODE_REPO libsigrokdecode
+cd libsigrokdecode
+./autogen.sh
+./configure $C $L
+make $PARALLEL $V
+make install $V
+cd ..
+
--- /dev/null
+#!/bin/sh
+##
+## This file is part of the sigrok-util project.
+##
+## Copyright (C) 2013-2018 Uwe Hermann <uwe@hermann-uwe.de>
+## Copyright (C) 2018-2021 Frank Stettner <frank-stettner@gmx.net>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, see <http://www.gnu.org/licenses/>.
+##
+
+set -e
+
+export PARALLEL="-j$(nproc)"
+
+# We need to find tools in the toolchain.
+export PATH="$MXE_DIR/usr/bin":"$PATH"
+
+TOOLCHAIN_TRIPLET="$TARGET-w64-mingw32.static.posix"
+
+export CMAKE="$TOOLCHAIN_TRIPLET-cmake"
+
+P="$INSTALL_DIR/lib/pkgconfig"
+P2="$MXE_DIR/usr/$TOOLCHAIN_TRIPLET/lib/pkgconfig"
+export C="--host=$TOOLCHAIN_TRIPLET --prefix=$INSTALL_DIR CPPFLAGS=-D__printf__=__gnu_printf__"
+export L="--disable-shared --enable-static"
+
+if [ "$TARGET" = "i686" ]; then
+ export PKG_CONFIG_PATH_i686_w64_mingw32_static_posix="$P:$P2"
+else
+ export PKG_CONFIG_PATH_x86_64_w64_mingw32_static_posix="$P:$P2"
+fi
+