|
| 1 | +#!/bin/bash -ex |
| 2 | +# Copyright (c) 2016 Arduino LLC |
| 3 | +# |
| 4 | +# This program is free software; you can redistribute it and/or |
| 5 | +# modify it under the terms of the GNU General Public License |
| 6 | +# as published by the Free Software Foundation; either version 2 |
| 7 | +# of the License, or (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with this program; if not, write to the Free Software |
| 16 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | +ARCH=`arm-linux-gnueabihf-gcc -v 2>&1 | awk '/Target/ { print $2 }'` |
| 18 | + |
| 19 | +mkdir -p distrib/$ARCH |
| 20 | +cd distrib/$ARCH |
| 21 | +PREFIX=`pwd` |
| 22 | +cd - |
| 23 | + |
| 24 | +#disable pkg-config |
| 25 | +export PKG_CONFIG_PATH=`pwd` |
| 26 | + |
| 27 | +if [[ ${ARCH} != *darwin* ]]; then |
| 28 | + |
| 29 | +cd eudev-3.1.5 |
| 30 | +export UDEV_DIR=`pwd` |
| 31 | +./autogen.sh |
| 32 | +./configure --enable-static --disable-shared --disable-blkid --disable-kmod --disable-manpages --host=arm-linux-gnueabihf |
| 33 | +make clean |
| 34 | +make -j4 |
| 35 | +cd .. |
| 36 | + |
| 37 | +export CFLAGS="-I$UDEV_DIR/src/libudev/" |
| 38 | +export LDFLAGS="-L$UDEV_DIR/src/libudev/.libs/" |
| 39 | +export LIBS="-ludev" |
| 40 | + |
| 41 | +fi |
| 42 | + |
| 43 | +cd libusb-1.0.20 |
| 44 | +export LIBUSB_DIR=`pwd` |
| 45 | +./configure --enable-static --disable-shared --host=arm-linux-gnueabihf |
| 46 | +make clean |
| 47 | +make |
| 48 | +cd .. |
| 49 | + |
| 50 | +export LIBUSB1_CFLAGS="-I$LIBUSB_DIR/libusb/" |
| 51 | +export LIBUSB1_LIBS="-L$LIBUSB_DIR/libusb/.libs/ -lusb-1.0 -lpthread" |
| 52 | + |
| 53 | +export LIBUSB_1_0_CFLAGS="-I$LIBUSB_DIR/libusb/" |
| 54 | +export LIBUSB_1_0_LIBS="-L$LIBUSB_DIR/libusb/.libs/ -lusb-1.0 -lpthread" |
| 55 | + |
| 56 | +cd libusb-compat-0.1.5 |
| 57 | +export LIBUSB0_DIR=`pwd` |
| 58 | +automake --add-missing |
| 59 | +autoreconf |
| 60 | +./configure --enable-static --disable-shared --host=arm-linux-gnueabihf |
| 61 | +make clean |
| 62 | +make |
| 63 | +cd .. |
| 64 | + |
| 65 | +export libusb_CFLAGS="-I$LIBUSB_DIR/libusb/" |
| 66 | +export libusb_LIBS="-L$LIBUSB_DIR/libusb/.libs/ -lusb-1.0 -lpthread" |
| 67 | +export libudev_CFLAGS="-I$UDEV_DIR/src/libudev/" |
| 68 | +export libudev_LIBS="-L$UDEV_DIR/src/libudev/.libs/ -ludev" |
| 69 | + |
| 70 | +cd hidapi |
| 71 | +./bootstrap |
| 72 | +export HIDAPI_DIR=`pwd` |
| 73 | +./configure --enable-static --disable-shared --host=arm-linux-gnueabihf |
| 74 | +make clean |
| 75 | +make -j4 |
| 76 | +cd .. |
| 77 | + |
| 78 | +cd libftdi1-1.4 |
| 79 | +export LIBFTDI1_DIR=`pwd` |
| 80 | +if [ -d build ]; then |
| 81 | +rm -rf build |
| 82 | +fi |
| 83 | +mkdir build && cd build |
| 84 | +cmake -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DBUILD_TESTS=no -DDOCUMENTATION=no -DEXAMPLES=no -DFTDIPP=no -DFTDI_EEPROM=no -DLINK_PYTHON_LIBRARY=no -DPYTHON_BINDINGS=no -DCMAKE_INSTALL_PREFIX=$LIBFTDI1_DIR .. |
| 85 | +cd .. |
| 86 | +make clean |
| 87 | +make ftdi1-static |
| 88 | +cd .. |
| 89 | + |
| 90 | +cd OpenOCD |
| 91 | +./bootstrap |
| 92 | +export LIBUSB0_CFLAGS="-I$LIBUSB0_DIR/libusb/" |
| 93 | +export LIBUSB0_LIBS="-L$LIBUSB0_DIR/libusb/.libs/ -lusb -lpthread" |
| 94 | +export LIBUSB1_CFLAGS="-I$LIBUSB_DIR/libusb/" |
| 95 | +export LIBUSB1_LIBS="-L$LIBUSB_DIR/libusb/.libs/ -lusb-1.0 -lpthread" |
| 96 | +export LIBFTDI_CFLAGS="-I$LIBFTDI1_DIR/src/" |
| 97 | +export LIBFTDI_LIBS="-L$LIBFTDI1_DIR/src/ -lftdi1 -lpthread" |
| 98 | +export HIDAPI_CFLAGS="-I$HIDAPI_DIR/hidapi/" |
| 99 | + |
| 100 | +if [[ ${ARCH} != *darwin* ]]; then |
| 101 | + |
| 102 | +export HIDAPI_LIBS="-L$HIDAPI_DIR/linux/.libs/ -L$HIDAPI_DIR/libusb/.libs/ -lhidapi-hidraw -lhidapi-libusb" |
| 103 | + |
| 104 | +else |
| 105 | + |
| 106 | +export HIDAPI_LIBS="-L$HIDAPI_DIR/mac/.libs/ -L$HIDAPI_DIR/libusb/.libs/ -lhidapi" |
| 107 | +fi |
| 108 | + |
| 109 | +OPENOCD_COMPILE_SWITCHES="--enable-remote-bitbang --enable-stlink --enable-usb-blaster-2 --enable-ti-icdi --enable-jlink --enable-usbprog --enable-cmsis-dap --enable-jtag_vpi --enable-ioutil" |
| 110 | + |
| 111 | +if [[ ${ARCH} != *darwin* ]]; then |
| 112 | +OPENOCD_COMPILE_SWITCHES="$OPENOCD_COMPILE_SWITCHES --enable-sysfsgpio" |
| 113 | +fi |
| 114 | + |
| 115 | +export CFLAGS="-DHAVE_LIBUSB_ERROR_NAME" |
| 116 | +PKG_CONFIG_PATH=`pwd` ./configure $OPENOCD_COMPILE_SWITCHES --disable-werror --prefix=$PREFIX --host=arm-linux-gnueabihf |
| 117 | +make clean |
| 118 | +CFLAGS=-static make |
| 119 | +make install |
0 commit comments