install 11.5 KB
Newer Older
Pietro Incardona's avatar
Pietro Incardona committed
1
#! /bin/bash
Pietro Incardona's avatar
Pietro Incardona committed
2

Pietro Incardona's avatar
Pietro Incardona committed
3
4
5
6
7
source script/help
source script/discover_os
source script/show_solutions
source script/pre_req
source script/remove_old
Pietro Incardona's avatar
Pietro Incardona committed
8

Pietro Incardona's avatar
Pietro Incardona committed
9
##
Pietro Incardona's avatar
Pietro Incardona committed
10

Pietro Incardona's avatar
Pietro Incardona committed
11
12
13
install_req=1
i_dir=" "
sq=0
Pietro Incardona's avatar
Pietro Incardona committed
14

Pietro Incardona's avatar
Pietro Incardona committed
15
16
while getopts :di:shc: FLAG; do
	case $FLAG in
Pietro Incardona's avatar
Pietro Incardona committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
	    d)
	      echo "Disable depencencies installation"
	      install_req=0
	      ;;
	    i)
	      echo "Setting dependencies installation dir: $OPTARG"
	      i_dir=$OPTARG
	      ;;
	    s)
	      echo "Skipping user cin"
	      sq=1
	      ;;
	    c)
	      echo "Fowarding options $OPTARG to configure script"
	      configure_options=$OPTARG
	      ;;
	    h)  #show help
Pietro Incardona's avatar
Pietro Incardona committed
34
35
36
37
38
      	      HELP
              ;;
    	    \?) #unrecognized option - are fowarded to configure
              ;;
	esac
incardon's avatar
incardon committed
39
40
done

incardon's avatar
incardon committed
41
42
discover_os

43
44
## Remove old dependencies and installations

Pietro Incardona's avatar
Pietro Incardona committed
45
46
47
48
if [ x"$i_dir" == x" " ]; then
 i_dir="$HOME"
fi

49
50
remove_old $i_dir

incardon's avatar
incardon committed
51
52
## Check and try to install the prerequisites

incardon's avatar
incardon committed
53
pre_req
incardon's avatar
incardon committed
54
55
56

## clone the dependencies

incardon's avatar
incardon committed
57
git submodule init
Yaser Afshar's avatar
Yaser Afshar committed
58
59
60
61
if [ $? -ne 0 ]; then
  echo -e "Configure\033[91;5;1m FAILED \033[0m"
  exit 1
fi
incardon's avatar
incardon committed
62

incardon's avatar
incardon committed
63
git submodule update
Yaser Afshar's avatar
Yaser Afshar committed
64
65
66
67
if [ $? -ne 0 ]; then
  echo -e "Configure\033[91;5;1m FAILED \033[0m"
  exit 1
fi
incardon's avatar
incardon committed
68

incardon's avatar
incardon committed
69
70
71
# Create config directory in each submodule

cd openfpm_data
incardon's avatar
incardon committed
72
73
74
if [ ! -d src/config  ]; then
  mkdir src/config
fi
incardon's avatar
incardon committed
75
76
77
cd ..

cd openfpm_devices
incardon's avatar
incardon committed
78
79
80
if [ ! -d src/config  ]; then
  mkdir src/config
fi
incardon's avatar
incardon committed
81
82
83
cd ..

cd openfpm_vcluster
incardon's avatar
incardon committed
84
85
86
if [ ! -d src/config  ]; then
  mkdir src/config
fi
incardon's avatar
incardon committed
87
88
89
cd ..

cd openfpm_io
incardon's avatar
incardon committed
90
91
92
if [ ! -d src/config  ]; then
  mkdir src/config
fi
incardon's avatar
incardon committed
93
94
cd ..

incardon's avatar
incardon committed
95
96
97
98
99
100
cd openfpm_numerics
if [ ! -d src/config  ]; then
  mkdir src/config
fi
cd ..

incardon's avatar
incardon committed
101
# Create config directory
incardon's avatar
incardon committed
102

incardon's avatar
incardon committed
103
104
105
if [ ! -d src/config ]; then
  mkdir src/config
fi
incardon's avatar
incardon committed
106

incardon's avatar
incardon committed
107
## generate configure script
incardon's avatar
incardon committed
108

incardon's avatar
incardon committed
109
sh ./autogen.sh
Incardona Pietro's avatar
Incardona Pietro committed
110
111
112
113
if [ $? -ne 0 ]; then
  echo -e "Configure\033[91;5;1m FAILED \033[0m"
  exit 1
fi
incardon's avatar
incardon committed
114

incardon's avatar
incardon committed
115
## check for options
incardon's avatar
incardon committed
116
117
118
119

echo -e "\033[1;34;5mDEPENCENCIES INSTALLATION DIR      \033[0m"
echo -e "Every required dependencies if needed will be installed into: \033[1;34;5m$i_dir\033[0m"
echo -e "if you want to install somewhere else do ./install -i /somewhere/else"
incardon's avatar
incardon committed
120
if [ $sq -eq 0 ]; then
121
  unset commands
incardon's avatar
incardon committed
122
123
124
  commands[0]="Continue"
  possible_solutions "${commands[@]}"
fi
incardon's avatar
incardon committed
125
126
127
128
129

echo -e "Installing requirements into: $i_dir "

##

incardon's avatar
incardon committed
130
## Take all the options with the exception of -d -i -s
incardon's avatar
incardon committed
131
132
133

## call the configure script

134
135
136
137
138
if [ x"$MPI_valid" == x"yes" ]; then
	configure_options="$configure_options CXX=mpic++ "
fi


incardon's avatar
incardon committed
139
140
MPI_installed=0
METIS_installed=0
141
PARMETIS_installed=0
incardon's avatar
incardon committed
142
BOOST_installed=0
Pietro Incardona's avatar
Pietro Incardona committed
143
144
145
LAPACK_installed=0
SUITESPARSE_installed=0
EIGEN_installed=0
Pietro Incardona's avatar
Pietro Incardona committed
146
HDF5_installed=0
147
H5PART_installed=0
Pietro Incardona's avatar
Pietro Incardona committed
148
blas_options=""
incardon's avatar
incardon committed
149
150
151
conf_err=1

if [ $install_req -eq 0 ]; then
Pietro Incardona's avatar
Pietro Incardona committed
152
    ./configure $options $configure_options "$blas_options"
incardon's avatar
incardon committed
153
154
155
else
    while [ $conf_err -ne 0 ]
    do
Pietro Incardona's avatar
Pietro Incardona committed
156
        ./configure $options $configure_options "$blas_options"
incardon's avatar
incardon committed
157
158
159
160
161
162
        conf_err=$?

	echo "Configure script terminated with $conf_err"

        ## if MPI or METIS installation required install it
        if [ $conf_err -eq 200  ]; then
163
            echo "MPI not found try to install, $MPI_installed"
incardon's avatar
incardon committed
164
165
166
167
            if [ $MPI_installed -eq 1 ]; then
                echo "Error the installation of MPI failed"
                exit 1
            fi
incardon's avatar
incardon committed
168
            ./script/install_MPI.sh $i_dir $compiler_opt
incardon's avatar
incardon committed
169
            MPI_installed=1
Yaser Afshar's avatar
Yaser Afshar committed
170
            export PATH="$PATH:$i_dir/MPI/bin"
171
            configure_options="$configure_options CXX=mpic++ "
incardon's avatar
incardon committed
172
173
174
175
176
177
        elif [ $conf_err -eq 201  ]; then
            echo "Metis not found try to install"
            if [ $METIS_installed -eq 1  ]; then
                echo "Error the installation of METIS failed"
                exit 1
            fi
incardon's avatar
incardon committed
178
            ./script/install_Metis.sh $i_dir $compiler_gcc $compiler_gpp
incardon's avatar
incardon committed
179
            METIS_installed=1
Yaser Afshar's avatar
Yaser Afshar committed
180
            configure_options=" $configure_options --with-metis=$i_dir/METIS "
incardon's avatar
incardon committed
181
        elif [ $conf_err -eq 202 ]; then
182
            echo "Boost not found try to install in $i_dir with $compiler_opt"
incardon's avatar
incardon committed
183
            if [ $BOOST_installed -eq 1  ]; then
incardon's avatar
incardon committed
184
185
186
                echo "Error the installation of Boost failed"
                exit 1
            fi
incardon's avatar
incardon committed
187
            ./script/install_BOOST.sh $i_dir $compiler_opt
incardon's avatar
incardon committed
188
            BOOST_installed=1
Yaser Afshar's avatar
Yaser Afshar committed
189
            configure_options=" $configure_options --with-boost=$i_dir/BOOST "
Pietro Incardona's avatar
Pietro Incardona committed
190
191
192
193
194
195
        elif [ $conf_err -eq 204 ]; then
            echo "Lapack not found try to install"
            if [ $LAPACK_installed -eq 1  ]; then
                echo "Error the installation of LAPACK failed"
                exit 1
            fi
Pietro Incardona's avatar
Pietro Incardona committed
196
197
            ./script/install_OPENBLAS.sh $i_dir $compiler_opt
            LAPACK_installed=1
jenkins's avatar
jenkins committed
198
            blas_options="--with-blas=-L$i_dir/OPENBLAS/lib/ -lopenblas"
Pietro Incardona's avatar
Pietro Incardona committed
199
        elif [ $conf_err -eq 205 ]; then
200
201
202
203
            ## First we install openblas, we ignore default lapack
            ## this SuiteSparse is programmed to use libopenblas
            ./script/install_OPENBLAS.sh $i_dir $compiler_opt
            LAPACK_installed=1
jenkins's avatar
jenkins committed
204
            blas_options="--with-blas=-L$i_dir/OPENBLAS/lib/ -lopenblas"
205
206
        
            ## Then suite sparse
Pietro Incardona's avatar
Pietro Incardona committed
207
208
209
210
211
212
            echo "SuiteSparse not found try to install"
            if [ $SUITESPARSE_installed -eq 1  ]; then
                echo "Error the installation of SuiteSparse failed"
                exit 1
            fi
            ./script/install_SUITESPARSE.sh $i_dir $compiler_opt
Pietro Incardona's avatar
Pietro Incardona committed
213
214
215
216
217
218
219
220
221
222
223
            configure_options=" $configure_options --with-suitesparse=$i_dir/SUITESPARSE "
            SUITESPARSE_installed=1
        elif [ $conf_err -eq 206 ]; then
            echo "Eigen not found try to install"
            if [ $EIGEN_installed -eq 1  ]; then
                echo "Error the installation of Eigen failed"
                exit 1
            fi
            ./script/install_EIGEN.sh $i_dir $compiler_opt
            configure_options=" $configure_options --with-eigen=$i_dir/EIGEN "
            EIGEN_installed=1
224
	elif [ $conf_err -eq 208 ]; then
225
226
227
228
229
            echo "ParMetis not found try to install"
            if [ $PARMETIS_installed -eq 1  ]; then
                echo "Error the installation of ParMETIS failed"
                exit 1
            fi
230
            ./script/install_Parmetis.sh $i_dir $compiler_gcc $compiler_gpp
231
232
            PARMETIS_installed=1
            configure_options=" $configure_options --with-parmetis=$i_dir/PARMETIS "
Pietro Incardona's avatar
Pietro Incardona committed
233
234
235
        elif [ $conf_err -eq 207 ]; then
            echo "HDF5 not found try to install"
            if [ $HDF5_installed -eq 1 ]; then
Pietro Incardona's avatar
Pietro Incardona committed
236
237
                echo "Error the installation of HDF5 failed"
                exit 1	
Pietro Incardona's avatar
Pietro Incardona committed
238
239
            fi
            ./script/install_HDF5.sh $i_dir $compiler_opt
Pietro Incardona's avatar
Pietro Incardona committed
240
            configure_options=" $configure_options --with-hdf5=$i_dir/HDF5/bin/h5pcc "
Pietro Incardona's avatar
Pietro Incardona committed
241
            HDF5_installed=1
incardon's avatar
incardon committed
242
243
244
245
246
247
248
        elif [ $conf_err -ne 0 ]; then
            echo "I do not know how to recover from this error"
            exit 1
        fi
    done
fi

249
250
### Create example.mk
install_base=$(cat install_dir)
251
252
253
254
echo "INCLUDE_PATH=-I. -I$install_base/openfpm_numerics/include -I$install_base/openfpm_pdata/include/config -I$install_base/openfpm_pdata/include -I$install_base/openfpm_data/include -I$install_base/openfpm_vcluster/include -I$install_base/openfpm_io/include -I$install_base/openfpm_devices/include -I$i_dir/METIS/include -I$i_dir/PARMETIS/include -I$i_dir/BOOST/include" > example.mk
echo "LIBS_PATH= -L$install_base/openfpm_devices/lib -L$install_base/openfpm_pdata/lib  -L$install_base/openfpm_vcluster/lib -L$i_dir/METIS/lib -L$i_dir/PARMETIS/lib  -L$i_dir/BOOST/lib " >> example.mk
echo "LIBS=-lvcluster -lofpm_pdata -lofpmmemory -lmetis -lparmetis -lboost_iostreams" >> example.mk
echo "LIBS_SE2=-lvcluster -lofpmmemory_se2 -lparmetis -lmetis -lboost_iostreams" >> example.mk
255
256
cp example.mk src/example.mk
cp example.mk example/example.mk
257

incardon's avatar
incardon committed
258
259
260
261
262
263
264
make clean
make

if [ $? -ne 0 ]; then
  conf_err=1
fi

incardon's avatar
incardon committed
265
266
echo ""
echo ""
incardon's avatar
incardon committed
267
if [ $conf_err -eq 0  ]; then
incardon's avatar
incardon committed
268
  echo -e "Install\033[92;5;1m SUCCEED \033[0m"
incardon's avatar
incardon committed
269
else
incardon's avatar
incardon committed
270
  echo -e "Install\033[91;5;1m FAILED \033[0m"
incardon's avatar
incardon committed
271
272
273
274
fi

echo "Command used to configure"
echo ""
Pietro Incardona's avatar
Pietro Incardona committed
275
echo -e "\033[1m ./configure $options $configure_options "$blas_options" \033[0m "
incardon's avatar
incardon committed
276
277
echo ""
if [ $MPI_installed -eq 1 ]; then
incardon's avatar
incardon committed
278
279
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
  echo -e "\033[1;34;5m ----------------- MPI -----------------  \033[0m"
incardon's avatar
incardon committed
280
  echo -e "  MPI has been installed into: \033[1m $i_dir/MPI \033[0m"
incardon's avatar
incardon committed
281
  echo ""
incardon's avatar
incardon committed
282
  if [ x"$platform" = x"linux" ]; then
incardon's avatar
incardon committed
283
    echo -e "\033[1m  export PATH=\"\$PATH:$i_dir/MPI/bin\" \033[0m "
incardon's avatar
incardon committed
284
    echo -e "\033[1m  export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$i_dir/MPI/lib\" \033[0m "
incardon's avatar
incardon committed
285
  else
incardon's avatar
incardon committed
286
    echo -e "\033[1m  export PATH=\"\$PATH:$i_dir/MPI/bin \" \033[0m "
incardon's avatar
incardon committed
287
    echo -e "\033[1m  export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:$i_dir/MPI/lib\" \033[0m"
incardon's avatar
incardon committed
288
  fi
incardon's avatar
incardon committed
289
fi
incardon's avatar
incardon committed
290

incardon's avatar
incardon committed
291
if [ $METIS_installed -eq 1 ]; then
incardon's avatar
incardon committed
292
293
  echo ""
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
294
  echo -e "\033[1;34;5m ---------------- METIS ---------------- \033[0m"
incardon's avatar
incardon committed
295
  echo -e "  METIS has been installed into: \033[1m $i_dir/METIS \033[0m"
incardon's avatar
incardon committed
296
  echo ""
incardon's avatar
incardon committed
297
  if [ x"$platform" = x"linux" ]; then
incardon's avatar
incardon committed
298
    echo -e "\033[1m  export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$i_dir/METIS/lib\" \033[0m "
incardon's avatar
incardon committed
299
  else
incardon's avatar
incardon committed
300
    echo -e "\033[1m  export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:$i_dir/METIS/lib\" \033[0m"
incardon's avatar
incardon committed
301
  fi
302
303
304
305
306
307
fi

if [ $BOOST_installed -eq 1 ]; then
  echo ""
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
  echo -e "\033[1;34;5m ---------------- BOOST ---------------- \033[0m"
incardon's avatar
incardon committed
308
  echo -e "  BOOST has been installed into: \033[1m $i_dir/BOOST \033[0m"
309
  echo ""
incardon's avatar
incardon committed
310
  if [ x"$platform" = x"linux" ]; then
incardon's avatar
incardon committed
311
    echo -e "\033[1m  export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$i_dir/BOOST/lib\" \033[0m "
incardon's avatar
incardon committed
312
  else
incardon's avatar
incardon committed
313
    echo -e "\033[1m  export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:$i_dir/BOOST/lib\" \033[0m"
incardon's avatar
incardon committed
314
  fi
incardon's avatar
incardon committed
315
fi
Pietro Incardona's avatar
Pietro Incardona committed
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
if [ $LAPACK_installed -eq 1 ]; then
  echo ""
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
  echo -e "\033[1;34;5m --------------- OPENBLAS -------------- \033[0m"
  echo -e "  OPENBLAS has been installed into: \033[1m $i_dir/OPENBLAS \033[0m"
  echo ""
  if [ x"$platform" = x"linux" ]; then
    echo -e "\033[1m  export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$i_dir/OPENBLAS/lib\" \033[0m "
  else
    echo -e "\033[1m  export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:$i_dir/OPENBLAS/lib\" \033[0m"
  fi
fi
if [ $SUITESPARSE_installed -eq 1 ]; then
  echo ""
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
  echo -e "\033[1;34;5m ------------- SUITESPARSE ------------- \033[0m"
  echo -e "  SUITESPARSE has been installed into: \033[1m $i_dir/SUITESPARSE \033[0m"
  echo ""
  if [ x"$platform" = x"linux" ]; then
    echo -e "\033[1m  export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$i_dir/SUITESPARSE/lib\" \033[0m "
  else
    echo -e "\033[1m  export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:$i_dir/SUITESPARSE/lib\" \033[0m"
  fi
fi
Pietro Incardona's avatar
Pietro Incardona committed
340
341
342
343
344
345
346
347
348
349
350
351
352
353
if [ $EIGEN_installed -eq 1 ]; then
  echo ""
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
  echo -e "\033[1;34;5m --------------- EIGEN ----------------- \033[0m"
  echo -e "  EIGEN has been installed into: \033[1m $i_dir/EIGEN \033[0m"
  echo ""
fi
if [ $HDF5_installed -eq 1 ]; then
  echo ""
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
  echo -e "\033[1;34;5m ---------------- HDF5 ----------------- \033[0m"
  echo -e "  HDF5 has been installed into: \033[1m $i_dir/HDF5 \033[0m"
  echo ""
fi
354
355
356
357
358
359
360
361
if [ $PARMETIS_installed -eq 1 ]; then
  echo ""
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
  echo -e "\033[1;34;5m ------------- PARMETIS ---------------- \033[0m"
  echo -e "  PARMETIS has been installed into: \033[1m $i_dir/PARMETIS \033[0m"
  echo ""
fi

incardon's avatar
incardon committed
362
363
echo ""
echo ""
364
365
366
if [ $conf_err -ne 0 ]; then
  exit 1
fi