From c65f6cbe6c77567a0829d7edd64b274e448b71c2 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Tue, 14 May 2013 20:35:41 +0000 Subject: [PATCH] Add a small script to cross-compile a Win32 binary under Unix. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1174 81a1dc3b-b13d-400b-aceb-764788c761c2 --- tools/build-mingw32.sh | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 tools/build-mingw32.sh diff --git a/tools/build-mingw32.sh b/tools/build-mingw32.sh new file mode 100755 index 00000000..3138ef66 --- /dev/null +++ b/tools/build-mingw32.sh @@ -0,0 +1,45 @@ +#! /bin/sh + +# ---------------------------------------------------------------------------- +# "THE BEER-WARE LICENSE" (Revision 42): +# Joerg Wunsch wrote this file. As long as you retain this notice you +# can do whatever you want with this stuff. If we meet some day, and you think +# this stuff is worth it, you can buy me a beer in return. +# ---------------------------------------------------------------------------- + +# Script to cross-compile a MinGW32 executable under unixish host. +# Run this script from within the tools/ subdirectory. +# Override MINGW32_PREFIX and LIBUSB_PREFIX from the commandline +# when invoking the script, like +# +# env LIBUSB_PREFIX="$HOME/dos/ProgramFiles/LibUSB-Win32" ./build-mingw32.sh +# +# The LibUSB-Win32 package is shipped as a self-installing +# executable; it can be unpacked using Wine, and typically +# extracts into the Wine environment. +# +# libelf can be cross-compiled, and installed into the MinGW32 +# target environment if desired. + +MINGW32_PREFIX=${MINGW32_PREFIX:-/usr/local/mingw32} +LIBUSB_PREFIX=${LIBUSB_PREFIX:-/WINDOWS/ProgramFiles/LibUSB-Win32} + +CC=mingw32-gcc + +BUILDDIR=build-mingw32 +mkdir -p ${BUILDDIR} || { echo "Cannot create build dir $BUILDDIR"; exit 1; } + +cd ${BUILDDIR} || { echo "Cannot chdir to $BUILDDIR"; exit 1; } + +LDFLAGS="-L${MINGW32_PREFIX}/lib -L${LIBUSB_PREFIX}/lib/gcc" +CPPFLAGS="-I${MINGW32_PREFIX}/include -I${LIBUSB_PREFIX}/include" + +env \ + CC="${CC}" \ + CPPFLAGS="${CPPFLAGS}" \ + LDFLAGS="${LDFLAGS}" \ + ../../configure \ + --host=$(../../config.guess) \ + --target=i386-unknowns-mingw32 + +make all