forked from itesla/ipst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·240 lines (215 loc) · 8.1 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
#!/bin/bash
# Copyright (c) 2016, RTE (http://www.rte-france.com)
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
##
## before setting these settings to true, make sure that these enviroment variables are available
## - EUROSTAG_SRC_HOME and INTEL_HOME (to compile EUROSTAG based modules)
## - MATLABHOME: to compile MATLAB CODE, must point to the root of a MATLAB v>R2015 installation
## - DYMOLAHOME: to compile the matlab integration module)
##
BUILD_EUROSTAG=false
BUILD_MATLAB=false
BUILD_DYMOLA=false
BUILD_THIRDPARTY=true
## ipst top source directory
sourceDir=$(dirname $(readlink -f $0))
## default ipst installation target directory
installDir=$HOME/itesla
## default ipst thirdparty directory
thirdpartyDir=$HOME/itesla_thirdparty
## stop script execution if installDir already exists
overwriteInstallation=false
## remove non java ipst build dir, before triggering a new build
removeNonJavaBuildDir=false
## remove thord-party build dir, before triggering a new build
removeThirdpartyBuildDir=false
cmd=$0
usage() {
echo "usage: $cmd [--help] [--installDir <installation path>] [--thirdpartyDir <thirdparty path>] [--overwriteInstallation] [--removeNonJavaBuildDir] [--removeThirdpartyBuildDir] [--buildMATLAB] [--buildEUROSTAG] [--buildDYMOLA]";
echo ""
exit 1
}
help() {
echo "usage: $cmd [--help] [--installDir <installation path>] [--thirdpartyDir <thirdparty path>] [--overwriteInstallation]";
echo " --installDir the target directory; default is <HOME>/itesla; installation will not proceed if it already exists,";
echo " unless --overwriteInstallation is set (in this case the existing installation will be overwritten)";
echo " --thirdpartyDir the target path for the thirdparty libraries, required to build IPST (default is <HOME>/itesla_thirdparty)";
echo " --overwriteInstallation if set, the install script overwrites an existing installation (default is not set: stop script execution if installDir already exists)";
echo " --buildMATLAB if set, build MATLAB components (default is false, this option requires installation of MATLAB and MATLAB compiler)";
echo " --buildEUROSTAG if set, build EUROSTAG components (default is false, this option requires installation of EUROSTAG and EUROSTAG SDK)";
echo " --buildDYMOLA if set, build DYMOLA components (default is false, this option requires installation of DYMOLA)";
echo " --removeThirdpartyBuildDir if set, remove an already existing third-party build dir before starting a new build (default is false)";
echo " --removeNonJavaBuildDir if set, remove an already existing non java ipst build dir before starting a new build (default is false)";
echo " --help ";
echo ""
exit
}
for ((i=1;i<=$#;i++));
do
if [ ${!i} = "--installDir" ]
then ((i++))
installDir=${!i};
elif [ ${!i} = "--thirdpartyDir" ];
then ((i++))
thirdpartyDir=${!i};
elif [ ${!i} = "--overwriteInstallation" ];
then
overwriteInstallation=true;
elif [ ${!i} = "--buildMATLAB" ];
then
BUILD_MATLAB=true;
elif [ ${!i} = "--buildEUROSTAG" ];
then
BUILD_EUROSTAG=true;
elif [ ${!i} = "--buildDYMOLA" ];
then
BUILD_DYMOLA=true;
elif [ ${!i} = "--skipThirdpartyBuild" ];
then
BUILD_THIRDPARTY=false;
elif [ ${!i} = "--removeThirdpartyBuildDir" ];
then
removeThirdpartyBuildDir=true;
elif [ ${!i} = "--removeNonJavaBuildDir" ];
then
removeNonJavaBuildDir=true;
elif [ ${!i} = "--help" ];
then ((i++))
help;
fi
done;
echo ""
echo "** Building and installing ipst:"
echo "** -----------------------------"
echo "** installDir:" $installDir
echo "** thirdpartyDir:" $thirdpartyDir
echo "** overwriteInstallation:" $overwriteInstallation
echo "** removeThirdpartyBuildDir:" $removeThirdpartyBuildDir
echo "** removeNonJavaBuildDir:" $removeNonJavaBuildDir
echo "** buildMATLAB:" $BUILD_MATLAB
echo "** buildEUROSTAG:" $BUILD_EUROSTAG
echo "** buildDYMOLA:" $BUILD_DYMOLA
if [ $BUILD_MATLAB = true ] ; then
if [ -z "$MATLABHOME" ] ; then
echo ""
echo "ERROR: to build MATLAB modules, MATLABHOME environment variable is required; MATLABHOME must point to the root of a licensed MATLAB installation (with MATLAB compiler)"
exit 1
fi
fi
if [ $BUILD_EUROSTAG = true ] ; then
if [ -z "$EUROSTAG_SRC_HOME" ] ; then
echo ""
echo "ERROR: to build EUROSTAG modules, EUROSTAG_SRC_HOME environment variable is required. It must point to an EUROSTAG SDK."
exit 1
fi
fi
if [ $BUILD_DYMOLA = true ] ; then
if [ -z "$DYMOLAHOME" ] ; then
echo ""
echo "ERROR: to build DYMOLA modules, DYMOLAHOME environment variable is required. It must point to the root of a DYMOLA installation."
exit 1
fi
fi
if [ -d $installDir ] &&
[ $overwriteInstallation != true ]
then
echo ""
echo "ERROR: installation cannot continue: the target directory '"$installDir"' already exists (to allow overwrite it, set the --overtriteInstallation parameter)."
echo ""
usage;
fi
############################################
# build required C/C++ thirdparty libraries:
# - boost, build, hdf5, libarchive, log4cpp, matio, protobuf, szip, zlib
#
if [ $BUILD_THIRDPARTY = true ] ; then
echo ""
echo "** Building thirdparty libraries"
echo ""
buildThirdpartyDir=$thirdpartyDir/build
if [ $removeThirdpartyBuildDir = true ] ; then
echo ""
echo "*** removing third-party build dir (if it already exists). Triggers a clean third-party build."
echo ""
rm -rf $buildThirdpartyDir
fi
cmake -Dthirdparty_prefix=$thirdpartyDir -G "Unix Makefiles" -H$sourceDir/thirdparty -B$buildThirdpartyDir
cr=$?
if [ $cr -ne 0 ] ; then
exit $cr
fi
make -C $buildThirdpartyDir
cr=$?
if [ $cr -ne 0 ] ; then
exit $cr
fi
else
echo ""
echo "** Exclude required thirdparty from build; libraries are assumed to be already available here: "$thirdpartyDir
echo ""
fi
###########################################################################################
# build IPST (C/C++ and MATLAB modules, if enabled by the above declared BUILD_MATLAB flag)
#
echo ""
echo "** Building IPST platform: C/C++ and MATLAB (when configured) modules"
echo ""
buildDir=$sourceDir/build
if [ $removeNonJavaBuildDir = true ] ; then
echo ""
echo "*** removing non java build dir (if it already exists). Triggers a clean build."
echo ""
rm -rf $buildDir
fi
cmake -DCMAKE_INSTALL_PREFIX=$installDir -Dthirdparty_prefix=$thirdpartyDir -DBUILD_EUROSTAG=$BUILD_EUROSTAG -DBUILD_MATLAB=$BUILD_MATLAB -DBUILD_DYMOLA=$BUILD_DYMOLA -G "Unix Makefiles" -H$sourceDir -B$buildDir
cr=$?
if [ $cr -ne 0 ] ; then
exit $cr
fi
make -C $buildDir
cr=$?
if [ $cr -ne 0 ] ; then
exit $cr
fi
###########################
# build IPST (Java modules)
#
echo ""
echo "** Building IPST platform: java modules"
echo ""
mvn -f $sourceDir/pom.xml clean install
cr=$?
if [ $cr -ne 0 ] ; then
exit $cr
fi
################################################
#install IPST to the target directory: installDir
#
echo ""
echo "** Copying distribution files to "$installDir
echo ""
cp -r $sourceDir/distribution/target/distribution-*-full/itesla/* $installDir/
cr=$?
if [ $cr -ne 0 ] ; then
exit $cr
fi
mkdir -p $installDir/etc
######################################################################################
# create a default configuration file, if a configuration file does not already exist
#
if [ ! -f $installDir/etc/itesla.conf ]; then
echo ""
echo "*** Creating a default itesla.conf file"
echo ""
echo "#itesla_cache_dir=" >> $installDir/etc/itesla.conf
echo "#itesla_config_dir=" >> $installDir/etc/itesla.conf
echo "itesla_config_name=config" >> $installDir/etc/itesla.conf
echo "mpi_tasks=3" >> $installDir/etc/itesla.conf
echo "mpi_hosts=localhost" >> $installDir/etc/itesla.conf
else
echo "*** Configuration file " $installDir/etc/itesla.conf " already exists: it will not be replaced."
fi
echo ""
exit 0