-
Notifications
You must be signed in to change notification settings - Fork 18
/
configure
executable file
·127 lines (113 loc) · 3.45 KB
/
configure
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh
set -e
# set defaults
PREFIX=/usr/local
HOST=
DEBUG=false
# parse options
while [ $# != 0 ]; do
arg=$1
case "$arg" in
"--help")
echo "This script fetches dependencies and configures the build."
echo "Options:"
echo " --help Show this help"
echo " --prefix Set the install prefix (default: /usr/local)"
echo " --host Set the host tuple used as a prefix to the build tools (default: none)"
echo " --enable-debug Enables debug symbols, assertions, extra checks, etc. (default: disabled)"
exit 1
;;
"--prefix="*)
PREFIX="${1#--prefix=}";;
"--prefix")
PREFIX="$2"; shift;;
"--host="*)
HOST="${1#--host=}";;
"--host")
HOST="$2"; shift;;
"--enable-debug")
DEBUG=true;;
"--disable-debug")
DEBUG=false;;
*)
echo "ERROR: unrecognized option: $arg"
exit 1
esac
if [ $# = 0 ]; then
echo "ERROR: $arg must be followed by an argument."
exit
fi
shift
done
# set tool prefix
if [ "x$HOST" = "x" ]; then
TOOL_PREFIX=
else
TOOL_PREFIX=$HOST-
fi
# dependency fetch function
fetch_lib() {
local name file hash url
name="$1"
file="$2"
hash="$3"
url="$4"
if [ "x$DOWNLOAD_CACHE" = "x" ]; then
DOWNLOAD_CACHE=$HOME/.cache/downloads
fi
local path temp
path="$DOWNLOAD_CACHE/$2"
temp="$DOWNLOAD_CACHE/tmp.$2"
if [ -e "$path" ]; then
touch "$path"
else
echo "Fetching $file from $url"
mkdir -p "$(dirname "$path")"
curl -Lo "$temp" "$url"
mv $temp $path
fi
local actual_hash
actual_hash=$(sha256sum $path|cut -d\ -f1)
if [ "$hash" != "$actual_hash" ]; then
echo "ERROR: Hash mismatch on $path"
echo " Expected: $hash"
echo " Actual: $actual_hash"
exit 1
fi
local folder
folder="contrib/$name"
rm -rf "$folder"
mkdir -p "$folder"
echo "Extracting $file"
if [ "${file##*.}" = "zip" ]; then
# Note: This will miss top-level hidden files. There isn't
# an easy portable "dotglob"; we're not going to bother
# putting in a bunch of shell-specific workarounds. If this
# misses a hidden file you care about, move it manually.
(cd "$folder" && unzip -q "$path" && mv */* .)
else
(cd "$folder" && tar -xf "$path" --strip-components=1)
fi
}
# fetch dependencies
fetch_lib mpack mpack-20170122-df17e83f.tar.gz \
872897ca06c01e73601784c883e0de981bed7419d2809edf02192756e2fe4ff7 \
"https://github.com/ludocode/mpack/archive/df17e83f0fa8571b9cd0d8ccf38144fa90e244d1.tar.gz"
fetch_lib rapidjson rapidjson-20160720-99ba17bd.tar.gz \
dcf3f10e51ea0f51cd0756d36e5bfa24b2c8c57f9c33dfcce0c951608bf7af4b \
"https://github.com/Tencent/rapidjson/archive/99ba17bd66a85ec64a2f322b68c2b9c3b77a4391.tar.gz"
LIBB64_VERSION=1.2.1
fetch_lib libb64 libb64-${LIBB64_VERSION}.zip \
20106f0ba95cfd9c35a13c71206643e3fb3e46512df3e2efb2fdbf87116314b2 \
"https://downloads.sourceforge.net/project/libb64/libb64/libb64/libb64-${LIBB64_VERSION}.zip?use_mirror=autoselect"
# write config
cat >config.mk <<EOF
HOST = $HOST
PREFIX = $PREFIX
DEBUG = $DEBUG
TOOL_PREFIX = $TOOL_PREFIX
LIBB64_VERSION = $LIBB64_VERSION
EOF
echo "Configuration:"
cat config.mk
echo "Done configure."