-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Obijuan/master
New script for cross-compiling for windows 64 bits
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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* |