pre_req 7.05 KB
Newer Older
incardon's avatar
incardon committed
1
2
#! /bin/bash

incardon's avatar
incardon committed
3
4
function pre_req()
{
incardon's avatar
incardon committed
5
source script/discover_package_manager
incardon's avatar
incardon committed
6
source script/discover_os
incardon's avatar
incardon committed
7
8
source script/solve_autoconf
source script/solve_gpp
incardon's avatar
incardon committed
9
source script/solve_gfortran
incardon's avatar
incardon committed
10
11
12
13
14
15
source script/solve_cmake
source script/solve_git
source script/solve_wget
source script/solve_automake
source script/solve_brew
source script/solve_libtool
incardon's avatar
incardon committed
16
17
source script/detect_gcc
source script/detect_osx
incardon's avatar
incardon committed
18
source script/show_solutions
incardon's avatar
incardon committed
19
source script/detect_fortran
incardon's avatar
incardon committed
20

incardon's avatar
incardon committed
21
discover_os
incardon's avatar
incardon committed
22
discover_package_manager $platform
Incardona Pietro's avatar
Incardona Pietro committed
23
pcman=$discover_package_manager_ret
incardon's avatar
incardon committed
24

Incardona Pietro's avatar
Incardona Pietro committed
25
if [ x"$platform" = x"osx" -a x"$pcman" = x""  ]; then
incardon's avatar
incardon committed
26
27
  echo -e "\033[30;43;5;1m WARNING \033[0m No package manager has been found on this system"
  solve_brew $platform
Incardona Pietro's avatar
Incardona Pietro committed
28
29
30
31
32
33

  discover_package_manager $platform
  pcman=$discover_package_manager_ret
  if [ x"$pcman" != x"brew" ]; then
    echo -e "brew \033[91;5;1m FAILED \033[0m"
  fi
incardon's avatar
incardon committed
34
35
fi

incardon's avatar
incardon committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
### Additional package required for apt-get based distros
if [ x"$platform" = x"linux" -a x"$pcman" = x"sudo apt-get"  ]; then
  dpkg-query -l libbz2-dev
  ret1=$?
  dpkg-query -l python-dev
  ret2=$?
  dpkg-query -l libxml2-dev
  ret3=$?
  dpkg-query -l libxslt-dev
  ret4=$?
  if [ $ret1 -ne 0 -o $ret2 -ne 0 -o $ret3 -ne 0 -o $ret4 -ne 0 ]; then
    echo "OpenFPM require additional packages in order to install correctly"
    commands[0]="$pcman install libbz2-dev python-dev libxml2-dev libxslt-dev"
    possible_solutions "${commands[@]}"
    echo "Executing: ${command[$possible_solutions_ret]}"
    eval ${commands[$possible_solutions_ret]}
  fi
fi

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
### Additional package required for yum based distros
if [ x"$platform" = x"linux" -a x"$pcman" = x"yum"  ]; then
  rpm -V bzip2-devel
  ret1=$?
  rpm -V python-devel
  ret2=$?
  rpm -V libxml2-devel
  ret3=$?
  rpm -V libxslt-devel
  ret4=$?
  if [ $ret1 -ne 0 -o $ret2 -ne 0 -o $ret3 -ne 0 -o $ret4 -ne 0 ]; then
    echo "OpenFPM require additional packages in order to install correctly"
    commands[0]="su -c \"$pcman install bzip2-devel python-devel libxml2-devel libxslt-devel\""
    commands[1]="sudo $pcman install bzip2-devel python-devel libxml2-devel libxslt-devel"
    possible_solutions "${commands[@]}"
    echo "Executing: ${command[$possible_solutions_ret]}"
    eval ${commands[$possible_solutions_ret]}
  fi
fi

incardon's avatar
incardon committed
75
command -v cmake >/dev/null 2>&1
76
77
if [ $? -ne 0 ]; then
  echo >&2
incardon's avatar
incardon committed
78
79
  echo -e "cmake\033[91;5;1m FAILED \033[0m"
  echo "OpenFPM require cmake but it's not installed, searching a solution... "
incardon's avatar
incardon committed
80
  solve_cmake $platform
incardon's avatar
incardon committed
81
  command -v cmake >/dev/null 2>&1
82
  if [ $? -ne 0 ]; then
incardon's avatar
incardon committed
83
    echo -e "cmake\033[91;5;1m FAILED \033[0m"
84
85
    exit 1
  else
incardon's avatar
incardon committed
86
    echo -e "cmake\033[92;1m SUCCESS \033[0m"
87
88
  fi
else
incardon's avatar
incardon committed
89
  echo -e "cmake\033[92;1m SUCCESS \033[0m"
90
91
fi

incardon's avatar
incardon committed
92
93
94
95
96
command -v wget >/dev/null 2>&1
if [ $? -ne 0 ]; then
  echo >&2
  echo -e "wget\033[91;5;1m FAILED \033[0m"
  echo "OpenFPM require wget but it's not installed, searching a solution... "
incardon's avatar
incardon committed
97
  solve_wget $platform
incardon's avatar
incardon committed
98
99
100
101
102
103
104
105
106
107
108
  command -v wget >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    echo -e "wget\033[91;5;1m FAILED \033[0m"
    exit 1
  else
    echo -e "wget\033[92;1m SUCCESS \033[0m"
  fi
else
  echo -e "wget \033[92;1m SUCCESS \033[0m"
fi

incardon's avatar
incardon committed
109
110
111
112
113
command -v git >/dev/null 2>&1
if [ $? -ne 0 ]; then 
  echo >&2
  echo -e "git\033[91;5;1m FAILED \033[0m"
  echo "OpenFPM require git but it's not installed, searching a solution... "
incardon's avatar
incardon committed
114
  solve_git $platform
incardon's avatar
incardon committed
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
  command -v git >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    echo -e "git\033[91;5;1m FAILED \033[0m"
    exit 1
  else
    echo -e "git\033[92;1m SUCCESS \033[0m"
  fi
else
  echo -e "git \033[92;1m SUCCESS \033[0m"
fi

command -v autoconf >/dev/null 2>&1
if [ $? -ne 0 ]; then
  echo >&2
  echo -e "autoconf\033[91;5;1m FAILED \033[0m"
  echo "OpenFPM require autoconf but it's not installed, searching a solution..."
incardon's avatar
incardon committed
131
  solve_autoconf $platform
incardon's avatar
incardon committed
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
  command -v autoheader >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    echo -e "autoconf\033[91;5;1m FAILED \033[0m"
    exit 1
  else
    echo -e "autoconf\033[92;1m SUCCESS \033[0m"
  fi
else
  echo -e "autoconf\033[92;1m SUCCESS \033[0m"
fi

command -v automake >/dev/null 2>&1
if [ $? -ne 0 ]; then
  echo >&2
  echo -e "automake\033[91;5;1m FAILED \033[0m"
  echo "OpenFPM require automake but it's not installed, searching a solution..."
incardon's avatar
incardon committed
148
  solve_automake $platform
incardon's avatar
incardon committed
149
150
151
152
153
154
155
156
157
158
159
  command -v automake >/dev/null 2>&1
  if [ $? -ne 0 ]; then
    echo "automake\033[91;5;1m FAILED \033[0m"
    exit 1
  else
    echo -e "automake\033[92;1m SUCCESS \033[0m"
  fi
else
  echo -e "automake\033[92;1m SUCCESS \033[0m"
fi

Incardona Pietro's avatar
Incardona Pietro committed
160
161
162
163
164

command -v libtoolize  >/dev/null 2>&1
opt1=$?
command -v glibtoolize  >/dev/null 2>&1
opt2=$?
incardon's avatar
incardon committed
165
if [ $opt1 -ne 0 -a $opt2 -ne 0 ]; then
incardon's avatar
incardon committed
166
167
168
  echo >&2
  echo -e "libtool\033[91;5;1m FAILED \033[0m"
  echo "OpenFPM require libtool but it's not installed, searching a solution..."
incardon's avatar
incardon committed
169
  solve_libtool $platform
Incardona Pietro's avatar
Incardona Pietro committed
170
171
172
173
  command -v libtoolize  >/dev/null 2>&1
  opt1=$?
  command -v glibtoolize  >/dev/null 2>&1
  opt2=$?
incardon's avatar
incardon committed
174
  if [ $opt1 -ne 0 -a $opt2 -ne 0 ]; then
incardon's avatar
incardon committed
175
176
177
178
179
180
181
182
183
    echo -e "libtool\033[91;5;1m FAILED \033[0m"
    exit 1
  else
    echo -e "libtool\033[92;1m SUCCESS \033[0m"
  fi
else
  echo -e "libtool\033[92;1m SUCCESS \033[0m"
fi

incardon's avatar
incardon committed
184
185
#### Detecting g++

186
detect_gcc_or_clang g++
incardon's avatar
incardon committed
187
if [ $dgc_ret -eq 0 ]; then
incardon's avatar
incardon committed
188
  echo -e "g++ \033[91;5;1m FAILED \033[0m"
incardon's avatar
incardon committed
189
  solve_gpp $platform
190
  detect_gcc_or_clang $compiler_gpp
incardon's avatar
incardon committed
191
192
  if [ $dgc_ret -eq 0 ]; then
    exit 1
incardon's avatar
incardon committed
193
  fi
incardon's avatar
incardon committed
194
195
196
197
198
199
elif [ $dgc_ret -eq 2 ]; then
  detect_osx $platform
  if [ $dosx_ret -eq 1 ]; then
    echo -e "\033[30;43;5;1m------------------------------- WARNING --------------------------------\033[0m"
    echo "g++ seem to be present, but we failed to detect the version. Your system $dosx_major.$dosx_middle.$dosx_minor seem to be recent enough, so we will continue the installation"
    sleep 10    
incardon's avatar
incardon committed
200
  fi
incardon's avatar
incardon committed
201
202
fi

incardon's avatar
incardon committed
203
204
205
206
#### Detection gfortran

detect_fortran gfortran
if [ $dgc_ret -eq 0 ]; then
incardon's avatar
incardon committed
207
  echo -e "gfortran\033[91;5;1m FAILED \033[0m"
incardon's avatar
incardon committed
208
209
210
211
212
213
214
215
216
217
  solve_gfortran $platform
  detect_fortran $compiler_fortran
  if [ $dgc_ret -eq 0 ]; then
    exit 1
  fi
else
  echo -e "gfortran \033[92;1m SUCCESS \033[0m"
fi


incardon's avatar
incardon committed
218
219
220
221
command -v mpirun >/dev/null 2>&1
if [ $? -ne 0 ]; then
  echo -e "No MPI"
else
incardon's avatar
incardon committed
222
223
224
  major=$(mpirun --version 2>&1 | grep mpirun | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1/g')
  middle=$(mpirun --version 2>&1 | grep mpirun | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\2/g')
  minor=$(mpirun --version 2>&1 | grep mpirun | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\3/g')
incardon's avatar
incardon committed
225
226
  if [ $major -gt 1 ]; then
    echo -e "mpirun $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
227
    MPI_valid=yes
incardon's avatar
incardon committed
228
229
230
231
  elif [ $major -lt 1 ]; then
    echo -e "mpirun $major.$middle.$minor \033[91;5;1m FAILED \033[0m is too old, 1.8.1 at least required"
  elif [ $middle -gt 8  ]; then
    echo -e "mpirun $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
232
    MPI_valid=yes
incardon's avatar
incardon committed
233
234
235
236
  elif [ $middle -lt 8 ]; then
    echo -e "mpirun $major.$middle.$minor \033[91;5;1m FAILED \033[0m is too old, 1.8.1 at least required"
  elif [ $minor -gt 0  ]; then
    echo -e "mpirun $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
237
    MPI_valid=yes
incardon's avatar
incardon committed
238
  else
incardon's avatar
incardon committed
239
    echo -e "mpirun $major.$middle.$minor \033[91;5;1m FAILED \033[0m is too old, 1.8.1 at least required"
incardon's avatar
incardon committed
240
241
  fi 
fi
incardon's avatar
incardon committed
242
}
incardon's avatar
incardon committed
243