-
Notifications
You must be signed in to change notification settings - Fork 27
/
install.sh
executable file
·241 lines (226 loc) · 7.65 KB
/
install.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#!/bin/bash
print_usage() {
echo "usage : ./install.sh [options]"
echo "options : "
echo " [--prefix=DIR] # Installation directory (default: ./install/)"
echo " [--build=DIR] # Build directory (default: ./build/)"
echo " [--enable-hdf5] # Enable HDF5 extension (default: disabled)"
echo " [--enable-sionlib] # Enable SIONlib extension (default: disabled)"
echo " [--enable-ime] # Enable IME extension (default: disabled)"
echo " [--enable-lustre] # Enable extended Lustre support (default: disabled)"
echo " [--enable-fortran] # Enable Fortran bindings (default: disabled)"
echo " [--disable-examples] # Disable the compilation of examples (default: enabled)"
echo " [--enable-tests] # Enable testing framework (default: disabled)"
echo " [--enable-docu] # Enable creation of FTI documentation (default: disabled)"
echo " [--enable-tutorial] # Enable creation of FTI tutorial (default: disabled)"
echo " [--enable-fi] # Enable FTI fault injection mechanism (default: disabled)"
echo " [--disable-openssl] # Disable linking with OpenSSL (default: enabled)"
echo " "
echo " [--sionlib-path=DIR] # Path to SIONlib installation"
echo " [--hdf5-path=DIR] # Path to HDF5 installation"
echo " [--ime-path=DIR] # Path to DDN IME installation"
echo " [--cmake-bin=BIN] # Use a custom CMake installation"
echo " [--cmake-arg=BIN] # Use a custom CMake argument"
echo " "
echo " [--enable-coverage] # Enable another build, fti_cov, for gathering coverage metrics"
echo " [--make-verbose] # Enable verbosity when calling make commands"
echo " [--debug] # Enable a debug build"
echo " [--silent] # No output to stdout or stderr during installation"
echo " [--uninstall] # No output to stdout or stderr during installation"
echo " [--create-logs] # Create installation logs when running this command"
}
# Calculate the FTI root directory relative to this file
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
export FTI_ROOT="$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)"
declare -r dft_install_log="$FTI_ROOT/install.log"
declare -r dft_config_log="$FTI_ROOT/config.log"
remove_fti() {
if [ -z "$FTI_ROOT" ]; then
set -x
rm -r build
rm -r install
rm -rf $dft_config_log
rm -rf $dft_install_log
set +x
else
set -x
rm -r $FTI_ROOT/build
rm -r $FTI_ROOT/install
rm -rf $dft_config_log
rm -rf $dft_install_log
set +x
fi
}
CMAKE_ARGS=""
#parse arguments
while [ $# -gt 0 ]; do
case $1 in
-h | --help)
print_usage
exit 0
;;
-s=* | --prefix=*)
FTI_INSTALL_DIR="${1#*=}"
shift # past argument=value
;;
--build=*)
FTI_BUILD_DIR="${1#*=}"
shift # past argument=value
;;
--debug)
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug"
shift # past argument=value
;;
--enable-coverage)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_COVERAGE=1"
shift # past argument=value
;;
--enable-hdf5)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_HDF5=1"
shift # past argument=value
;;
--enable-sionlib)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_SIONLIB=1"
shift # past argument=value
;;
--enable-ime)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_IME_NATIVE=1"
shift # past argument=value
;;
--enable-lustre)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_LUSTRE=1"
shift # past argument=value
;;
--enable-fortran)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_FORTRAN=1"
shift # past argument=value
;;
--enable-examples)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_EXAMPLES=1"
shift # past argument=value
;;
--enable-tests)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_TESTS=1"
shift # past argument=value
;;
--enable-docu)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_DOCU=1"
shift # past argument=value
;;
--enable-tutorial)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_TUTORIAL=1"
shift # past argument=value
;;
--enable-fi)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_FI_IO=1"
shift # past argument=value
;;
--disable-openssl)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_OPENSSL=0"
shift # past argument=value
;;
--enable-docu)
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_DOCU=1"
shift # past argument=value
;;
--cmake-arg=*)
CMAKE_ARGS="$CMAKE_ARGS -D${1#*=}"
shift # past argument=value
;;
--sionlib-path=*)
CMAKE_ARGS="$CMAKE_ARGS -DSIONLIBBASE=${1#*=}"
shift # past argument=value
;;
--hdf5-path=*)
CMAKE_ARGS="$CMAKE_ARGS -DHDF5_ROOT=${1#*=}"
shift # past argument=value
;;
--ime-path=*)
CMAKE_ARGS="$CMAKE_ARGS -DIMEBASE=${1#*=}"
shift # past argument=value
;;
--cmake-bin=*)
cmake_bin="${1#*=}"
shift
;;
--make-verbose)
make_verbose="VERBOSE=1"
shift
;;
--silent)
VERBOSE=false
shift # past argument=value
;;
--uninstall)
remove_fti
exit 0 # past argument=value
;;
--default)
DEFAULT=YES
shift # past argument with no value
;;
--create-logs)
install_log=$dft_install_log
config_log=$dft_config_log
shift
;;
*)
CMAKE_ARGS="$CMAKE_ARGS $1"
shift
;;
esac
done
rm -rf $dft_config_log
rm -rf $dft_install_log
if [ -z $install_log ]; then
install_log='/dev/null'
fi
if [ -z $config_log ]; then
config_log='/dev/null'
fi
# Test if user has an installation directory
if [ -z "$FTI_INSTALL_DIR" ]; then
FTI_INSTALL_DIR="$FTI_ROOT/install"
fi
# Test if user has a build directory
if [ -z "$FTI_BUILD_DIR" ]; then
FTI_BUILD_DIR="build"
fi
echo "cmake command:" >>$config_log
echo "cmake -DCMAKE_INSTALL_PREFIX:PATH=$FTI_INSTALL_DIR $CMAKE_ARGS $FTI_ROOT" >>$config_log
# Tutorial steps
cd "$FTI_ROOT"
mkdir -p "$FTI_BUILD_DIR"
cd "$FTI_BUILD_DIR"
if [ -z $cmake_bin ]; then
cmake_bin='cmake'
fi
if [ $VERBOSE ]; then
$cmake_bin -DCMAKE_INSTALL_PREFIX:PATH=$FTI_INSTALL_DIR $CMAKE_ARGS $FTI_ROOT >>$install_log 2>&1
if [ $? -ne 0 ]; then
rm -rf build
exit 1
fi
else
$cmake_bin -DCMAKE_INSTALL_PREFIX:PATH=$FTI_INSTALL_DIR $CMAKE_ARGS $FTI_ROOT 2>&1 | tee -a $install_log
if [ ${PIPESTATUS[0]} -ne 0 ]; then
rm -rf build
exit 1
fi
fi
if [ $VERBOSE ]; then
make -j $make_verbose all install >>$install_log 2>&1
if [ $? -ne 0 ]; then
exit 1
fi
else
make -j $make_verbose all install 2>&1 | tee -a $install_log
if [ ${PIPESTATUS[0]} -ne 0 ]; then
exit 1
fi
fi