install 7.37 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
incardon's avatar
incardon committed
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

##

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
40
41
discover_os

incardon's avatar
incardon committed
42
43
## Check and try to install the prerequisites

incardon's avatar
incardon committed
44
pre_req
incardon's avatar
incardon committed
45
46
47

## clone the dependencies

incardon's avatar
incardon committed
48
git submodule init
Yaser Afshar's avatar
Yaser Afshar committed
49
50
51
52
if [ $? -ne 0 ]; then
  echo -e "Configure\033[91;5;1m FAILED \033[0m"
  exit 1
fi
incardon's avatar
incardon committed
53

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

incardon's avatar
incardon committed
60
61
62
# Create config directory in each submodule

cd openfpm_data
incardon's avatar
incardon committed
63
64
65
if [ ! -d src/config  ]; then
  mkdir src/config
fi
incardon's avatar
incardon committed
66
git checkout develop
incardon's avatar
incardon committed
67
68
69
cd ..

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

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

cd openfpm_io
incardon's avatar
incardon committed
82
83
84
if [ ! -d src/config  ]; then
  mkdir src/config
fi
incardon's avatar
incardon committed
85
86
cd ..

incardon's avatar
incardon committed
87
# Create config directory
incardon's avatar
incardon committed
88

incardon's avatar
incardon committed
89
90
91
if [ ! -d src/config ]; then
  mkdir src/config
fi
incardon's avatar
incardon committed
92

incardon's avatar
incardon committed
93
## generate configure script
incardon's avatar
incardon committed
94

incardon's avatar
incardon committed
95
sh ./autogen.sh
Incardona Pietro's avatar
Incardona Pietro committed
96
97
98
99
if [ $? -ne 0 ]; then
  echo -e "Configure\033[91;5;1m FAILED \033[0m"
  exit 1
fi
incardon's avatar
incardon committed
100

incardon's avatar
incardon committed
101
## check for options
incardon's avatar
incardon committed
102
103
104
105
106
107
108
109

if [ x"$i_dir" == x" " ]; then
 i_dir="$HOME"
fi

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
110
111
112
113
if [ $sq -eq 0 ]; then
  commands[0]="Continue"
  possible_solutions "${commands[@]}"
fi
incardon's avatar
incardon committed
114
115
116
117
118

echo -e "Installing requirements into: $i_dir "

##

incardon's avatar
incardon committed
119
## Take all the options with the exception of -d -i -s
incardon's avatar
incardon committed
120
121
122
123
124

## call the configure script

MPI_installed=0
METIS_installed=0
incardon's avatar
incardon committed
125
BOOST_installed=0
incardon's avatar
incardon committed
126
127
conf_err=1

incardon's avatar
incardon committed
128
129
## MPI

incardon's avatar
incardon committed
130
131
132
133
134
135
136
137
if [ x"$MPI_installation_required" == x"yes"  ]; then
  ./script/install_MPI.sh $i_dir $compiler_opt
  export PATH="$i_dir/MPI/bin:$PATH"
  configure_options="$configure_options CXX=mpic++ "
  MPI_installed=1
else
  command -v mpic++ >/dev/null 2>&1
  if [ $? -eq 0 ]; then
incardon's avatar
incardon committed
138
139
    configure_options="$configure_options CXX=mpic++ "
  fi
incardon's avatar
incardon committed
140
141
fi

incardon's avatar
incardon committed
142
143
## if a new compiler has been installed reinstall all the dependencies

incardon's avatar
incardon committed
144
if [ x"$compiler_opt" != x"" ]; then
incardon's avatar
incardon committed
145
146
  ./script/install_MPI.sh $i_dir $compiler_opt
  export PATH="$PATH:$i_dir/MPI/bin"
incardon's avatar
incardon committed
147
  configure_options="$configure_options CXX=mpic++ "
incardon's avatar
incardon committed
148
149
150
151
152
153
154
155
  MPI_installed=1
  ./script/install_BOOST.sh $i_dir $compiler_opt
  configure_options=" $configure_options --with-boost=$i_dir/BOOST "
  BOOST_installed=1
  ./script/install_METIS.sh $i_dir $compiler_gcc $compiler_gpp
  configure_options=" $configure_options --with-metis=$i_dir/METIS "
  METIS_installed=1
fi
incardon's avatar
incardon committed
156

incardon's avatar
incardon committed
157
158
echo "./configure $options $configure_options" 

incardon's avatar
incardon committed
159
if [ $install_req -eq 0 ]; then
incardon's avatar
incardon committed
160
    ./configure $options $configure_options
incardon's avatar
incardon committed
161
162
163
else
    while [ $conf_err -ne 0 ]
    do
incardon's avatar
incardon committed
164
        ./configure $options $configure_options
incardon's avatar
incardon committed
165
166
167
168
169
170
        conf_err=$?

	echo "Configure script terminated with $conf_err"

        ## if MPI or METIS installation required install it
        if [ $conf_err -eq 200  ]; then
171
            echo "MPI not found try to install, $MPI_installed"
incardon's avatar
incardon committed
172
173
174
175
            if [ $MPI_installed -eq 1 ]; then
                echo "Error the installation of MPI failed"
                exit 1
            fi
incardon's avatar
incardon committed
176
            ./script/install_MPI.sh $i_dir $compiler_opt
incardon's avatar
incardon committed
177
            MPI_installed=1
Yaser Afshar's avatar
Yaser Afshar committed
178
            export PATH="$PATH:$i_dir/MPI/bin"
179
            configure_options="$configure_options CXX=mpic++ "
incardon's avatar
incardon committed
180
181
182
183
184
185
        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
186
            ./script/install_Metis.sh $i_dir $compiler_gcc $compiler_gpp
incardon's avatar
incardon committed
187
            METIS_installed=1
Yaser Afshar's avatar
Yaser Afshar committed
188
            configure_options=" $configure_options --with-metis=$i_dir/METIS "
incardon's avatar
incardon committed
189
        elif [ $conf_err -eq 202 ]; then
incardon's avatar
incardon committed
190
            echo "Boost not found try to install"
incardon's avatar
incardon committed
191
            if [ $BOOST_installed -eq 1  ]; then
incardon's avatar
incardon committed
192
193
194
                echo "Error the installation of Boost failed"
                exit 1
            fi
incardon's avatar
incardon committed
195
            ./script/install_BOOST.sh $i_dir $compiler_opt
incardon's avatar
incardon committed
196
            BOOST_installed=1
Yaser Afshar's avatar
Yaser Afshar committed
197
            configure_options=" $configure_options --with-boost=$i_dir/BOOST "
incardon's avatar
incardon committed
198
199
200
201
202
203
204
        elif [ $conf_err -ne 0 ]; then
            echo "I do not know how to recover from this error"
            exit 1
        fi
    done
fi

205
206
### Create example.mk
install_base=$(cat install_dir)
incardon's avatar
incardon committed
207
208
echo "INCLUDE_PATH=-I. -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
echo "LIBS_PATH=-L$install_base/openfpm_devices/lib -L$install_base/openfpm_vcluster/lib -L$i_dir/METIS/lib -L$i_dir/BOOST/lib " >> example.mk
209
echo "LIBS=-lvcluster -lofpmmemory -lmetis -lboost_iostreams" >> example.mk
210
211
cp example.mk src/example.mk
cp example.mk example/example.mk
212

incardon's avatar
incardon committed
213
214
215
216
217
218
219
make clean
make

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

incardon's avatar
incardon committed
220
221
echo ""
echo ""
incardon's avatar
incardon committed
222
if [ $conf_err -eq 0  ]; then
incardon's avatar
incardon committed
223
  echo -e "Install\033[92;5;1m SUCCEED \033[0m"
incardon's avatar
incardon committed
224
else
incardon's avatar
incardon committed
225
  echo -e "Install\033[91;5;1m FAILED \033[0m"
incardon's avatar
incardon committed
226
227
228
229
fi

echo "Command used to configure"
echo ""
230
echo -e "\033[1m ./configure $options $configure_options \033[0m "
incardon's avatar
incardon committed
231
232
echo ""
if [ $MPI_installed -eq 1 ]; then
incardon's avatar
incardon committed
233
234
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
  echo -e "\033[1;34;5m ----------------- MPI -----------------  \033[0m"
incardon's avatar
incardon committed
235
  echo -e "  MPI has been installed into: \033[1m $i_dir/MPI \033[0m"
incardon's avatar
incardon committed
236
  echo ""
incardon's avatar
incardon committed
237
  if [ x"$platform" = x"linux" ]; then
incardon's avatar
incardon committed
238
    echo -e "\033[1m  export PATH=\"\$PATH:$i_dir/MPI/bin\" \033[0m "
incardon's avatar
incardon committed
239
    echo -e "\033[1m  export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$i_dir/MPI/lib\" \033[0m "
incardon's avatar
incardon committed
240
  else
incardon's avatar
incardon committed
241
    echo -e "\033[1m  export PATH=\"\$PATH:$i_dir/MPI/bin \" \033[0m "
incardon's avatar
incardon committed
242
    echo -e "\033[1m  export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:$i_dir/MPI/lib\" \033[0m"
incardon's avatar
incardon committed
243
  fi
incardon's avatar
incardon committed
244
fi
incardon's avatar
incardon committed
245

incardon's avatar
incardon committed
246
if [ $METIS_installed -eq 1 ]; then
incardon's avatar
incardon committed
247
248
  echo ""
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
249
  echo -e "\033[1;34;5m ---------------- METIS ---------------- \033[0m"
incardon's avatar
incardon committed
250
  echo -e "  METIS has been installed into: \033[1m $i_dir/METIS \033[0m"
incardon's avatar
incardon committed
251
  echo ""
incardon's avatar
incardon committed
252
  if [ x"$platform" = x"linux" ]; then
incardon's avatar
incardon committed
253
    echo -e "\033[1m  export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$i_dir/METIS/lib\" \033[0m "
incardon's avatar
incardon committed
254
  else
incardon's avatar
incardon committed
255
    echo -e "\033[1m  export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:$i_dir/METIS/lib\" \033[0m"
incardon's avatar
incardon committed
256
  fi
257
258
259
260
261
262
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
263
  echo -e "  BOOST has been installed into: \033[1m $i_dir/BOOST \033[0m"
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/BOOST/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/BOOST/lib\" \033[0m"
incardon's avatar
incardon committed
269
  fi
incardon's avatar
incardon committed
270
271
272
fi
echo ""
echo ""
273
274
275
if [ $conf_err -ne 0 ]; then
  exit 1
fi