diff --git a/src/main/c/build/README.md b/src/main/c/build/README.md new file mode 100644 index 0000000..f7b96f2 --- /dev/null +++ b/src/main/c/build/README.md @@ -0,0 +1,3 @@ +To cross-compile on Linux: + +arm: gcc-arm-linux-gnueabi diff --git a/src/main/c/build/common.sh b/src/main/c/build/common.sh new file mode 100644 index 0000000..2c4dfdc --- /dev/null +++ b/src/main/c/build/common.sh @@ -0,0 +1,64 @@ +cd "$(dirname $0)" +SRCDIR="$(pwd)/.." +TMPDIR="$SRCDIR/tmp" +DOWNLOADS="$SRCDIR/downloads" +LIBUSBX_VERSION="1.0.14" +LIBUSBX_ARCHIVE="libusbx-$LIBUSBX_VERSION.tar.bz2" +LIBUSBX_FILE="$DOWNLOADS/$LIBUSBX_ARCHIVE" +LIBUSBX_URL="http://downloads.sf.net/project/libusbx/releases/$LIBUSBX_VERSION/source/$LIBUSBX_ARCHIVE" + +build() +{ + DISTDIR="$SRCDIR/../resources/de/ailis/usb4java/libusb/$OS-$ARCH" + + # Clean up + rm -rf "$TMPDIR" + rm -rf "$DISTDIR" + + # Download libusbx if necessary + mkdir -p "$DOWNLOADS" + if [ ! -e "$LIBUSBX_FILE" ] + then + wget -O "$LIBUSBX_FILE" "$LIBUSBX_URL" + fi + + # Unpack and compile libusbx + mkdir -p "$TMPDIR" + cd "$TMPDIR" + tar xfj "$DOWNLOADS/$LIBUSBX_ARCHIVE" + cd "libusbx-$LIBUSBX_VERSION" + CFLAGS="$CFLAGS $LIBUSBX_CFLAGS" \ + ./configure --prefix="$TMPDIR" --host="$HOST" --with-pic $LIBUSBX_CONFIG + make + make install-strip + + # Build autoconf stuff of usb4java if needed + cd "$SRCDIR" + if [ ! -e configure ] + then + make -f Makefile.scm + fi + + # Build libusb4java + PKG_CONFIG_PATH="$TMPDIR/lib/pkgconfig" \ + LIBS="$USB4JAVA_LIBS" \ + CFLAGS="$CFLAGS $USB4JAVA_CFLAGS" \ + ./configure --prefix=/ --host="$HOST" $USB4JAVA_CONFIG + make clean install-strip DESTDIR="$TMPDIR" + + # Copy dist files to java resources directory + mkdir -p "$DISTDIR" + cp -faL 2>/dev/null \ + "$TMPDIR/lib/libusb4java.so" \ + "$TMPDIR/bin/libusb-1.0.dll" \ + "$DISTDIR" || true + cp -faL 2>/dev/null \ + "$TMPDIR/bin/libusb4java-1.dll" \ + "$DISTDIR/libusb4java.dll" || true + + # Remove executable flag from dist files + chmod -x "$DISTDIR/"* + + # Cleanup + rm -rf "$TMPDIR" +} diff --git a/src/main/c/build/linux-arm.sh b/src/main/c/build/linux-arm.sh index f14d4c4..16d397e 100755 --- a/src/main/c/build/linux-arm.sh +++ b/src/main/c/build/linux-arm.sh @@ -1,31 +1,15 @@ #!/bin/sh # -# Builds libusb4java for 32 bit arm. libusb-dev must be installed. -# This script is meant to be run directly on a linux-arm machine -# (Like the Raspberry) +# Builds libusb4java for 32 bit ARM linux (Raspberry Pi) set -e -cd $(dirname $0)/.. -OS=linux -ARCH=arm -TMPDIR=$(pwd)/tmp -DISTDIR=$(pwd)/../resources/de/ailis/usb4java/jni/${OS}-${ARCH} +. $(dirname $0)/common.sh -# Clean up -rm -rf $TMPDIR -rm -rf $DISTDIR +OS="linux" +ARCH="arm" +HOST="$ARCH-$OS-gnueabi" +LIBUSBX_CONFIG="--disable-shared" +USB4JAVA_LIBS="-lrt" -# Build autoconf stuff if needed -if [ ! -e configure ] -then - make -f Makefile.scm -fi - -# Build libusb4java -./configure --prefix=/ -make clean install-strip DESTDIR=$TMPDIR -mkdir -p $DISTDIR -cp -faL $TMPDIR/lib/libusb4java.so $DISTDIR/ -chmod -x $DISTDIR/libusb4java.so -rm -rf $TMPDIR +build diff --git a/src/main/c/build/linux-x86.sh b/src/main/c/build/linux-x86.sh index a75e1c0..af49fed 100755 --- a/src/main/c/build/linux-x86.sh +++ b/src/main/c/build/linux-x86.sh @@ -1,51 +1,16 @@ #!/bin/sh # -# Builds libusb4java for 32 bit linux on a linux host. +# Builds libusb4java for 32 bit x86 linux set -e -cd "$(dirname $0)/.." + +. $(dirname $0)/common.sh OS="linux" ARCH="x86" -LIBUSBX_VERSION="1.0.14" -LIBUSBX_ARCHIVE="libusbx-$LIBUSBX_VERSION.tar.bz2" -TMPDIR="$(pwd)/tmp" -DOWNLOADS="$(pwd)/downloads" -DISTDIR="$(pwd)/../resources/de/ailis/usb4java/libusb/${OS}-${ARCH}" +HOST="$ARCH-$OS-gnu" +CFLAGS="-m32" +LIBUSBX_CONFIG="--disable-shared" +USB4JAVA_LIBS="-lrt" -# Clean up -rm -rf "$TMPDIR" -rm -rf "$DISTDIR" - -# Download libusbx if necessary -mkdir -p "$DOWNLOADS" -if [ ! -e "$DOWNLOADS/$LIBUSBX_ARCHIVE" ] -then - wget -O "$DOWNLOADS/$LIBUSBX_ARCHIVE" "http://downloads.sourceforge.net/project/libusbx/releases/$LIBUSBX_VERSION/source/$LIBUSBX_ARCHIVE" -fi - -# Unpack and compile libusbx -mkdir -p "$TMPDIR" -cd "$TMPDIR" -tar xfj "$DOWNLOADS/$LIBUSBX_ARCHIVE" -cd "libusbx-$LIBUSBX_VERSION" -CFLAGS="-m32" ./configure "--prefix=$TMPDIR" --disable-shared --with-pic -make -make install - -# Build autoconf stuff of usb4java if needed -cd "$TMPDIR/.." -if [ ! -e configure ] -then - make -f Makefile.scm -fi - -# Build libusb4java -PKG_CONFIG_PATH="$TMPDIR/lib/pkgconfig" CFLAGS="-m32" ./configure --prefix=/ -make clean install-strip DESTDIR="$TMPDIR" -mkdir -p "$DISTDIR" -cp -faL "$TMPDIR/lib/libusb4java.so" "$DISTDIR/" -chmod -x "$DISTDIR/libusb4java.so" - -# Cleanup -rm -rf "$TMPDIR" +build diff --git a/src/main/c/build/linux-x86_64.sh b/src/main/c/build/linux-x86_64.sh index eaa0bc7..b526366 100755 --- a/src/main/c/build/linux-x86_64.sh +++ b/src/main/c/build/linux-x86_64.sh @@ -1,51 +1,16 @@ #!/bin/sh # -# Builds libusb4java for 64 bit linux on a 64 bit linux host. +# Builds libusb4java for 64 bit x86 linux set -e -cd "$(dirname $0)/.." + +. $(dirname $0)/common.sh OS="linux" ARCH="x86_64" -LIBUSBX_VERSION="1.0.14" -LIBUSBX_ARCHIVE="libusbx-$LIBUSBX_VERSION.tar.bz2" -TMPDIR="$(pwd)/tmp" -DOWNLOADS="$(pwd)/downloads" -DISTDIR="$(pwd)/../resources/de/ailis/usb4java/libusb/${OS}-${ARCH}" +HOST="$ARCH-$OS-gnu" +CFLAGS="-m64" +LIBUSBX_CONFIG="--disable-shared" +USB4JAVA_LIBS="-lrt" -# Clean up -rm -rf "$TMPDIR" -rm -rf "$DISTDIR" - -# Download libusbx if necessary -mkdir -p "$DOWNLOADS" -if [ ! -e "$DOWNLOADS/$LIBUSBX_ARCHIVE" ] -then - wget -O "$DOWNLOADS/$LIBUSBX_ARCHIVE" "http://downloads.sourceforge.net/project/libusbx/releases/$LIBUSBX_VERSION/source/$LIBUSBX_ARCHIVE" -fi - -# Unpack and compile libusbx -mkdir -p "$TMPDIR" -cd "$TMPDIR" -tar xfj "$DOWNLOADS/$LIBUSBX_ARCHIVE" -cd "libusbx-$LIBUSBX_VERSION" -./configure "--prefix=$TMPDIR" --disable-shared --with-pic -make -make install - -# Build autoconf stuff of usb4java if needed -cd "$TMPDIR/.." -if [ ! -e configure ] -then - make -f Makefile.scm -fi - -# Build libusb4java -PKG_CONFIG_PATH="$TMPDIR/lib/pkgconfig" ./configure --prefix=/ -make clean install-strip DESTDIR="$TMPDIR" -mkdir -p "$DISTDIR" -cp -faL "$TMPDIR/lib/libusb4java.so" "$DISTDIR/" -chmod -x "$DISTDIR/libusb4java.so" - -# Cleanup -rm -rf "$TMPDIR" +build diff --git a/src/main/c/build/mingw-windows-x86.sh b/src/main/c/build/mingw-windows-x86.sh deleted file mode 100755 index 6e112db..0000000 --- a/src/main/c/build/mingw-windows-x86.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# -# Compile libusb4java for 32 bit windows with mingw on Windows -# or cross-compile it with mingw on Linux. -# -# For cross-compiling on Linux mingw-w64-dev must be installed. - -set -e -cd $(dirname $0)/.. - -OS="windows" -ARCH="x86" -LIBUSBX_VERSION="1.0.14" -LIBUSBX_ARCHIVE="libusbx-$LIBUSBX_VERSION.tar.bz2" -TMPDIR="$(pwd)/tmp" -DOWNLOADS="$(pwd)/downloads" -DISTDIR="$(pwd)/../resources/de/ailis/usb4java/libusb/${OS}-${ARCH}" - -# Clean up -rm -rf "$TMPDIR" -rm -rf "$DISTDIR" - -# Download libusbx if necessary -mkdir -p "$DOWNLOADS" -if [ ! -e "$DOWNLOADS/$LIBUSBX_ARCHIVE" ] -then - wget -O "$DOWNLOADS/$LIBUSBX_ARCHIVE" "http://downloads.sourceforge.net/project/libusbx/releases/$LIBUSBX_VERSION/source/$LIBUSBX_ARCHIVE" -fi - -# Unpack and compile libusbx -mkdir -p "$TMPDIR" -cd "$TMPDIR" -tar xfj "$DOWNLOADS/$LIBUSBX_ARCHIVE" -cd "libusbx-$LIBUSBX_VERSION" -CFLAGS=-m32 ./configure \ - --prefix="$TMPDIR" \ - --with-pic \ - --host=i686-w64-mingw32 -make -make install-strip - -# Build autoconf stuff of usb4java if needed -cd "$TMPDIR/.." -if [ ! -e configure ] -then - make -f Makefile.scm -fi - -# Build libusb4java -CFLAGS=-m32 PKG_CONFIG_PATH="$TMPDIR/lib/pkgconfig" ./configure \ - --prefix="$TMPDIR" \ - --host=i686-w64-mingw32 -make clean install-strip -mkdir -p "$DISTDIR" -cp -faL "$TMPDIR/bin/libusb4java-1.dll" "$DISTDIR/libusb4java.dll" -cp -faL "$TMPDIR/bin/libusb-1.0.dll" "$DISTDIR" -chmod -x "$DISTDIR/"*.dll - -# Cleanup -rm -rf "$TMPDIR" diff --git a/src/main/c/build/mingw-windows-x86_64.sh b/src/main/c/build/mingw-windows-x86_64.sh deleted file mode 100755 index 88d15cd..0000000 --- a/src/main/c/build/mingw-windows-x86_64.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# -# Compile libusb4java for 32 bit windows with mingw on Windows -# or cross-compile it with mingw on Linux. -# -# For cross-compiling on Linux mingw-w64-dev must be installed. - -set -e -cd $(dirname $0)/.. - -OS="windows" -ARCH="x86_64" -LIBUSBX_VERSION="1.0.14" -LIBUSBX_ARCHIVE="libusbx-$LIBUSBX_VERSION.tar.bz2" -TMPDIR="$(pwd)/tmp" -DOWNLOADS="$(pwd)/downloads" -DISTDIR="$(pwd)/../resources/de/ailis/usb4java/libusb/${OS}-${ARCH}" - -# Clean up -rm -rf "$TMPDIR" -rm -rf "$DISTDIR" - -# Download libusbx if necessary -mkdir -p "$DOWNLOADS" -if [ ! -e "$DOWNLOADS/$LIBUSBX_ARCHIVE" ] -then - wget -O "$DOWNLOADS/$LIBUSBX_ARCHIVE" "http://downloads.sourceforge.net/project/libusbx/releases/$LIBUSBX_VERSION/source/$LIBUSBX_ARCHIVE" -fi - -# Unpack and compile libusbx -mkdir -p "$TMPDIR" -cd "$TMPDIR" -tar xfj "$DOWNLOADS/$LIBUSBX_ARCHIVE" -cd "libusbx-$LIBUSBX_VERSION" -./configure \ - --prefix="$TMPDIR" \ - --with-pic \ - --host=x86_64-w64-mingw32 -make -make install-strip - -# Build autoconf stuff of usb4java if needed -cd "$TMPDIR/.." -if [ ! -e configure ] -then - make -f Makefile.scm -fi - -# Build libusb4java -PKG_CONFIG_PATH="$TMPDIR/lib/pkgconfig" ./configure \ - --prefix="$TMPDIR" \ - --host=x86_64-w64-mingw32 -make clean install-strip -mkdir -p "$DISTDIR" -cp -faL "$TMPDIR/bin/libusb4java-1.dll" "$DISTDIR/libusb4java.dll" -cp -faL "$TMPDIR/bin/libusb-1.0.dll" "$DISTDIR" -chmod -x "$DISTDIR/"*.dll - -# Cleanup -rm -rf "$TMPDIR" diff --git a/src/main/c/build/windows-x86.sh b/src/main/c/build/windows-x86.sh new file mode 100755 index 0000000..f683c40 --- /dev/null +++ b/src/main/c/build/windows-x86.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# +# Builds libusb4java for 32 bit windows + +set -e + +. $(dirname $0)/common.sh + +OS="windows" +ARCH="x86" +HOST="i686-w64-mingw32" +CFLAGS="-m32" + +build diff --git a/src/main/c/build/windows-x86_64.sh b/src/main/c/build/windows-x86_64.sh new file mode 100755 index 0000000..1abaad7 --- /dev/null +++ b/src/main/c/build/windows-x86_64.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# +# Builds libusb4java for 64 bit windows + +set -e + +. $(dirname $0)/common.sh + +OS="windows" +ARCH="x86_64" +HOST="$ARCH-w64-mingw32" +CFLAGS="-m64" + +build diff --git a/src/main/resources/de/ailis/usb4java/libusb/linux-arm/libusb4java.so b/src/main/resources/de/ailis/usb4java/libusb/linux-arm/libusb4java.so new file mode 100644 index 0000000..78e2ae9 Binary files /dev/null and b/src/main/resources/de/ailis/usb4java/libusb/linux-arm/libusb4java.so differ diff --git a/src/main/resources/de/ailis/usb4java/libusb/linux-x86/libusb4java.so b/src/main/resources/de/ailis/usb4java/libusb/linux-x86/libusb4java.so index c052d30..c53a55d 100644 Binary files a/src/main/resources/de/ailis/usb4java/libusb/linux-x86/libusb4java.so and b/src/main/resources/de/ailis/usb4java/libusb/linux-x86/libusb4java.so differ diff --git a/src/main/resources/de/ailis/usb4java/libusb/linux-x86_64/libusb4java.so b/src/main/resources/de/ailis/usb4java/libusb/linux-x86_64/libusb4java.so index 835bbf7..ffa7e5a 100644 Binary files a/src/main/resources/de/ailis/usb4java/libusb/linux-x86_64/libusb4java.so and b/src/main/resources/de/ailis/usb4java/libusb/linux-x86_64/libusb4java.so differ diff --git a/src/main/resources/de/ailis/usb4java/libusb/windows-x86/libusb-1.0.dll b/src/main/resources/de/ailis/usb4java/libusb/windows-x86/libusb-1.0.dll index 326b91e..fa99962 100644 Binary files a/src/main/resources/de/ailis/usb4java/libusb/windows-x86/libusb-1.0.dll and b/src/main/resources/de/ailis/usb4java/libusb/windows-x86/libusb-1.0.dll differ diff --git a/src/main/resources/de/ailis/usb4java/libusb/windows-x86/libusb4java.dll b/src/main/resources/de/ailis/usb4java/libusb/windows-x86/libusb4java.dll index f521a26..cab4a44 100644 Binary files a/src/main/resources/de/ailis/usb4java/libusb/windows-x86/libusb4java.dll and b/src/main/resources/de/ailis/usb4java/libusb/windows-x86/libusb4java.dll differ diff --git a/src/main/resources/de/ailis/usb4java/libusb/windows-x86_64/libusb-1.0.dll b/src/main/resources/de/ailis/usb4java/libusb/windows-x86_64/libusb-1.0.dll index fa6c028..0415dd2 100644 Binary files a/src/main/resources/de/ailis/usb4java/libusb/windows-x86_64/libusb-1.0.dll and b/src/main/resources/de/ailis/usb4java/libusb/windows-x86_64/libusb-1.0.dll differ diff --git a/src/main/resources/de/ailis/usb4java/libusb/windows-x86_64/libusb4java.dll b/src/main/resources/de/ailis/usb4java/libusb/windows-x86_64/libusb4java.dll index 9c37ecf..77fa59b 100644 Binary files a/src/main/resources/de/ailis/usb4java/libusb/windows-x86_64/libusb4java.dll and b/src/main/resources/de/ailis/usb4java/libusb/windows-x86_64/libusb4java.dll differ