Debian Codegraph @

contrib/make_libusb.sh

raw symbols SCIP
1 #!/bin/bash
2
3 LIBUSB_VERSION="d52e355daa09f17ce64819122cb067b8a2ee0d4b"
4 # ^ tag v1.0.27
5
6 set -e
7
8 . "$(dirname "$0")/build_tools_util.sh" || (echo "Could not source build_tools_util.sh" && exit 1)
9
10 here="$(dirname "$(realpath "$0" 2> /dev/null || grealpath "$0")")"
11 CONTRIB="$here"
12 PROJECT_ROOT="$CONTRIB/.."
13
14 pkgname="libusb"
15 info "Building $pkgname..."
16
17 (
18 cd "$CONTRIB"
19 if [ ! -d libusb ]; then
20 git clone https://github.com/libusb/libusb.git
21 fi
22 cd libusb
23 if ! $(git cat-file -e ${LIBUSB_VERSION}) ; then
24 info "Could not find requested version $LIBUSB_VERSION in local clone; fetching..."
25 git fetch --all
26 fi
27 git reset --hard
28 git clean -dfxq
29 git checkout "${LIBUSB_VERSION}^{commit}"
30
31 if [ "$BUILD_TYPE" = "wine" ] ; then
32 echo "libusb_1_0_la_LDFLAGS += -Wc,-static" >> libusb/Makefile.am
33 fi
34 ./bootstrap.sh || fail "Could not bootstrap libusb"
35 if ! [ -r config.status ] ; then
36 if [ "$BUILD_TYPE" = "wine" ] ; then
37 # windows target
38 LDFLAGS="-Wl,--no-insert-timestamp"
39 elif [ $(uname) == "Darwin" ]; then
40 # macos target
41 LDFLAGS="-Wl -lm"
42 else
43 # linux target
44 LDFLAGS=""
45 fi
46 LDFLAGS="$LDFLAGS" ./configure \
47 $AUTOCONF_FLAGS \
48 || fail "Could not configure $pkgname. Please make sure you have a C compiler installed and try again."
49 fi
50 make "-j$CPU_COUNT" || fail "Could not build $pkgname"
51 make install || warn "Could not install $pkgname"
52 . "$here/$pkgname/libusb/.libs/libusb-1.0.la"
53 host_strip "$here/$pkgname/libusb/.libs/$dlname"
54 TARGET_NAME="$dlname"
55 if [ $(uname) == "Darwin" ]; then # on mac, dlname is "libusb-1.0.0.dylib"
56 TARGET_NAME="libusb-1.0.dylib"
57 fi
58 cp -fpv "$here/$pkgname/libusb/.libs/$dlname" "$PROJECT_ROOT/electrum/$TARGET_NAME" || fail "Could not copy the $pkgname binary to its destination"
59 info "$TARGET_NAME has been placed in the inner 'electrum' folder."
60 if [ -n "$DLL_TARGET_DIR" ] ; then
61 cp -fpv "$here/$pkgname/libusb/.libs/$dlname" "$DLL_TARGET_DIR/$TARGET_NAME" || fail "Could not copy the $pkgname binary to DLL_TARGET_DIR"
62 fi
63 )