-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbootstrap.sh
executable file
·197 lines (170 loc) · 5.23 KB
/
bootstrap.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/bash
############################################################################
#
# Run this script to install all dependencies for BLT in
# $PREFIX (or $PWD/env by default).
#
# The script produces another shell script with configuration meant to
# be sourced before building BLT.
#
# Options:
#
# * PREFIX -- prefix to install dependency libs and include files to
# * GET_YICES -- download and install Yices when this variable set to any
# non-empty string AND YICES_URL is specified.
#
#
# Prerequisites: (Ubuntu)
#
# $ apt-get install git curl build-essential -y
#
# Prerequisites: (Mac OSX)
#
# * OSX Developer Tools
#
############################################################################
set -eu
# prefix to install 3rd party libraries to
PREFIX="${PREFIX:-$PWD/env}"
OS=$(uname)
### 3rd party libraries, versions and locations
#
# both VERSION and URL must be specified together in the calling environment,
# or the defaults below will be used
NTL_VER=${NTL_VER:-"9.11.0"}
NTL_URL=${NTL_URL:-"http://www.shoup.net/ntl/ntl-${NTL_VER}.tar.gz"}
NTL_OPTS=${NTL_OPTS:-"NTL_GMP_LIP=off WIZARD=off"}
GLPK_VER=${GLPK_VER:-"4.55"}
GLPK_URL=${GLPK_URL:-"http://ftp.gnu.org/gnu/glpk/glpk-${GLPK_VER}.tar.gz"}
GLPK_OPTS=${GLPK_OPTS:-"--disable-shared"}
BOOST_VER=${BOOST_VER:-"1.59.0"}
BOOST_VER_UND=${BOOST_VER//\./_}
BOOST_URL=${BOOST_URL:-"http://sourceforge.net/projects/boost/files/boost/${BOOST_VER}/boost_${BOOST_VER_UND}.tar.gz/download"}
YICES_VER=${YICES_VER:-"2.4.0"}
YICES_URL=${YICES_URL:-""}
YICES_OPTS=${YICES_OPTS:-""}
### Print the environment ###
printf "%s\n" "Environment:"
printf "%s\n" "------------"
printf "\n"
printf "%15s %s\n" "PREFIX:" "${PREFIX:-}"
printf "%15s %s\n" "CPPFLAGS:" "${CPPFLAGS:-}"
printf "%15s %s\n" "LDFLAGS:" "${LDFLAGS:-}"
printf "%15s %s\n" "GET_YICES:" "${GET_YICES:-}"
printf "%15s %s\n" "OS:" "$OS"
printf "%15s %s\n" "NTL:" "$NTL_URL"
printf "%15s %s\n" "GLPK:" "$GLPK_URL"
printf "%15s %s\n" "Boost:" "$BOOST_URL"
printf "%15s %s\n" "Yices:" "$YICES_URL"
### Auxilliary Functions
# $1 = filepath to test
assert_exists() {
if [ -f "$1" ]; then
return
else
echo "build error: artifact $1 not found" 2>&1
exit 1
fi
}
# $1 = dirpath to test
assert_dir() {
if [ -d "$1" ]; then
return
else
echo "build error: directory $1 not found" 2>&1
exit 1
fi
}
### create PREFIX directories
mkdir -p "$PREFIX"
mkdir -p "$PREFIX/include"
mkdir -p "$PREFIX/lib"
mkdir -p "$PREFIX/src"
# place tarballs here
pushd "$PREFIX/src"
# Build & install ntl
# We require objects are compiled with -fPIC so they can be included in
# haskell .so libs.
if [ -f "$PREFIX/lib/libntl.a" ]; then
echo "Skipping NTL (found $PREFIX/lib/libntl.a)"
else
echo "Getting NTL... $NTL_URL"
curl -L "$NTL_URL" | tar xz
pushd "ntl-${NTL_VER}"/src
# set -e explicitly b/c configure does not return proper exit status codes
bash -e configure PREFIX="$PREFIX" WIZARD=off CXXFLAGS="-O2 -fPIC" "$NTL_OPTS"
make && make install
popd
fi
# Build & install glpk
# We require objects are compiled with -fPIC so they can be included in
# haskell .so libs
if [ -f "$PREFIX/lib/libglpk.a" ]; then
echo "Skipping GLPK (found $PREFIX/lib/libglpk.a)"
else
echo "Getting GLPK... $GLPK_URL"
curl "${GLPK_URL}" | tar xz
pushd "glpk-${GLPK_VER}"
CFLAGS="-fPIC" ./configure --prefix="$PREFIX" "$GLPK_OPTS"
make && make install
popd
fi
# Install boost
if [ -d "$PREFIX/include/boost" ]; then
echo "Skipping boost (found $PREFIX/include/boost)"
else
echo "Getting boost... $BOOST_URL"
curl -L "$BOOST_URL" | tar xz
cp -r "boost_${BOOST_VER_UND}/boost" "$PREFIX/include/boost"
fi
# Install Yices
if [ -n "${GET_YICES:-}" ]; then
if [ -f "$PREFIX/lib/libyices.so" ] || \
[ -f "$PREFIX/lib/libyices.dylib" ] || \
[ "$OS" == "Unknown" ]; then
echo "Skipping Yices..."
unset USE_YICES
else
if [ -z "$YICES_URL" ]; then
echo "No YICES_URL set, skipping Yices..."
else
echo "Getting Yices... $YICES_URL"
curl "${YICES_URL}" | tar xz
pushd "yices-${YICES_VER}"
./configure --prefix="$PREFIX" "$YICES_OPTS"
make
make install
if [ "$OS" == "Darwin" ]; then
YICES_LIB="libyices.dylib"
elif [ "$OS" == "Linux" ]; then
YICES_LIB="libyices.so"
fi
popd
fi
fi
fi
popd
assert_exists "$PREFIX/lib/libglpk.a"
assert_exists "$PREFIX/lib/libntl.a"
[ -z "${GET_YICES:-}" ] || assert_exists "$PREFIX/lib/$YICES_LIB"
assert_dir "$PREFIX/include/boost"
# populate setup_env.sh script
cat << EOF > setup_env.sh
export CPPFLAGS="-isystem $PREFIX/include/boost -I$PREFIX/include"
export LDFLAGS="-L$PREFIX/lib"
export YICES_LIB_PATH="$PREFIX/lib"
EOF
# Message to the user
echo "Dependencies are installed."
echo ""
echo "Invoke the following to build and test the BLT library:"
echo ""
echo " % source ./setup_env.sh"
echo " % cd libblt"
echo " % make && make test"
echo ""
echo "If you have built with Yices support, you may want to run the test"
echo "suite with Yices support enabled:"
echo ""
echo " % make test-yices"
echo ""