32
32
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
33
# POSSIBILITY OF SUCH DAMAGE.
34
34
35
+ # This file is organized into three sections:
36
+ # 1. Command-line argument processor.
37
+ # 2. Function definitions.
38
+ # 3. Main body.
39
+ # The script depends on several external programs, including a second script that
40
+ # builds prerequisite software. Building prerequisites requires network access
41
+ # unless tar balls of the prerequisites are present.
42
+
43
+ # ___________________ Process command-line arguments ___________________
44
+
35
45
this_script=` basename $0 `
36
46
47
+ # Interpret the first command-line argument, if present, as the OpenCoarrays installation path.
48
+ # Otherwise, install in a subdirectory of the present working directory.
49
+ if [[ -z $1 ]]; then
50
+ install_path=${PWD} /opencoarrays-installation
51
+ else
52
+ install_path=$1
53
+ fi
54
+
55
+
56
+ # Interpret the second command-line argument, if present, as the number of threads for 'make'.
57
+ # Otherwise, default to single-threaded 'make'.
58
+ if [[ -z $2 ]]; then
59
+ num_threads=1
60
+ else
61
+ num_threads=$2
62
+ fi
63
+
64
+ # ___________________ Define functions for use in the main body ___________________
65
+
37
66
usage ()
38
67
{
39
68
echo " "
@@ -55,25 +84,6 @@ usage()
55
84
exit 1
56
85
}
57
86
58
- # Interpret the first command-line argument, if present, as the installation path.
59
- # Otherwise, install in a subdirectory of the present working directory.
60
- default_install_path=${PWD} /opencoarrays-installation
61
- if [[ -z $1 ]]; then
62
- install_path=$default_install_path
63
- else
64
- install_path=$1
65
- fi
66
-
67
- build_path=${PWD} /opencorrays-build
68
-
69
- # Interpret the second command-line argument, if present, as the number of threads for 'make'.
70
- # Otherwise, default to single-threaded 'make'.
71
- if [[ -z $2 ]]; then
72
- num_threads=1
73
- else
74
- num_threads=$2
75
- fi
76
-
77
87
find_or_install ()
78
88
{
79
89
package=$1
@@ -149,11 +159,36 @@ find_or_install()
149
159
fi
150
160
151
161
# Now we know the $executable is not in the PATH or is not an acceptable version
152
- printf " Ok to downloand, build, and install $package from source?\n"
162
+ printf " Ok to downloand, build, and install $package from source? (y/n) "
163
+ read proceed
153
164
if [[ $proceed == " y" ]]; then
154
165
printf " Downloading, building, and installing $package \n"
155
166
cd install_prerequisites &&
156
- FC=gfortran CC=gcc CXX=g++ ./build $package &&
167
+ if [[ $package == " gcc" ]]; then
168
+ # Building GCC from source requires flex
169
+ printf " Building requires the 'flex' package.\n"
170
+ printf " Checking flex is in the PATH... "
171
+ if type flex > /dev/null; then
172
+ printf " yes\n"
173
+ else
174
+ printf " no\n"
175
+ printf " Ok to downloand, build, and install flex from source? (y/n) "
176
+ read build_flex
177
+ if [[ $build_flex == " y" ]]; then
178
+ FC=gfortran CC=gcc CXX=g++ ./build flex
179
+ flex_install_path=` ./build flex --default --query` &&
180
+ if [[ -f $flex_install_path /bin/flex ]]; then
181
+ printf " Installation successful."
182
+ printf " $package is in $flex_install_path /bin \n"
183
+ fi
184
+ PATH=$flex_install_path /bin:$PATH
185
+ else
186
+ printf " Aborting. Building GCC requires flex.\n"
187
+ exit 1
188
+ fi
189
+ fi
190
+ fi
191
+ FC=gfortran CC=gcc CXX=g++ ./build $package --default $num_threads &&
157
192
package_install_path=` ./build $package --default --query` &&
158
193
if [[ -f $package_install_path /bin/$executable ]]; then
159
194
printf " Installation successful."
@@ -165,24 +200,23 @@ find_or_install()
165
200
elif [[ $package == " mpich" ]]; then
166
201
MPICC=$package_install_path /bin/mpicc
167
202
MPIFC=$package_install_path /bin/mpif90
168
- else
169
- PATH=$package_install_path /bin:$PATH
170
203
fi
204
+ PATH=$package_install_path /bin:$PATH
171
205
return
172
206
else
173
207
printf " Installation unsuccessful."
174
208
printf " $package is not in the expected path: $package_install_path /bin \n"
175
209
exit 1
176
210
fi
177
211
else
178
- printf " Aborting. OpenCoarrays installation requires $package "
212
+ printf " Aborting. OpenCoarrays installation requires $package \n "
179
213
exit 1
180
214
fi
181
215
printf " $this_script : the dependency installation logic is missing a return or exit.\n"
182
216
exit 1
183
217
}
184
218
185
- # ##### Main Body ##########
219
+ # ___________________ Define functions for use in the main body ___________________
186
220
187
221
if [[ $1 == ' --help' || $1 == ' -h' ]]; then
188
222
# Print usage information if script is invoked with --help or -h argument
@@ -201,23 +235,25 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
201
235
echo " "
202
236
else
203
237
238
+
204
239
# Find or install prerequisites and install OpenCoarrays
240
+ build_path=${PWD} /opencoarrays-build
205
241
installation_record=install-opencoarrays.log
206
242
time \
207
243
{
208
- # Find or install GCC first to ensure we build MPICH with an acceptable version of GCC
209
- find_or_install gcc &&
210
- find_or_install mpich &&
211
- find_or_install cmake &&
212
- mkdir -p opencoarrays-build &&
213
- cd opencoarrays-build &&
244
+ # Building OpenCoarrays with CMake requires MPICH and GCC; MPICH requires GCC.
245
+ find_or_install gcc &&
246
+ find_or_install mpich &&
247
+ find_or_install cmake &&
248
+ mkdir -p $build_path &&
249
+ cd $build_path &&
214
250
if [[ -z $MPICC || -z $MPIFC ]]; then
215
251
echo " Empty MPICC=$MPICC or MPIFC=$MPIFC "
216
252
exit 1
217
253
else
218
254
CC=$MPICC FC=$MPIFC cmake .. -DCMAKE_INSTALL_PREFIX=$install_path &&
219
- make &&
220
- make install &&
255
+ make -j $num_threads &&
256
+ make install &&
221
257
make clean
222
258
fi
223
259
} >&1 | tee $installation_record
0 commit comments