install 7.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
45
46
## Remove old dependencies and installations

remove_old $i_dir

incardon's avatar
incardon committed
47
48
## Check and try to install the prerequisites

incardon's avatar
incardon committed
49
pre_req
incardon's avatar
incardon committed
50
51
52

## clone the dependencies

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

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

incardon's avatar
incardon committed
65
66
67
# Create config directory in each submodule

cd openfpm_data
incardon's avatar
incardon committed
68
69
70
if [ ! -d src/config  ]; then
  mkdir src/config
fi
incardon's avatar
incardon committed
71
git checkout develop
incardon's avatar
incardon committed
72
73
74
cd ..

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

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

cd openfpm_io
incardon's avatar
incardon committed
87
88
89
if [ ! -d src/config  ]; then
  mkdir src/config
fi
incardon's avatar
incardon committed
90
91
cd ..

incardon's avatar
incardon committed
92
# Create config directory
incardon's avatar
incardon committed
93

incardon's avatar
incardon committed
94
95
96
if [ ! -d src/config ]; then
  mkdir src/config
fi
incardon's avatar
incardon committed
97

incardon's avatar
incardon committed
98
## generate configure script
incardon's avatar
incardon committed
99

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

incardon's avatar
incardon committed
106
## check for options
incardon's avatar
incardon committed
107
108
109
110
111
112
113
114

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

echo -e "Installing requirements into: $i_dir "

##

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

## call the configure script

MPI_installed=0
METIS_installed=0
incardon's avatar
incardon committed
131
BOOST_installed=0
incardon's avatar
incardon committed
132
133
conf_err=1

incardon's avatar
incardon committed
134
135
## MPI

incardon's avatar
incardon committed
136
137
138
139
140
141
142
143
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
144
145
    configure_options="$configure_options CXX=mpic++ "
  fi
incardon's avatar
incardon committed
146
147
fi

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

incardon's avatar
incardon committed
150
if [ x"$compiler_opt" != x"" ]; then
incardon's avatar
incardon committed
151
152
  ./script/install_MPI.sh $i_dir $compiler_opt
  export PATH="$PATH:$i_dir/MPI/bin"
incardon's avatar
incardon committed
153
  configure_options="$configure_options CXX=mpic++ "
incardon's avatar
incardon committed
154
155
156
157
158
159
160
161
  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
162

incardon's avatar
incardon committed
163
164
echo "./configure $options $configure_options" 

incardon's avatar
incardon committed
165
if [ $install_req -eq 0 ]; then
incardon's avatar
incardon committed
166
    ./configure $options $configure_options
incardon's avatar
incardon committed
167
168
169
else
    while [ $conf_err -ne 0 ]
    do
incardon's avatar
incardon committed
170
        ./configure $options $configure_options
incardon's avatar
incardon committed
171
172
173
174
175
176
        conf_err=$?

	echo "Configure script terminated with $conf_err"

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

211
212
### Create example.mk
install_base=$(cat install_dir)
incardon's avatar
incardon committed
213
214
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
215
echo "LIBS=-lvcluster -lofpmmemory -lmetis -lboost_iostreams" >> example.mk
216
217
cp example.mk src/example.mk
cp example.mk example/example.mk
218

incardon's avatar
incardon committed
219
220
221
222
223
224
225
make clean
make

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

incardon's avatar
incardon committed
226
227
echo ""
echo ""
incardon's avatar
incardon committed
228
if [ $conf_err -eq 0  ]; then
incardon's avatar
incardon committed
229
  echo -e "Install\033[92;5;1m SUCCEED \033[0m"
incardon's avatar
incardon committed
230
else
incardon's avatar
incardon committed
231
  echo -e "Install\033[91;5;1m FAILED \033[0m"
incardon's avatar
incardon committed
232
233
234
235
fi

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

incardon's avatar
incardon committed
252
if [ $METIS_installed -eq 1 ]; then
incardon's avatar
incardon committed
253
254
  echo ""
  echo -e "\033[1;34;5m ---------------------------------------  \033[0m"
255
  echo -e "\033[1;34;5m ---------------- METIS ---------------- \033[0m"
incardon's avatar
incardon committed
256
  echo -e "  METIS has been installed into: \033[1m $i_dir/METIS \033[0m"
incardon's avatar
incardon committed
257
  echo ""
incardon's avatar
incardon committed
258
  if [ x"$platform" = x"linux" ]; then
incardon's avatar
incardon committed
259
    echo -e "\033[1m  export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$i_dir/METIS/lib\" \033[0m "
incardon's avatar
incardon committed
260
  else
incardon's avatar
incardon committed
261
    echo -e "\033[1m  export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:$i_dir/METIS/lib\" \033[0m"
incardon's avatar
incardon committed
262
  fi
263
264
265
266
267
268
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
269
  echo -e "  BOOST has been installed into: \033[1m $i_dir/BOOST \033[0m"
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/BOOST/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/BOOST/lib\" \033[0m"
incardon's avatar
incardon committed
275
  fi
incardon's avatar
incardon committed
276
277
278
fi
echo ""
echo ""
279
280
281
if [ $conf_err -ne 0 ]; then
  exit 1
fi