Skip to content

Commit 89bdca6

Browse files
committed
Added the build of the flex prerequisite when necesssary for building GCC from source. Corrected string literal constant error in install_prerequisites/acceptable_compiler.f90.
Signed-off-by: Damian Rouson <[email protected]>
1 parent 6cfcd1d commit 89bdca6

File tree

2 files changed

+104
-34
lines changed

2 files changed

+104
-34
lines changed

install.sh

Lines changed: 69 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,37 @@
3232
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3333
# POSSIBILITY OF SUCH DAMAGE.
3434

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+
3545
this_script=`basename $0`
3646

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+
3766
usage()
3867
{
3968
echo ""
@@ -55,25 +84,6 @@ usage()
5584
exit 1
5685
}
5786

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-
7787
find_or_install()
7888
{
7989
package=$1
@@ -149,11 +159,36 @@ find_or_install()
149159
fi
150160

151161
# 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
153164
if [[ $proceed == "y" ]]; then
154165
printf "Downloading, building, and installing $package \n"
155166
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 &&
157192
package_install_path=`./build $package --default --query` &&
158193
if [[ -f $package_install_path/bin/$executable ]]; then
159194
printf "Installation successful."
@@ -165,24 +200,23 @@ find_or_install()
165200
elif [[ $package == "mpich" ]]; then
166201
MPICC=$package_install_path/bin/mpicc
167202
MPIFC=$package_install_path/bin/mpif90
168-
else
169-
PATH=$package_install_path/bin:$PATH
170203
fi
204+
PATH=$package_install_path/bin:$PATH
171205
return
172206
else
173207
printf "Installation unsuccessful."
174208
printf "$package is not in the expected path: $package_install_path/bin \n"
175209
exit 1
176210
fi
177211
else
178-
printf "Aborting. OpenCoarrays installation requires $package"
212+
printf "Aborting. OpenCoarrays installation requires $package \n"
179213
exit 1
180214
fi
181215
printf "$this_script: the dependency installation logic is missing a return or exit.\n"
182216
exit 1
183217
}
184218

185-
###### Main Body ##########
219+
# ___________________ Define functions for use in the main body ___________________
186220

187221
if [[ $1 == '--help' || $1 == '-h' ]]; then
188222
# Print usage information if script is invoked with --help or -h argument
@@ -201,23 +235,25 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
201235
echo ""
202236
else
203237

238+
204239
# Find or install prerequisites and install OpenCoarrays
240+
build_path=${PWD}/opencoarrays-build
205241
installation_record=install-opencoarrays.log
206242
time \
207243
{
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 &&
214250
if [[ -z $MPICC || -z $MPIFC ]]; then
215251
echo "Empty MPICC=$MPICC or MPIFC=$MPIFC"
216252
exit 1
217253
else
218254
CC=$MPICC FC=$MPIFC cmake .. -DCMAKE_INSTALL_PREFIX=$install_path &&
219-
make &&
220-
make install &&
255+
make -j$num_threads &&
256+
make install &&
221257
make clean
222258
fi
223259
} >&1 | tee $installation_record
Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
1+
!
2+
! acceptable_compiler
3+
!
4+
! -- Report whether the compiler version equals or exceeds the first
5+
! OpenCoarrays-aware version
6+
!
7+
! OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
8+
! Copyright (c) 2015, Sourcery, Inc.
9+
! Copyright (c) 2015, Sourcery Institute
10+
! All rights reserved.
11+
!
12+
! Redistribution and use in source and binary forms, with or without modification,
13+
! are permitted provided that the following conditions are met:
14+
!
15+
! 1. Redistributions of source code must retain the above copyright notice, this
16+
! list of conditions and the following disclaimer.
17+
! 2. Redistributions in binary form must reproduce the above copyright notice, this
18+
! list of conditions and the following disclaimer in the documentation and/or
19+
! other materials provided with the distribution.
20+
! 3. Neither the names of the copyright holders nor the names of their contributors
21+
! may be used to endorse or promote products derived from this software without
22+
! specific prior written permission.
23+
!
24+
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25+
! ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26+
! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27+
! IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28+
! INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29+
! NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30+
! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+
! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32+
! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33+
! POSSIBILITY OF SUCH DAMAGE.
34+
135
program main
236
use iso_fortran_env, only : compiler_version
337
implicit none
4-
print *,compiler_version() >= " GCC version 5.1.0"
38+
print *,compiler_version() >= "GCC version 5.1.0 "
539
end program

0 commit comments

Comments
 (0)