install 9.47 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
# Create config directory
incardon's avatar
incardon committed
96

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

incardon's avatar
incardon committed
101
## generate configure script
incardon's avatar
incardon committed
102

incardon's avatar
incardon committed
103
sh ./autogen.sh
Incardona Pietro's avatar
Incardona Pietro committed
104
105
106
107
if [ $? -ne 0 ]; then
  echo -e "Configure\033[91;5;1m FAILED \033[0m"
  exit 1
fi
incardon's avatar
incardon committed
108

incardon's avatar
incardon committed
109
## check for options
incardon's avatar
incardon committed
110
111
112
113

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
114
if [ $sq -eq 0 ]; then
115
  unset commands
incardon's avatar
incardon committed
116
117
118
  commands[0]="Continue"
  possible_solutions "${commands[@]}"
fi
incardon's avatar
incardon committed
119
120
121
122
123

echo -e "Installing requirements into: $i_dir "

##

incardon's avatar
incardon committed
124
## Take all the options with the exception of -d -i -s
incardon's avatar
incardon committed
125
126
127
128
129

## call the configure script

MPI_installed=0
METIS_installed=0
incardon's avatar
incardon committed
130
BOOST_installed=0
Pietro Incardona's avatar
Pietro Incardona committed
131
132
133
134
LAPACK_installed=0
SUITESPARSE_installed=0
EIGEN_installed=0
blas_options=""
incardon's avatar
incardon committed
135
136
137
conf_err=1

if [ $install_req -eq 0 ]; then
Pietro Incardona's avatar
Pietro Incardona committed
138
    ./configure $options $configure_options "$blas_options"
incardon's avatar
incardon committed
139
140
141
else
    while [ $conf_err -ne 0 ]
    do
Pietro Incardona's avatar
Pietro Incardona committed
142
        ./configure $options $configure_options "$blas_options"
incardon's avatar
incardon committed
143
144
145
146
147
148
        conf_err=$?

	echo "Configure script terminated with $conf_err"

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

217
218
### Create example.mk
install_base=$(cat install_dir)
Pietro Incardona's avatar
Pietro Incardona committed
219
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
220
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
221
echo "LIBS=-lvcluster -lofpm_pdata -lofpmmemory -lmetis -lboost_iostreams" >> example.mk
222
echo "LIBS_SE2=-lvcluster -lofpmmemory_se2 -lmetis -lboost_iostreams" >> example.mk
223
224
cp example.mk src/example.mk
cp example.mk example/example.mk
225

incardon's avatar
incardon committed
226
227
228
229
230
231
232
make clean
make

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

incardon's avatar
incardon committed
233
234
echo ""
echo ""
incardon's avatar
incardon committed
235
if [ $conf_err -eq 0  ]; then
incardon's avatar
incardon committed
236
  echo -e "Install\033[92;5;1m SUCCEED \033[0m"
incardon's avatar
incardon committed
237
else
incardon's avatar
incardon committed
238
  echo -e "Install\033[91;5;1m FAILED \033[0m"
incardon's avatar
incardon committed
239
240
241
242
fi

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

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