-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_dependencies.sh
executable file
·93 lines (71 loc) · 2.06 KB
/
install_dependencies.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
####
# Helper Functions
####
function install_srcs {
SRC_LOCATIONS="$1"
CROSS_COMPILE="$2"
INSTALL_LOCATION="$3"
for src_location in $1
do
filename=${src_location##*/}
dir=${filename%%\.tar\.gz}
if [ ! -d "$dir" ]; then
echo "Retrieving and installing $dir"
wget $src_location
tar xzvf $filename
cd $dir
./configure $CROSS_COMPILE $INSTALL_LOCATION
make
make install
cd ..
else
echo "Already installed $dir"
fi
done
}
####
# Main Script
####
echo "Creating and entering 'depends' directory"
mkdir -p depends
cd depends
BCMLIBRARY="bcm2835-1.60"
BUILD_APT_PACKAGES="cmake"
HOST_APT_PACKAGES="libncurses5 libncurses5-dev"
SRC_LOCATIONS="http://www.airspayce.com/mikem/bcm2835/bcm2835-1.60.tar.gz"
XCOMP_SRC_LOCATIONS="ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.1.tar.gz"
CROSS_COMPILE=""
INSTALL_LOCATION=""
APT_PACKAGES="$MIN_APT_PACKAGES $HOST_APT_PACKAGES"
while (( "$#" )); do
case "$1" in
-x|--cross-compile)
CROSS_COMPILE="--host $2 --disable-stripping"
INSTALL_LOCATION="--prefix $PWD"
APT_PACKAGES="$BUILD_APT_PACAKGES"
shift 2
;;
*)
echo "Error: unsupported arguments"
exit 1
;;
esac
done
echo ""
echo "Installing apt packages $APT_PACKAGES..."
sudo apt-get install -y $APT_PACKAGES
mkdir -p src
cd src
if [ -z "$CROSS_COMPILE" ]; then
echo "-------------------------------------------------------"
echo "Installing dependecies requiring from source compiling"
echo "-------------------------------------------------------"
install_srcs "$SRC_LOCATIONS" "$CROSS_COMPILE" "$INSTALL_LOCATION"
else
echo "-------------------------------------------------------"
echo "Installing dependencies for cross compiling into 'depends' directory"
echo "-------------------------------------------------------"
SRC_LOCATIONS="$SRC_LOCATIONS $XCOMP_SRC_LOCATIONS"
install_srcs "$SRC_LOCATIONS" "$CROSS_COMPILE" "$INSTALL_LOCATION"
fi