-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-reanimator-library.sh
executable file
·146 lines (132 loc) · 3.42 KB
/
build-reanimator-library.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
#!/bin/bash
####################
# Script variables #
####################
numberOfCores="$(nproc --all)"
install=false
configArgs=""
rootDir="$(dirname $(realpath $0))"
buildDir="${rootDir}/build"
repositoryDir="${buildDir}/repositories"
installDir="${buildDir}"
####################
# Script functions #
####################
# Wrapper function for running commands with feedback
function runcmd
{
echo "CMD: $@"
sleep 0.2
$@
ret=$?
if test $ret -ne 0 ; then
exit $ret
fi
}
# Output usage string (invoked on -h or --help)
function printUsage
{
(
cat << EOF
Usage: $0 [options...]
Options:
--config-args ARGS Append ARGS to every ./configure command
--install Install libraries and binaries under /usr/local
--install-dir DIR Install libraries and binaries to DIR (ignored if --install)
-h, --help Print this help message
EOF
) >&2
exit 0
}
##################
# Script startup #
##################
while [[ $# -gt 0 ]]; do
key="$1"
case "${key}" in
--config-args)
shift # past argument
configArgs="$1"
shift # past value
;;
--install)
install=true
shift # past argument
;;
--install-dir)
shift # past argument
installDir="$(realpath "$1" || exit $?)"
shift # past value
;;
-h|--help)
printUsage
shift # past argument
;;
*)
shift # past argument
;;
esac
done
# --install-dir is ignored if --install is specified
if $install; then
installDir="/usr/local"
fi
# Set up the build directory
runcmd mkdir -p "${buildDir}"
runcmd mkdir -p xml
runcmd cd tables
runcmd perl gen-xml-enums.pl
runcmd cd ../
runcmd cp -r ./xml "${buildDir}"
runcmd rm -f include/strace2ds-enums.h
runcmd cp strace2ds-enums.h include
runcmd cd "${buildDir}"
# Cloning all repositories
runcmd mkdir -p "${repositoryDir}"
runcmd cd "${repositoryDir}"
[[ -d "Lintel" ]] || runcmd git clone https://github.com/dataseries/Lintel.git
[[ -d "DataSeries" ]] || runcmd git clone https://github.com/dataseries/DataSeries.git
[[ -d "gperftools" ]] || runcmd git clone https://github.com/gperftools/gperftools.git
# Building Lintel
# ---------------
runcmd cd Lintel
runcmd cmake -DCMAKE_INSTALL_PREFIX="${installDir}" .
if $install; then
runcmd sudo make -j"${numberOfCores}" install
else
runcmd make -j"${numberOfCores}" install
fi
runcmd cd "${repositoryDir}"
# Building DataSeries
# -------------------
runcmd cd DataSeries
runcmd cmake -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX="${installDir}" .
if $install; then
runcmd sudo make -j"${numberOfCores}" install
else
runcmd make -j"${numberOfCores}" install
fi
runcmd cd "${repositoryDir}"
# Building tcmalloc
# -----------------
runcmd cd gperftools
runcmd ./autogen.sh
runcmd ./configure --prefix="${installDir}" "${configArgs}"
runcmd make -j"${numberOfCores}"
if $install; then
runcmd sudo make -j"${numberOfCores}" install
else
runcmd make -j"${numberOfCores}" install
fi
runcmd cd "${repositoryDir}"
# Building strace2ds
# ------------------
runcmd cd "${buildDir}"
runcmd cmake -DCMAKE_INSTALL_PREFIX:PATH="${installDir}" ../
runcmd make clean
runcmd make -j"${numberOfCores}"
if $install; then
runcmd sudo make -j"${numberOfCores}" install
else
runcmd make -j"${numberOfCores}" install
fi