-
Notifications
You must be signed in to change notification settings - Fork 49
/
bootstrap.sh
executable file
·141 lines (121 loc) · 4.2 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
#!/bin/bash
function dep() {
./.mason/mason install $1 $2
./.mason/mason link $1 $2
}
CURRENT_DIR=$(pwd)
# default to clang
CXX=${CXX:-clang++}
TARGET=${TARGET:-Release}
OSRM_RELEASE=${OSRM_RELEASE:-"v4.9.0"}
OSRM_REPO=${OSRM_REPO:-"https://github.com/Project-OSRM/osrm-backend.git"}
OSRM_DIR=deps/osrm-backend-${TARGET}
function all_deps() {
dep cmake 3.2.2 &
dep lua 5.3.0 &
dep luabind dev &
dep boost 1.57.0 &
dep boost_libsystem 1.57.0 &
dep boost_libthread 1.57.0 &
dep boost_libfilesystem 1.57.0 &
dep boost_libprogram_options 1.57.0 &
dep boost_libregex 1.57.0 &
dep boost_libiostreams 1.57.0 &
dep boost_libtest 1.57.0 &
dep boost_libdate_time 1.57.0 &
dep expat 2.1.0 &
dep stxxl 1.4.1 &
dep bzip 1.0.6 &
dep zlib system &
dep tbb 43_20150316 &
wait
}
function move_tool() {
cp ${MASON_HOME}/bin/$1 "${TARGET_DIR}/"
}
function copy_tbb() {
if [[ `uname -s` == 'Darwin' ]]; then
cp ${MASON_HOME}/lib/libtbb.dylib ${TARGET_DIR}/
cp ${MASON_HOME}/lib/libtbbmalloc.dylib ${TARGET_DIR}/
else
cp ${MASON_HOME}/lib/libtbb.so.2 ${TARGET_DIR}/
cp ${MASON_HOME}/lib/libtbbmalloc.so.2 ${TARGET_DIR}/
cp ${MASON_HOME}/lib/libtbbmalloc_proxy.so.2 ${TARGET_DIR}/
fi
}
function localize() {
mkdir -p ${TARGET_DIR}
copy_tbb
cp ${MASON_HOME}/bin/lua ${TARGET_DIR}
move_tool osrm-extract
move_tool osrm-datastore
move_tool osrm-prepare
}
function build_osrm() {
mkdir -p ${OSRM_DIR}
git clone ${OSRM_REPO} ${OSRM_DIR}
pushd ${OSRM_DIR}
echo "Using OSRM ${OSRM_RELEASE}"
echo "Using OSRM ${OSRM_REPO}"
git checkout .
git checkout ${OSRM_RELEASE}
rm -rf build
mkdir -p build
cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=${MASON_HOME} \
-DCMAKE_CXX_COMPILER="$CXX" \
-DBoost_NO_SYSTEM_PATHS=ON \
-DTBB_INSTALL_DIR=${MASON_HOME} \
-DCMAKE_INCLUDE_PATH=${MASON_HOME}/include \
-DCMAKE_LIBRARY_PATH=${MASON_HOME}/lib \
-DCMAKE_BUILD_TYPE=${TARGET} \
-DCMAKE_EXE_LINKER_FLAGS="${LINK_FLAGS}" \
-DDEBUG_GEOMETRY=ON
make -j${JOBS} && make install
popd
}
function main() {
if [[ ! -d ./.mason ]]; then
git clone --depth 1 https://github.com/mapbox/mason.git ./.mason
fi
export MASON_DIR=$(pwd)/.mason
export MASON_HOME=$(pwd)/mason_packages/.link
if [[ ! -d ${MASON_HOME} ]]; then
all_deps
fi
# fix install name of tbb
if [[ `uname -s` == 'Darwin' ]]; then
install_name_tool -id @loader_path/libtbb.dylib ${MASON_HOME}/lib/libtbb.dylib
install_name_tool -id @loader_path/libtbb.dylib ${MASON_HOME}/lib/libtbbmalloc.dylib
fi
export PATH=${MASON_HOME}/bin:$PATH
export PKG_CONFIG_PATH=${MASON_HOME}/lib/pkgconfig
# environment variables to tell the compiler and linker
# to prefer mason paths over other paths when finding
# headers and libraries. This should allow the build to
# work even when conflicting versions of dependencies
# exist on global paths
# stopgap until c++17 :) (http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2014/n4214.pdf)
export C_INCLUDE_PATH="${MASON_HOME}/include"
export CPLUS_INCLUDE_PATH="${MASON_HOME}/include"
export LIBRARY_PATH="${MASON_HOME}/lib"
if [[ ! -d ./node_modules/node-pre-gyp ]]; then
npm install node-pre-gyp
fi
export TARGET_DIR=$(./node_modules/.bin/node-pre-gyp reveal module_path --silent)
LINK_FLAGS=""
if [[ $(uname -s) == 'Linux' ]]; then
LINK_FLAGS="${LINK_FLAGS} "'-Wl,-z,origin -Wl,-rpath=\$ORIGIN'
fi
# make sure we rebuild if previous build was not successful
if [[ ! -f ${OSRM_DIR}/build/osrm-extract ]] || [[ ! -f ${MASON_HOME}/bin/osrm-extract ]] ||
[[ ! -f ${OSRM_DIR}/build/osrm-prepare ]] || [[ ! -f ${MASON_HOME}/bin/osrm-prepare ]] ||
[[ ! -f ${OSRM_DIR}/build/osrm-datastore ]] || [[ ! -f ${MASON_HOME}/bin/osrm-datastore ]]; then
build_osrm
fi
localize
#if [[ `uname -s` == 'Darwin' ]]; then otool -L ./lib/binding/* || true; fi
#if [[ `uname -s` == 'Linux' ]]; then readelf -d ./lib/binding/* || true; fi
echo "success: now run 'npm install --build-from-source'"
}
main