forked from FPGAwars/libftdi-cross-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-windows_x86_64.sh
99 lines (74 loc) · 2.23 KB
/
build-windows_x86_64.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#################################################
# libftdi builder for different Windows 64-bits #
#################################################
BUILD=x86-unknown-linux-gnu
HOST=x86_64-w64-mingw32
TARGET=x86_64-w64-mingw32
NAME=libftdi
ARCH=windows_x86_64
PREFIX=$HOME/.$ARCH
VERSION=2
PACKNAME=$NAME-$ARCH-$VERSION
BUILD_DIR=build_$ARCH
BUILD_DATA_DIR=build-data
PACK_DIR=packages
TARBALL=$PWD/$BUILD_DIR/$PACKNAME.tar.gz
ZIPBALL=$PWD/$BUILD_DIR/$PACKNAME.zip
ZIPEXAMPLE=find_all-example-$ARCH-$VERSION.zip
GITREPO=git://developer.intra2net.com/libftdi
# Store current dir
WORK=$PWD
# -- TARGET: CLEAN. Remove the build dir and the generated packages
# -- then exit
if [ "$1" == "clean" ]; then
echo "-----> CLEAN"
# 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/libftdi1-config
rm -f $PREFIX/bin/libftdi1.dll
rm -f -r $PREFIX/include/libftdi1
rm -f $PREFIX/lib/libftdi*
rm -f $PREFIX/lib/pkgconfig/libftdi*
rm -f -r $PREFIX/lib/cmake/libftdi1
exit
fi
# Install dependencies
echo "Installing dependencies..."
sudo apt-get install cmake git-core mingw-w64 mingw-w64-tools zip
# download libftdi
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 libftdi into the build dir
cp -r $WORK/$NAME .
# Prepare for building
cd $NAME
cp $WORK/$BUILD_DATA_DIR/$ARCH/toolchain-mingw32.cmake .
mkdir -p build; cd build
# Configure the cross compilation
cmake -DCMAKE_TOOLCHAIN_FILE=toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$PREFIX ..
# let's cross compile!
make
# Installation
make install
# Cross compile one example
cd ../examples
$HOST-gcc find_all.c -o find_all.exe -I ../src -L $PREFIX/lib -static -lftdi1 -lusb-1.0
# Zip the .exe file and move it to the main directory
zip $ZIPEXAMPLE find_all.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