forked from arduino/avrdude-build-script
-
Notifications
You must be signed in to change notification settings - Fork 2
/
libhidapi.build.bash
executable file
·65 lines (55 loc) · 2.19 KB
/
libhidapi.build.bash
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
#!/bin/bash -ex
# Copyright (c) 2014-2016 Arduino LLC
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
mkdir -p objdir
cd objdir
PREFIX=`pwd`
cd -
if [[ $CROSS_COMPILE != "" ]] ; then
CONFARGS="$CONFARGS --host=$CROSS_COMPILE_HOST"
fi
if [[ $TARGET_OS == "GNU/Linux" ]] ; then
wget https://github.com/gentoo/eudev/archive/v3.2.9.tar.gz
tar xvf v3.2.9.tar.gz
cd eudev-3.2.9
sed -i 's|foreign 1.13|foreign 1.11|g' configure.ac
./autogen.sh
./configure --enable-static --disable-gudev --disable-introspection --disable-shared --disable-blkid --disable-kmod --disable-manpages --prefix=$PREFIX $CONFARGS
make clean
make -j4
make install
cd ..
rm -rf eudev
fi
git clone https://github.com/signal11/hidapi.git --branch autotools --depth 1
export CFLAGS="-I$PREFIX/include -I$PREFIX/include/hidapi -I$PREFIX/include/libelf -I$PREFIX/include/ncurses -I$PREFIX/include/ncursesw -I$PREFIX/include/readline -I$PREFIX/include/libusb-1.0 $CFLAGS"
export LDFLAGS="-L$PREFIX/lib $LDFLAGS"
cd hidapi
sed -i '/AC_CONFIG_MACRO_DIR/ s/^#*/#/' configure.ac # Fix build error
CONFARGS="--prefix=$PREFIX --enable-static --disable-shared"
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
if [[ $CROSS_COMPILE != "" ]] ; then
CONFARGS="$CONFARGS --host=$CROSS_COMPILE_HOST"
# solve bug with --host not being effective on second level directory
export CC=$CROSS_COMPILE_HOST-gcc
export AR=$CROSS_COMPILE_HOST-ar
export RANLIB=$CROSS_COMPILE_HOST-ranlib
fi
./bootstrap
CFLAGS="-w -O2 $CFLAGS" CXXFLAGS="-w -O2 $CXXFLAGS" LDFLAGS="-s $LDFLAGS" ./configure $CONFARGS
make -j 1
make install
cd ..