Skip to content

Commit

Permalink
Merge pull request #9 from Obijuan/master
Browse files Browse the repository at this point in the history
New script for cross-compiling for windows 64 bits
  • Loading branch information
Obijuan committed Feb 25, 2016
2 parents 9ea7ef1 + 1413630 commit 5046146
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
73 changes: 73 additions & 0 deletions build-windows_x86_64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
##############################################
# libusb builder for Windows 64 bits #
##############################################

BUILD=x86-unknown-linux-gnu
HOST=x86_64-w64-mingw32
TARGET=x86_64-w64-mingw32


NAME=libusb
ARCH=windows_x86_64
PREFIX=$HOME/.$ARCH
VERSION=4
PACKNAME=$NAME-$ARCH-$VERSION
BUILD_DIR=build_$ARCH
PACK_DIR=packages

TARBALL=$PWD/$BUILD_DIR/$PACKNAME.tar.gz
ZIPBALL=$PWD/$BUILD_DIR/$PACKNAME.zip
ZIPEXAMPLE=listdevs-example-$ARCH-$VERSION.zip

GITREPO=https://github.com/libusb/libusb.git



# Store current dir
WORK=$PWD

# Install dependencies
echo "Instalando DEPENDENCIAS:"
sudo apt-get install mingw-w64 libtool autoconf

# Clone the libusb repo
git -C $NAME pull || git clone $GITREPO

# Create the packages directory
mkdir -p $PACK_DIR

# Enter into the build directory
mkdir -p $BUILD_DIR ; cd $BUILD_DIR

# Copy the upstream libusb into the build dir
cp -r $WORK/$NAME .

# Prepare for building
cd $NAME
./autogen.sh

# Configure cross compilation
./configure --build=$BUILD --host=$HOST --target=$TARGET --prefix=$PREFIX

# let's cross compile!
make

# Install libusb
make install

# Cross-compile one example
cd examples
$HOST-gcc -o listdevs.exe listdevs.c -I $PREFIX/include/libusb-1.0 -L $PREFIX/lib -static -lusb-1.0

# Zip the .exe file and move it to the main directory
zip $ZIPEXAMPLE listdevs.exe
mv $ZIPEXAMPLE $WORK/$PACK_DIR

# Create the tarball
cd $PREFIX
tar vzcf $TARBALL *
mv $TARBALL $WORK/$PACK_DIR

# Create the zipball
zip -r $ZIPBALL *
mv $ZIPBALL $WORK/$PACK_DIR
27 changes: 27 additions & 0 deletions clean-windows_x86_64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
####################################################################
# Clean the cross-compilation file outputs for the Windows_x86_64
####################################################################

NAME=libusb
ARCH=windows_x86_64
PACK_DIR=packages
BUILD_DIR=build_$ARCH
EXAMPLE=listdevs-example
PREFIX=$HOME/.$ARCH



# Remove the build directory
rm -f -r $BUILD_DIR

# Removed the packages generated
rm -f $PWD/$PACK_DIR/$NAME-$ARCH-*.tar.gz
rm -f $PWD/$PACK_DIR/$NAME-$ARCH-*.zip
rm -f $PWD/$PACK_DIR/$EXAMPLE-$ARCH-*.zip

#-- Remove the installed libusb
cd $PREFIX
rm -f $PREFIX/bin/libusb-1.0.dll
rm -f -r $PREFIX/include/libusb-1.0
rm -f $PREFIX/lib/libusb-1*
rm -f $PREFIX/lib/pkgconfig/libusb-1*

0 comments on commit 5046146

Please sign in to comment.