install 9.55 KB
Newer Older
incardon's avatar
incardon committed
1
2
#! /bin/bash

incardon's avatar
incardon committed
3
source script/help
incardon's avatar
incardon committed
4
source script/discover_os
incardon's avatar
incardon committed
5
source script/show_solutions
incardon's avatar
incardon committed
6
source script/pre_req
7
source script/remove_old
incardon's avatar
incardon committed
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

##

install_req=1
i_dir=" "
sq=0

while getopts :di:shc: FLAG; do
  case $FLAG in
    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
      HELP
      ;;
    \?) #unrecognized option - are fowarded to configure
      ;;
  esac
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
134
135

## call the configure script

MPI_installed=0
METIS_installed=0
incardon's avatar
incardon committed
136
BOOST_installed=0
Pietro Incardona's avatar
Pietro Incardona committed
137
138
139
140
LAPACK_installed=0
SUITESPARSE_installed=0
EIGEN_installed=0
blas_options=""
incardon's avatar
incardon committed
141
142
143
conf_err=1

if [ $install_req -eq 0 ]; then
Pietro Incardona's avatar
Pietro Incardona committed
144
    ./configure $options $configure_options "$blas_options"
incardon's avatar
incardon committed
145
146
147
else
    while [ $conf_err -ne 0 ]
    do
Pietro Incardona's avatar
Pietro Incardona committed
148
        ./configure $options $configure_options "$blas_options"
incardon's avatar
incardon committed
149
150
151
152
153
154
        conf_err=$?

	echo "Configure script terminated with $conf_err"

        ## if MPI or METIS installation required install it
        if [ $conf_err -eq 200  ]; then
155
            echo "MPI not found try to install, $MPI_installed"
incardon's avatar
incardon committed
156
157
158
159
            if [ $MPI_installed -eq 1 ]; then
                echo "Error the installation of MPI failed"
                exit 1
            fi
incardon's avatar
incardon committed
160
            ./script/install_MPI.sh $i_dir $compiler_opt
incardon's avatar
incardon committed
161
            MPI_installed=1
Yaser Afshar's avatar
Yaser Afshar committed
162
            export PATH="$PATH:$i_dir/MPI/bin"
163
            configure_options="$configure_options CXX=mpic++ "
incardon's avatar
incardon committed
164
165
166
167
168
169
        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
170
            ./script/install_Metis.sh $i_dir $compiler_gcc $compiler_gpp
incardon's avatar
incardon committed
171
            METIS_installed=1
Yaser Afshar's avatar
Yaser Afshar committed
172
            configure_options=" $configure_options --with-metis=$i_dir/METIS "
incardon's avatar
incardon committed
173
        elif [ $conf_err -eq 202 ]; then
174
            echo "Boost not found try to install in $i_dir with $compiler_opt"
incardon's avatar
incardon committed
175
            if [ $BOOST_installed -eq 1  ]; then
incardon's avatar
incardon committed
176
177
178
                echo "Error the installation of Boost failed"
                exit 1
            fi
incardon's avatar
incardon committed
179
            ./script/install_BOOST.sh $i_dir $compiler_opt
incardon's avatar
incardon committed
180
            BOOST_installed=1
Yaser Afshar's avatar
Yaser Afshar committed
181
            configure_options=" $configure_options --with-boost=$i_dir/BOOST "
Pietro Incardona's avatar
Pietro Incardona committed
182
183
184
185
186
187
        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
188
189
            ./script/install_OPENBLAS.sh $i_dir $compiler_opt
            LAPACK_installed=1
jenkins's avatar
jenkins committed
190
            blas_options="--with-blas=-L$i_dir/OPENBLAS/lib/ -lopenblas"
Pietro Incardona's avatar
Pietro Incardona committed
191
        elif [ $conf_err -eq 205 ]; then
192
193
194
195
            ## 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
196
            blas_options="--with-blas=-L$i_dir/OPENBLAS/lib/ -lopenblas"
197
198
        
            ## Then suite sparse
Pietro Incardona's avatar
Pietro Incardona committed
199
200
201
202
203
204
            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
205
206
207
208
209
210
211
212
213
214
215
            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
incardon's avatar
incardon committed
216
217
218
219
220
221
222
        elif [ $conf_err -ne 0 ]; then
            echo "I do not know how to recover from this error"
            exit 1
        fi
    done
fi

223
224
### Create example.mk
install_base=$(cat install_dir)
Pietro Incardona's avatar
Pietro Incardona committed
225
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/BOOST/include" > example.mk
226
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/BOOST/lib " >> example.mk
Pietro Incardona's avatar
Pietro Incardona committed
227
echo "LIBS=-lvcluster -lofpm_pdata -lofpmmemory -lmetis -lboost_iostreams" >> example.mk
228
echo "LIBS_SE2=-lvcluster -lofpmmemory_se2 -lmetis -lboost_iostreams" >> example.mk
229
230
cp example.mk src/example.mk
cp example.mk example/example.mk
231

incardon's avatar
incardon committed
232
233
234
235
236
237
238
make clean
make

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

incardon's avatar
incardon committed
239
240
echo ""
echo ""
incardon's avatar
incardon committed
241
if [ $conf_err -eq 0  ]; then
incardon's avatar
incardon committed
242
  echo -e "Install\033[92;5;1m SUCCEED \033[0m"
incardon's avatar
incardon committed
243
else
incardon's avatar
incardon committed
244
  echo -e "Install\033[91;5;1m FAILED \033[0m"
incardon's avatar
incardon committed
245
246
247
248
fi

echo "Command used to configure"
echo ""
Pietro Incardona's avatar
Pietro Incardona committed
249
echo -e "\033[1m ./configure $options $configure_options "$blas_options" \033[0m "
incardon's avatar
incardon committed
250
251
echo ""
if [ $MPI_installed -eq 1 ]; then
incardon's avatar
incardon committed
252
253
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
  echo -e "\033[1;34;5m ----------------- MPI -----------------  \033[0m"
incardon's avatar
incardon committed
254
  echo -e "  MPI has been installed into: \033[1m $i_dir/MPI \033[0m"
incardon's avatar
incardon committed
255
  echo ""
incardon's avatar
incardon committed
256
  if [ x"$platform" = x"linux" ]; then
incardon's avatar
incardon committed
257
    echo -e "\033[1m  export PATH=\"\$PATH:$i_dir/MPI/bin\" \033[0m "
incardon's avatar
incardon committed
258
    echo -e "\033[1m  export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$i_dir/MPI/lib\" \033[0m "
incardon's avatar
incardon committed
259
  else
incardon's avatar
incardon committed
260
    echo -e "\033[1m  export PATH=\"\$PATH:$i_dir/MPI/bin \" \033[0m "
incardon's avatar
incardon committed
261
    echo -e "\033[1m  export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:$i_dir/MPI/lib\" \033[0m"
incardon's avatar
incardon committed
262
  fi
incardon's avatar
incardon committed
263
fi
incardon's avatar
incardon committed
264

incardon's avatar
incardon committed
265
if [ $METIS_installed -eq 1 ]; then
incardon's avatar
incardon committed
266
267
  echo ""
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
268
  echo -e "\033[1;34;5m ---------------- METIS ---------------- \033[0m"
incardon's avatar
incardon committed
269
  echo -e "  METIS has been installed into: \033[1m $i_dir/METIS \033[0m"
incardon's avatar
incardon committed
270
  echo ""
incardon's avatar
incardon committed
271
  if [ x"$platform" = x"linux" ]; then
incardon's avatar
incardon committed
272
    echo -e "\033[1m  export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$i_dir/METIS/lib\" \033[0m "
incardon's avatar
incardon committed
273
  else
incardon's avatar
incardon committed
274
    echo -e "\033[1m  export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:$i_dir/METIS/lib\" \033[0m"
incardon's avatar
incardon committed
275
  fi
276
277
278
279
280
281
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
282
  echo -e "  BOOST has been installed into: \033[1m $i_dir/BOOST \033[0m"
283
  echo ""
incardon's avatar
incardon committed
284
  if [ x"$platform" = x"linux" ]; then
incardon's avatar
incardon committed
285
    echo -e "\033[1m  export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$i_dir/BOOST/lib\" \033[0m "
incardon's avatar
incardon committed
286
  else
incardon's avatar
incardon committed
287
    echo -e "\033[1m  export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:$i_dir/BOOST/lib\" \033[0m"
incardon's avatar
incardon committed
288
  fi
incardon's avatar
incardon committed
289
fi
Pietro Incardona's avatar
Pietro Incardona committed
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
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
incardon's avatar
incardon committed
314
315
echo ""
echo ""
316
317
318
if [ $conf_err -ne 0 ]; then
  exit 1
fi