forked from FPGAwars/libftdi-cross-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-ubuntu-phone_armhf.sh
93 lines (69 loc) · 2.13 KB
/
build-ubuntu-phone_armhf.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
#################################################
# libftdi builder for different Windows 64-bits #
#################################################
BUILD=x86-unknown-linux-gnu
HOST=arm-linux-gnueabihf
TARGET=arm-linux-gnueabihf
NAME=libftdi
ARCH=armhf
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.tar.gz
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
# Remove the packages generated
rm -f $PWD/$PACK_DIR/$EXAMPLE-$ARCH-*.tar.gz
# Remove the installed libftdi
cd $PREFIX
rm -f -r $PREFIX/include/libftdi1
rm -f $PREFIX/lib/libftdi1.*
rm -f $PREFIX/lib/pkgconfig/libftdi*
exit
fi
# Install dependencies
echo "Installing dependencies..."
sudo apt-get install cmake git-core gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf 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
echo "PREPARING FOR BUILDING........."
cd $NAME
cp $WORK/$BUILD_DATA_DIR/$ARCH/toolchain-armhf.cmake .
cp $WORK/$BUILD_DATA_DIR/$ARCH/CMakeLists.txt .
mkdir -p build; cd build
# Configure the cross compilation
cmake -DCMAKE_TOOLCHAIN_FILE=toolchain-armhf.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 -I ../src $PREFIX/lib/libftdi1.a \
$PREFIX/lib/libusb-1.0.a -L $PREFIX/lib -lpthread
# TAR the executable file and move it to the main directory
tar vzcf $ZIPEXAMPLE find_all
mv $ZIPEXAMPLE $WORK/$PACK_DIR
# Create the tarball
cd $PREFIX
tar vzcf $TARBALL *
mv $TARBALL $WORK/$PACK_DIR