-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-only.sh
62 lines (53 loc) · 1.9 KB
/
build-only.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
#!/bin/bash
####################################
## Softward versions
####################################
libusb_dir=libusb-1.0.24
libdfuutil_dir=dfu-util-0.10
####################################
set -e
echo "------------------------------------------"
echo "Prepare MSYS2 dependencies..."
echo "------------------------------------------"
# Update the package database and base packages if
# MSYS2 is not very recent.
pacman -Syu
pacman -S --needed \
tar unzip \
make libtool autogen autoconf automake \
mingw-w64-x86_64-gcc mingw-w64-x86_64-make \
mingw-w64-x86_64-winpthreads-git
echo "------------------------------------------"
echo "Compiling ${libusb_dir}..."
echo "------------------------------------------"
cd "${libusb_dir}"
./bootstrap.sh
./configure --prefix=$PWD/../Build --enable-examples-build --enable-tests-build
make
make install
cd ..
echo "------------------------------------------"
echo "Compiling ${libdfuutil_dir}..."
echo "------------------------------------------"
cd "${libdfuutil_dir}"
# Patch configure.ac that breaks in libusb detection on MSYS2.
# We use own paths to libusb-1.0, we don't need autodetection.
sed -i '/^[^#]/ s/\(^.*PKG_CHECK_MODULES(\[USB\].*$\)/#\ \1/' configure.ac
sed -i '/^[^#]/ s/\(^.*AC_MSG_ERROR.*Required libusb.*$\)/#\ \1/' configure.ac
./autogen.sh
CFLAGS="-I$PWD/../Build/include/libusb-1.0" \
LIBS="-L $PWD/../Build/lib -lusb-1.0" \
./configure --prefix=$PWD/../Build
# Link libusb statically. But if you want to use
# libusb-1.0.dll (dynamic linking), don't add LDFLAGS=-static
make LDFLAGS=-static
make install
cd ..
echo
echo "------------------------------------------"
echo "Congrats! Your projects are compiled in"
echo "Build directory. You do not need to have "
echo "libusb-1.0.dll in Build/bin directory "
echo "since DFU utils have been compiled "
echo "statically with this library."
echo "------------------------------------------"