-
Notifications
You must be signed in to change notification settings - Fork 44
/
build-for-linux.sh
executable file
·66 lines (58 loc) · 1.25 KB
/
build-for-linux.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
#!/bin/sh
PWD=$(pwd)
SRC_DIR=$PWD/src
BUILD_DIR=$PWD/build
DOWNLOAD_DIR=$PWD/dl
LIBS_DIR=$BUILD_DIR/libs
LIBUSB_VER="1.0.27"
LIBUSB_URL="https://github.com/libusb/libusb/releases/download/v${LIBUSB_VER}/libusb-${LIBUSB_VER}.tar.bz2"
LIBUSB_DIR=""
prepare_dirs(){
if [ ! -d $BUILD_DIR ]; then
mkdir -p $BUILD_DIR || exit 1
fi
if [ ! -d $DOWNLOAD_DIR ]; then
mkdir -p $DOWNLOAD_DIR || exit 1
fi
if [ ! -d $LIBS_DIR ]; then
mkdir -p $LIBS_DIR || exit 1
fi
return 0
}
download_files(){
if [ -d $DOWNLOAD_DIR ] && [ ! -d $DOWNLOAD_DIR/libusb-$LIBUSB_VER ]; then
cd $DOWNLOAD_DIR; \
wget $LIBUSB_URL; \
tar xf libusb-$LIBUSB_VER.tar.bz2
fi
LIBUSB_DIR=$(cd $DOWNLOAD_DIR/libusb-$LIBUSB_VER && pwd)
return 0
}
build_depends(){
if [ -d $LIBUSB_DIR ]; then
cd $LIBUSB_DIR; \
./configure --prefix=$LIBS_DIR --disable-udev; \
make clean; \
make; \
make install
fi
return 0
}
build_target(){
make -C $SRC_DIR CONFIG_STATIC=yes LIBS_BASE=$LIBS_DIR strip && mv $SRC_DIR/snander $BUILD_DIR
make -C $SRC_DIR clean
return 0
}
#clean_all(){
# if [ -d $BUILD_DIR ]; then
# rm -rf $BUILD_DIR || exit 1
# elif [ -d $DOWNLOAD_DIR ]; then
# rm -rf $DOWNLOAD_DIR || exit 1
# fi
# return 0
#}
prepare_dirs
download_files
build_depends
build_target
#clean_all