diff --git a/.VERSION b/.VERSION index 0786f722e..6aa584345 100644 --- a/.VERSION +++ b/.VERSION @@ -1,6 +1,6 @@ $Format:%d%n%n$ # Fall back version, probably last release: -2.9.2 +3.0.0 # OpenCoarrays version file. This project uses semantic # versioning. For details see http://semver.org diff --git a/AUTHORS.md b/AUTHORS.md index ea1cae641..803af4be6 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -28,6 +28,7 @@ Download this file as a PDF document - [X] Götz Waschk @LaHaine - [ ] John C. Linford - [ ] Daniel Carrera + - [ ] Brad Richardson [top] diff --git a/INSTALL b/INSTALL index 17b98134b..a64cccf9f 100644 --- a/INSTALL +++ b/INSTALL @@ -156,3 +156,8 @@ Configure options For a look at all of the possible CMake settings, many/most of which are default CMake options, please run `ccmake /path/to/source` or `cmake-gui /path/to/source`. + +Experimental fpm build +---------------------- + +./run-fpm.sh diff --git a/example/hello.f90 b/example/hello.f90 new file mode 100644 index 000000000..504e39fe3 --- /dev/null +++ b/example/hello.f90 @@ -0,0 +1,4 @@ +program main + implicit none + print*,"Hello from image ",this_image() +end program diff --git a/example/support-test/README.md b/example/support-test/README.md new file mode 100644 index 000000000..bbdd8856e --- /dev/null +++ b/example/support-test/README.md @@ -0,0 +1,3 @@ +Test Support +------------ +The programs in this directory intentionally error-terminate to support the `error stop` tests in `test/caf_error_stop.f90`, which use Fortran's `execute_command_line` to run the programms in this directory and check for the expected non-zero stop codes. Running the tests in this manner enables the Vegetable tests to continue executing in the presence of error-terminating tests. diff --git a/example/support-test/error_stop_character_code.f90 b/example/support-test/error_stop_character_code.f90 new file mode 100644 index 000000000..78721bfae --- /dev/null +++ b/example/support-test/error_stop_character_code.f90 @@ -0,0 +1,7 @@ +program error_stop_character_code + implicit none + + error stop "" + + stop 0 ! ../../test/error_stop_test.f90 will report a test failure if this line runs +end program diff --git a/example/support-test/error_stop_integer_code.f90 b/example/support-test/error_stop_integer_code.f90 new file mode 100644 index 000000000..6e61b3752 --- /dev/null +++ b/example/support-test/error_stop_integer_code.f90 @@ -0,0 +1,7 @@ +program error_stop_integer_code + implicit none + + error stop + + stop 0 ! caffeine/test/error_stop_test.f90 reports a failure if this line runs +end program diff --git a/example/support-test/normal_termination.f90 b/example/support-test/normal_termination.f90 new file mode 100644 index 000000000..8dfff9289 --- /dev/null +++ b/example/support-test/normal_termination.f90 @@ -0,0 +1,7 @@ +program normal_termination + implicit none + + stop 0 + + stop 1 ! opencoarrays/test/zzz_finalization_test.f90 reports a failure if this line runs +end program diff --git a/fpm.toml b/fpm.toml new file mode 100644 index 000000000..cd32e3e26 --- /dev/null +++ b/fpm.toml @@ -0,0 +1,13 @@ +name = "opencoarrays" +version = "3.0.0" +license = "BSD" +author = ["Sourcery Institute"] +maintainer = "damian@archaeologic.codes" +copyright = "2015-2022 Sourcery Institute" + +[install] +library = true + +[dev-dependencies] +garden = {git = "https://gitlab.com/everythingfunctional/garden", tag = "v1.0.1"} +assert= {git = "https://github.com/sourceryinstitute/assert", tag = "1.3.0"} diff --git a/install.sh b/install.sh index ffbcabc8a..28fde5839 100755 --- a/install.sh +++ b/install.sh @@ -1,354 +1,329 @@ -#!/usr/bin/env bash -# -# install.sh -# -# -- This script installs OpenCoarrays and its prerequisites. -# -# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License: -# Copyright (c) 2015-2016, Sourcery, Inc. -# Copyright (c) 2015-2016, Sourcery Institute -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright notice, this -# list of conditions and the following disclaimer in the documentation and/or -# other materials provided with the distribution. -# 3. Neither the names of the copyright holders nor the names of their contributors -# may be used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# Portions of this script derive from BASH3 Boilerplate and are distributed under -# the following license: -# -# The MIT License (MIT) -# -# Copyright (c) 2014 Kevin van Zonneveld -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# -# - https://github.com/kvz/bash3boilerplate -# - http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/ -# -# Version: 2.0.0 -# -# Authors: -# -# - Kevin van Zonneveld (http://kvz.io) -# - Izaak Beekman (https://izaakbeekman.com/) -# - Alexander Rathai (Alexander.Rathai@gmail.com) -# - Dr. Damian Rouson (http://www.sourceryinstitute.org/) (documentation) -# -# Licensed under MIT -# Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io) - -# The invocation of bootstrap.sh below performs the following tasks: -# (1) Import several bash3boilerplate helper functions & default settings. -# (2) Set several variables describing the current file and its usage page. -# (3) Parse the usage information (default usage file name: current file's name with -usage appended). -# (4) Parse the command line using the usage information. - -### Start of boilerplate -- do not edit this block ####################### -export OPENCOARRAYS_SRC_DIR="${OPENCOARRAYS_SRC_DIR:-${PWD%/}}" -if [[ ! -f "${OPENCOARRAYS_SRC_DIR}/src/libcaf.h" ]]; then - echo "Please run this script inside the top-level OpenCoarrays source directory or " - echo "set OPENCOARRAYS_SRC_DIR to the OpenCoarrays source directory path." - exit 1 -fi -export B3B_USE_CASE="${B3B_USE_CASE:-${OPENCOARRAYS_SRC_DIR}/prerequisites/use-case}" -if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then - echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path." - exit 2 -else - # shellcheck source=./prerequisites/use-case/bootstrap.sh - source "${B3B_USE_CASE}/bootstrap.sh" "$@" -fi -### End of boilerplate -- start user edits below ######################### +#!/bin/sh -# Set expected value of present flags that take no arguments -export __flag_present=1 +set -e # exit on error +set -o pipefail -# Set up a function to call when receiving an EXIT signal to do some cleanup. Remove if -# not needed. Other signals can be trapped too, like SIGINT and SIGTERM. -function cleanup_before_exit () { - info "Cleaning up. Done" +print_usage_info() +{ + echo "OpenCoarrays Installation Script" + echo "" + echo "USAGE:" + echo "./install.sh [--help | [--prefix=PREFIX]" + echo "" + echo " --help Display this help text" + echo " --prefix=PREFIX Install binary in 'PREFIX/bin'" + echo " --prereqs Display a list of prerequisite software." + echo " Default prefix='\$HOME/.local/bin'" + echo "" + echo "For a non-interactive build with the 'yes' utility installed, execute" + echo "yes | ./install.sh" } -trap cleanup_before_exit EXIT # The signal is specified here. Could be SIGINT, SIGTERM etc. +GCC_VERSION=11 -### Validation (decide what's required for running your script and error out) -##################################################################### - -[ -z "${LOG_LEVEL:-}" ] && emergency "Cannot continue without LOG_LEVEL. " +list_prerequisites() +{ + echo "By default, OpenCoarrays and this installer use the following prerequisite package" + echo "versions, which also indicate the versions that the installer will install if" + echo "missing and if granted permission:" + echo "" + echo " GCC $GCC_VERSION" + echo " fpm 0.5.0" + echo " pkg-config 0.29.2" + echo " realpath 9.0 (Homebrew coreutils 9.0)" + echo "" + echo "Some earlier versions will also work." +} -# shellcheck disable=SC2154 -if [[ "${arg_v}" == "${__flag_present}" || "${arg_l}" == "${__flag_present}" || ! -z "${arg_P:-${arg_U:-${arg_V:-${arg_D}}}}" ]]; then - print_debug_only=7 - if [ "$(( LOG_LEVEL < print_debug_only ))" -ne 0 ]; then - debug "Supressing info and debug messages: one of {-l, -v, -P, -U, -V, -D} present." - suppress_info_debug_messages - fi +while [ "$1" != "" ]; do + PARAM=$(echo "$1" | awk -F= '{print $1}') + VALUE=$(echo "$1" | awk -F= '{print $2}') + case $PARAM in + -h | --help) + print_usage_info + exit + ;; + --prereqs) + list_prerequisites + exit + ;; + --prefix) + PREFIX=$VALUE + ;; + *) + echo "ERROR: unknown parameter \"$PARAM\"" + usage + exit 1 + ;; + esac + shift +done + +set -u # error on use of undefined variable + +if [ -z ${MPIFC+x} ] || [ -z ${MPICC+x} ] ; then + if command -v mpifort > /dev/null 2>&1; then + MPIFC=`which mpifort` + echo "Setting MPIFC=$MPIFC" + fi + if command -v mpicc > /dev/null 2>&1; then + MPICC=`which mpicc` + echo "Setting MPICC=$MPICC" + fi fi -[ ! -z "${arg_D}" ] && [ ! -z "${arg_P:-${arg_U:-${arg_V}}}" ] && - emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected). [exit 101]" - -[ ! -z "${arg_P}" ] && [ ! -z "${arg_U:-${arg_V}}" ] && - emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected). [exit 102]" +if command -v pkg-config > /dev/null 2>&1; then + PKG_CONFIG=`which pkg-config` +fi + +if command -v realpath > /dev/null 2>&1; then + REALPATH=`which realpath` +fi -[ ! -z "${arg_U}" ] && [ ! -z "${arg_V}" ] && - emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected). [exit 103]" +if command -v fpm > /dev/null 2>&1; then + FPM=`which fpm` +fi -### Print bootstrapped magic variables to STDERR when LOG_LEVEL -### is at the default value (6) or above. -##################################################################### -# shellcheck disable=SC2154 +ask_permission_to_use_homebrew() { -info "__file: ${__file}" -info "__dir: ${__dir}" -info "__base: ${__base}" -info "__os: ${__os}" -info "__usage: ${__usage}" -info "LOG_LEVEL: ${LOG_LEVEL}" - -info "-b (--install-branch): ${arg_b}" -info "-c (--with-c): ${arg_c}" -info "-C (--with-cxx): ${arg_C}" -info "-d (--debug): ${arg_d}" -info "-D (--print-downloader): ${arg_D}" -info "-e (--verbose): ${arg_e}" -info "-f (--with-fortran): ${arg_f}" -info "-h (--help): ${arg_h}" -info "-i (--install-prefix): ${arg_i}" -info "-I (--install-version): ${arg_I}" -info "-j (--num-threads): ${arg_j}" -info "-l (--list-packages): ${arg_l}" -info "-m (--with-cmake): ${arg_m}" -info "-M (--with-mpi): ${arg_M}" -info "-n (--no-color): ${arg_n}" -info "-o (--only-download): ${arg_o}" -info "-p (--package): ${arg_p}" -info "-P (--print-path): ${arg_P}" -info "-r (--prefix-root): ${arg_r}" -info "-u (--from-url): ${arg_u}" -info "-U (--print-url): ${arg_U}" -info "-v (--version): ${arg_v}" -info "-V (--print-version): ${arg_V}" -info "-y (--yes-to-all): ${arg_y}" -info "-Z (--bootstrap): ${arg_Z}" + echo "" + echo "Either one or both of the environment variables MPIFC and MPICC are unset or" + echo "one or more of the following packages are not in the PATH: pkg-config, realpath, and fpm." + echo "If you grant permission to install prerequisites, you will be prompted before each installation." + echo "" + echo "Press 'Enter' to choose the square-bracketed default answer:" + printf "Is it ok to use Homebrew to install prerequisite packages? [yes] " } -# This file is organized into three sections: -# 1. Command-line argument and environment variable processing. -# 2. Function definitions. -# 3. Main body. -# The script depends on several external programs, including a second script that -# builds prerequisite software. Building prerequisites requires network access -# unless tar balls of the prerequisites are present. - -# TODO: -# 1. Collapse the body of the main conditional branches in the find_or_install function -# into one new function. -# 2. Verify that script-installed packages meet the minimum version number. -# 3. Add a script_transfer function to collapse the stack_pop x; stack_push z y -# pattern into one statement -# 4. Consider adding mpich and cmake to the dependency stack before passing them to -# find_or_install to make the blocks inside find_or_install more uniform. -# Alternatively, check the dependency stacks for the package before entering the -# main conditional blocks in find_or_install. -# - - -# __________ Process command-line arguments and environment variables _____________ - -this_script="$(basename "$0")" -export this_script - -export install_path=${arg_i%/} -export prefix_root="${arg_r:-}" - -export num_threads="${arg_j}" -info "num_threads=\"${arg_j}\"" - -export opencoarrays_src_dir="${OPENCOARRAYS_SRC_DIR}" -info "opencoarrays_src_dir=${OPENCOARRAYS_SRC_DIR}" - -export build_path="${opencoarrays_src_dir}"/prerequisites/builds -info "build_path=\"${opencoarrays_src_dir}\"/prerequisites/builds" - -export build_script="${opencoarrays_src_dir}"/prerequisites/build.sh -info "build_script=\"${opencoarrays_src_dir}\"/prerequisites/build.sh" - -# ___________________ Define functions for use in the Main Body ___________________ - -# Include stack management functions -#. ./prerequisites/stack.sh -# shellcheck source=./prerequisites/stack.sh -source $opencoarrays_src_dir/prerequisites/stack.sh -stack_new dependency_pkg -stack_new dependency_exe -stack_new dependency_path -stack_new script_installed - -# shellcheck source=./prerequisites/install-functions/find_or_install.sh -source $opencoarrays_src_dir/prerequisites/install-functions/find_or_install.sh - -# shellcheck source=./prerequisites/install-functions/print_header.sh -source $opencoarrays_src_dir/prerequisites/install-functions/print_header.sh - -# shellcheck source=./prerequisites/install-functions/build_opencoarrays.sh -source $opencoarrays_src_dir/prerequisites/install-functions/build_opencoarrays.sh - -# shellcheck source=./prerequisites/install-functions/report_results.sh -source $opencoarrays_src_dir/prerequisites/install-functions/report_results.sh - -# shellcheck source=./prerequisites/install-functions/install-xcode-clt.sh -source "${opencoarrays_src_dir}/prerequisites/install-functions/install-xcode-clt.sh" - -# ___________________ End of function definitions for use in the Main Body __________________ - -# ________________________________ Start of the Main Body ___________________________________ - -if [[ "${arg_v}" == "${__flag_present}" || "${arg_V}" == "opencoarrays" ]]; then +ask_permission_to_install_homebrew() +{ + echo "" + echo "Homebrew not found. Installing Homebrew requires sudo privileges." + echo "If you grant permission to install Homebrew, you may be prompted to enter your password." + echo "" + echo "Press 'Enter' to choose the square-bracketed default answer:" + printf "Is it ok to download and install Homebrew? [yes] " +} - # Print script copyright & version if invoked with -v, -V, or - # --version argument git attributes handle .VERSION, making it more - # robust, but fallback version is still manually included. Search - # for the first version string we encounter and extract it using sed: - opencoarrays_version=$(sed -n '/[0-9]\{1,\}\(\.[0-9]\{1,\}\)\{1,\}/{s/^\([^.]*\)\([0-9]\{1,\}\(\.[0-9]\{1,\}\)\{1,\}\)\(.*\)/\2/p;q;}' "${opencoarrays_src_dir%/}/.VERSION") - if [[ "${arg_v}" == "${__flag_present}" ]]; then - echo "OpenCoarrays ${opencoarrays_version}" - echo "" - echo "OpenCoarrays installer" - echo "Copyright (C) 2015-2016 Sourcery, Inc." - echo "Copyright (C) 2015-2016 Sourcery Institute" - echo "" - echo "OpenCoarrays comes with NO WARRANTY, to the extent permitted by law." - echo "You may redistribute copies of ${this_script} under the terms of the" - echo "BSD 3-Clause License. For more information about these matters, see" - echo "http://www.sourceryinstitute.org/license.html" +ask_permission_to_install_homebrew_package() +{ + echo "" + if [ ! -z ${2+x} ]; then + echo "Homebrew installs $1 collectively in one package named '$2'." echo "" - elif [[ "${arg_V}" == "opencoarrays" ]]; then - echo "${opencoarrays_version//[[:space:]]/}" fi + printf "Is it ok to use Homebrew to install $1? [yes] " +} -elif [[ ! -z "${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}" || "${arg_l}" == "${__flag_present}" ]]; then - - # Delegate to build.sh for the packages it builds - build_arg=${arg_D:-${arg_P:-${arg_U:-${arg_V:-${arg_p}}}}} - [ ! -z "${arg_D}" ] && build_flag="-D" - [ ! -z "${arg_P}" ] && build_flag="-P" - [ ! -z "${arg_U}" ] && build_flag="-U" - [ ! -z "${arg_V}" ] && build_flag="-V" - [ "${arg_l}" == "${__flag_present}" ] && build_flag="-l" - - if [[ "${arg_P}" == "opencoarrays" ]]; then - - version="$("${opencoarrays_src_dir}/install.sh" -V opencoarrays)" - echo "${install_path%/}/opencoarrays/${version}" - - else - - info "Invoking build script with the following command:" - info "\"${opencoarrays_src_dir}\"/prerequisites/build.sh \"${build_flag}\" \"${build_arg}\"" - "${opencoarrays_src_dir}"/prerequisites/build.sh "${build_flag}" "${build_arg}" +CI=${CI:-"false"} # GitHub Actions workflows set CI=true - # Add lines other packages the current script builds - if [[ "${arg_l}" == "${__flag_present}" ]]; then - echo "opencoarrays (version $("${opencoarrays_src_dir}/install.sh" -V opencoarrays))" - echo "ofp (version: ofp-sdf for OS X )" - fi +exit_if_user_declines() +{ + if [ $CI = true ]; then + echo " 'yes' assumed (GitHub Actions workflow detected)" + return fi + read answer + if [ -n "$answer" -a "$answer" != "y" -a "$answer" != "Y" -a "$answer" != "Yes" -a "$answer" != "YES" -a "$answer" != "yes" ]; then + echo "Installation declined." + case ${1:-} in + *MPI*) + echo "To use compilers other than Homebrew-installed mpifort and mpicc," + echo "please set the MPIFC and MPICC environment variables and rerun './install.sh'." ;; + *) + echo "Please ensure that $1 is installed and in your PATH and then rerun './install.sh'." ;; + esac + echo "OpenCoarrays was not installed." + exit 1 + fi +} -elif [[ "${arg_p:-}" == "opencoarrays" ]]; then +DEPENDENCIES_DIR="build/dependencies" +if [ ! -d $DEPENDENCIES_DIR ]; then + mkdir -p $DEPENDENCIES_DIR +fi - if [[ "${arg_o}" == "${__flag_present}" ]]; then +if [ -z ${MPIFC+x} ] || [ -z ${MPICC+x} ] || [ -z ${PKG_CONFIG+x} ] || [ -z ${REALPATH+x} ] || [ -z ${FPM+x} ] ; then - # Download all prerequisites and exit - info "source ${OPENCOARRAYS_SRC_DIR}/prerequisites/install-functions/download-all-prerequisites.sh" - source "${OPENCOARRAYS_SRC_DIR}/prerequisites/install-functions/download-all-prerequisites.sh" - info "download_all_prerequisites" - download_all_prerequisites + ask_permission_to_use_homebrew + exit_if_user_declines "brew" - else + BREW="brew" - # Install Xcode command line tools (CLT) if on macOS and if needed - maybe_install_xcodeCLT - # Install OpenCoarrays + if ! command -v $BREW > /dev/null 2>&1; then - cd prerequisites || exit 1 - installation_record=install-opencoarrays.log - # shellcheck source=./prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh - source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh" - version="$("${opencoarrays_src_dir}/install.sh" -V opencoarrays)" + ask_permission_to_install_homebrew + exit_if_user_declines "brew" - if [[ -z "${prefix_root:-}" ]]; then - set_SUDO_if_needed_to_write_to_directory "${install_path}" - else - set_SUDO_if_needed_to_write_to_directory "${prefix_root}" + if ! command -v curl > /dev/null 2>&1; then + echo "No download mechanism found. Please install curl and rerun ./install.sh" + exit 1 fi - if grep -s -q Microsoft /proc/version ; then - info "Windows Subsystem for Linux detected. Invoking windows-install.sh with the following command:" - info "\"${opencoarrays_src_dir}\"/prerequisites/install-functions/windows-install.sh \"$@\"" - "${opencoarrays_src_dir}"/prerequisites/install-functions/windows-install.sh "$@" + curl -L https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh -o $DEPENDENCIES_DIR/install-homebrew.sh --create-dirs + chmod u+x $DEPENDENCIES_DIR/install-homebrew.sh + + if [ -p /dev/stdin ]; then + echo "" + echo "Pipe detected. Installing Homebrew requires sudo privileges, which most likely will" + echo "not work if you are installing non-interactively, e.g., via 'yes | ./install.sh'." + echo "To install OpenCoarrays non-interactiely, please rerun the OpenCoarrays installer after" + echo "executing the following command to install Homebrew:" + echo "\"./$DEPENDENCIES_DIR/install-homebrew.sh\"" + exit 1 else - # Using process substitution "> >(...) -" instead of piping to tee via "2>&1 |" ensures that - # report_results gets the FC value set in build_opencoarrays - # Source: http://stackoverflow.com/questions/8221227/bash-variable-losing-its-value-strange - build_opencoarrays > >( tee ../"${installation_record}" ) - - report_results 2>&1 | tee -a ../"${installation_record}" + ./$DEPENDENCIES_DIR/install-homebrew.sh + rm $DEPENDENCIES_DIR/install-homebrew.sh + fi + + if [ $(uname) = "Linux" ]; then + BREW=/home/linuxbrew/.linuxbrew/bin/brew + eval "$($BREW shellenv)" fi fi -elif [[ "${arg_p:-}" == "ofp" ]]; then + if [ -z ${MPIFC+x} ] || [ -z ${MPICC+x} ]; then + ask_permission_to_install_homebrew_package "'mpifort' and 'mpicc'" "open-mpi" + exit_if_user_declines "mpifort and mpicc" + "$BREW" install open-mpi + fi + MPIFC=`which mpifort` + MPICC=`which mpicc` + + if [ -z ${PKG_CONFIG+x} ]; then + ask_permission_to_install_homebrew_package "'pkg-config'" + exit_if_user_declines "pkg-config" + "$BREW" install pkg-config + fi + PKG_CONFIG=`which pkg-config` - # Install Xcode command line tools (CLT) if on macOS and if needed - maybe_install_xcodeCLT + if [ -z ${REALPATH+x} ] ; then + ask_permission_to_install_homebrew_package "'realpath'" "coreutils" + exit_if_user_declines "realpath" + "$BREW" install coreutils + fi + REALPATH=`which realpath` + + if [ -z ${FPM+x} ] ; then + ask_permission_to_install_homebrew_package "'fpm'" + exit_if_user_declines "fpm" + "$BREW" tap awvwgk/fpm + "$BREW" install fpm + fi + FPM=`which fpm` +fi - info "Invoking Open Fortran Parser build script with the following command:" - info "\"${opencoarrays_src_dir}\"/prerequisites/install-ofp.sh" - "${opencoarrays_src_dir}"/prerequisites/install-ofp.sh +PREFIX=`$REALPATH ${PREFIX:-"${HOME}/.local"}` +echo "PREFIX=$PREFIX" + +PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig" +mkdir -p "$PKG_CONFIG_PATH" +echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" + +CAF_VERSION=$(sed -n '/[0-9]\{1,\}\(\.[0-9]\{1,\}\)\{1,\}/{s/^\([^.]*\)\([0-9]\{1,\}\(\.[0-9]\{1,\}\)\{1,\}\)\(.*\)/\2/p;q;}' .VERSION) +Fortran_COMPILER="$(which $($MPIFC --showme:command))" +CAF_MPI_Fortran_LINK_FLAGS="$($MPIFC --showme:link)" +CAF_MPI_Fortran_COMPILE_FLAGS="" +CAF_MPI_C_COMPILE_FLAGS="$($MPICC --showme:link)" +CAF_LIBS="lib/libopencoarrays.a" + +MPIFC_LIBS="$($MPIFC --showme:libs)" +MPIFC_LIBS="$(echo -L${MPIFC_LIBS} | sed -n -e 's/\ / -l/g')" + +MPIFC_LIB_DIRS="$($MPIFC --showme:libdirs)" +MPIFC_LIB_DIRS="$(echo -L${MPIFC_LIB_DIRS} | sed -n -e 's/\ / -L/g')" + +OPENCOARRAYS_LIBS="-L$PREFIX/lib/ -lopencoarrays" + +OPENCOARRAYS_PC="$PKG_CONFIG_PATH/opencoarrays.pc" +echo "OPENCOARRAYS_FC=$MPIFC" > $OPENCOARRAYS_PC +echo "OPENCOARRAYS_CC=$MPICC" >> $OPENCOARRAYS_PC +echo "OPENCOARRAYS_CFLAGS='-DPREFIX_NAME=_gfortran_caf_ -DGCC_GE_7 -DGCC_GE_8'" >> $OPENCOARRAYS_PC +echo "OPENCOARRAYS_LIBS=$OPENCOARRAYS_LIBS" >> $OPENCOARRAYS_PC +echo "" >> $OPENCOARRAYS_PC +echo "Name: OpenCoarrays" >> $OPENCOARRAYS_PC +echo "Description: Coarray Fortran parallel runtime library" >> $OPENCOARRAYS_PC +echo "URL: https://github.com/sourceryinstitute/opencoarrays" >> $OPENCOARRAYS_PC +echo "Version: $CAF_VERSION" >> $OPENCOARRAYS_PC +echo "Libs: ${OPENCOARRAYS_LIBS}" >> $OPENCOARRAYS_PC + +exit_if_pkg_config_pc_file_missing() +{ + export PKG_CONFIG_PATH + if ! $PKG_CONFIG $1 ; then + echo "$1.pc pkg-config file not found in $PKG_CONFIG_PATH" + exit 1 + fi +} +exit_if_pkg_config_pc_file_missing "opencoarrays" + +build_script_dir="build/script-templates" +mkdir -p $build_script_dir + +CAF_MPI_LIBS="$MPIFC_LIB_DIRS" + +cp src/script-templates/caf.in $build_script_dir/caf.in +sed -i'' -e "s/@CAF_VERSION@/$CAF_VERSION/g" $build_script_dir/caf.in +sed -i'' -e "s:@Fortran_COMPILER@:$Fortran_COMPILER:g" $build_script_dir/caf.in +sed -i'' -e "s:@CAF_MPI_Fortran_LINK_FLAGS@:$CAF_MPI_Fortran_LINK_FLAGS:g" $build_script_dir/caf.in +sed -i'' -e "s:@CAF_MPI_Fortran_COMPILE_FLAGS@:$CAF_MPI_Fortran_COMPILE_FLAGS:g" $build_script_dir/caf.in +sed -i'' -e "s:@CAF_LIBS@:$CAF_LIBS:g" $build_script_dir/caf.in +sed -i'' -e "s:@CAF_MPI_LIBS@:$CAF_MPI_LIBS:g" $build_script_dir/caf.in +cp build/script-templates/caf.in "$PREFIX"/bin/caf + +MPIEXEC="$(which mpiexec)" +HAVE_FAILED_IMG=false +MPIEXEC_NUMPROC_FLAG="-n" +MPIEXEC_PREFLAGS="" +MPIEXEC_POSTFLAGS="" + +cp src/script-templates/cafrun.in $build_script_dir/cafrun.in +sed -i'' -e "s/@CAF_VERSION@/$CAF_VERSION/g" $build_script_dir/cafrun.in +sed -i'' -e "s:@MPIEXEC@:$MPIEXEC:g" $build_script_dir/cafrun.in +sed -i'' -e "s/@MPIEXEC_NUMPROC_FLAG@/$MPIEXEC_NUMPROC_FLAG/g" $build_script_dir/cafrun.in +sed -i'' -e "s/@MPIEXEC_PREFLAGS@/$MPIEXEC_PREFLAGS/g" $build_script_dir/cafrun.in +sed -i'' -e "s/@MPIEXEC_POSTFLAGS@/$MPIEXEC_POSTFLAGS/g" $build_script_dir/cafrun.in +sed -i'' -e "s/@HAVE_FAILED_IMG@/$HAVE_FAILED_IMG/g" $build_script_dir/cafrun.in +cp $build_script_dir/cafrun.in "$PREFIX"/bin/cafrun + +if [ ! -x "$PREFIX"/bin/caf ]; then + echo "caf not installed in '$PREFIX'/bin" + exit 1 +fi -elif [[ ! -z "${arg_p:-}" ]]; then +if [ ! -x "$PREFIX"/bin/cafrun ]; then + echo "cafrun not installed in '$PREFIX'/bin" + exit 1 +fi - # Install Xcode command line tools (CLT) if on macOS and if needed - maybe_install_xcodeCLT +cp src/script-templates/install.rsp-template $build_script_dir +sed -i'' -e "s:@MPIFC@:'$MPIFC':g" $build_script_dir/install.rsp-template +sed -i'' -e "s:@MPICC@:'$MPICC':g" $build_script_dir/install.rsp-template +mv $build_script_dir/install.rsp-template build/install.rsp +fpm @build/install - info "Invoking build script with the following command:" - info "\"${opencoarrays_src_dir}\"/prerequisites/build.sh ${*:-}" - "${opencoarrays_src_dir}"/prerequisites/build.sh "${@:-}" +cp "src/script-templates/test.rsp-template" $build_script_dir +sed -i'' -e "s:@CAF@:'$PREFIX'/bin/caf:g" "$build_script_dir/test.rsp-template" +sed -i'' -e "s:@MPICC@:'$MPICC':g" "$build_script_dir/test.rsp-template" +mv "$build_script_dir/test.rsp-template" "build/test.rsp" +if [ ! -f "$PREFIX"/lib/libopencoarrays.a ]; then + echo "libopencoarrays.a not installed in '$PREFIX'/lib" + exit 1 fi -# ____________________________________ End of Main Body ____________________________________________ + +echo "" +echo "________________ OpenCoarrays has been installed ________________" +echo "" +echo "OpenCoarrays users: compile and launch parallel Fortran programs the installed scripts:" +echo "" +echo "$PREFIX/bin/caf example/hello.f90" +echo "$PREFIX/bin/cafrun -n 4 ./a.out" +echo "" +echo "The following command should work now to reinstall or test OpenCoarrays, respectively:" +echo "" +echo "fpm @build/install" +echo "fpm @build/test -- -d -v" +echo "" +echo "where the '-- -d -v' arguments instruct the Garden unit testing framework to print" +echo "verbose debugging information." diff --git a/install.sh-usage b/install.sh-usage deleted file mode 100644 index 937c4ef6a..000000000 --- a/install.sh-usage +++ /dev/null @@ -1,25 +0,0 @@ - -b --install-branch [arg] Install the specified repository development branch (Examples: -b master). - -c --with-c [arg] Use specified C compiler (Example: -c /usr/local/bin/gcc). - -C --with-cxx [arg] Use specified C++ compiler (Example: -C /usr/local/bin/g++). - -d --debug Enable debug mode. - -D --print-downloader [arg] Print download program for package specified in argument (Example: -D gcc). - -e --verbose Enable verbose mode, print script as it is executed. - -f --with-fortran [arg] Use specified Fortran compiler (Example: -f /usr/local/bin/gfortran). - -h --help Print this page. - -i --install-prefix [arg] Install package in specified path. Default="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations/${package_name:-}/${version_to_build:-}" - -I --install-version [arg] Install package version (Example: -I 7.2.0). - -j --num-threads [arg] Number of threads to use when invoking make (Example: -j 8). Default="4" - -l --list-packages Print packages this script can install. - -m --with-cmake [arg] Use specified CMake installation (Example: -m /usr/local/bin/cmake). - -M --with-mpi [arg] Use specified MPI installation (Examples: -M /usr/local/ or -m /opt/mpich-3.2/). - -n --no-color Disable color output. - -o --only-download Download (without building) the source for the package specified by -p or --package. - -p --package [arg] Install specified package (Examples: -p gcc or -p mpich). Default="opencoarrays" - -P --print-path [arg] Print installation directory for specified package (Example: -P gcc). - -r --prefix-root [arg] Installation path to which package name/version will be appended. (Example: -r /opt). - -u --from-url [arg] Specify a URL to use for downloading a package (Example: -u https://github.com/sourceryinstitute/gcc/archive/teams-rc3.tar.gz). - -U --print-url [arg] Print download location for specified package (Example: -U gcc). - -v --version Print OpenCoarrays version number. - -V --print-version [arg] Print version number for specified package (Example: -V mpich). - -y --yes-to-all Build non-interactively by assuming affirmative user responses. - -Z --bootstrap Enable bootstrap build for robustness when building the required GCC version with an old GCC version. diff --git a/prerequisites/acceptable_compiler.f90 b/prerequisites/acceptable_compiler.f90 deleted file mode 100644 index 879f7c2f3..000000000 --- a/prerequisites/acceptable_compiler.f90 +++ /dev/null @@ -1,153 +0,0 @@ -! -! acceptable_compiler -! -! -- Report whether the compiler version equals or exceeds the first -! OpenCoarrays-aware version -! -! OpenCoarrays is distributed under the OSI-approved BSD 3-clause License: -! Copyright (c) 2015, 2016, Sourcery, Inc. -! Copyright (c) 2015, 2016, Sourcery Institute -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, -! are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this -! list of conditions and the following disclaimer. -! 2. Redistributions in binary form must reproduce the above copyright notice, this -! list of conditions and the following disclaimer in the documentation and/or -! other materials provided with the distribution. -! 3. Neither the names of the copyright holders nor the names of their contributors -! may be used to endorse or promote products derived from this software without -! specific prior written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -! ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -! IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -! INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -! NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -! POSSIBILITY OF SUCH DAMAGE. - -program main - !! input: acceptable compiler version in the form major.minor.patch - !! output: - !! .true. if compiler version >= acceptable version - !! .false. otherwise - use iso_fortran_env, only : compiler_version - implicit none - - integer, parameter :: first_argument=1, max_version_length=len('999.999.999') - integer stat - character(len=max_version_length) acceptable_version - - call get_command_argument(first_argument,acceptable_version,status=stat) - call validate_command_line( stat ) - - print *, meets_minimum( acceptable_version ) - -contains - - pure function meets_minimum( required_version ) result( acceptable) - character(len=*), intent(in) :: required_version - logical acceptable - - acceptable = .false. ! default result - - associate( actual_version => compiler_version() ) - associate(major_version=>major(actual_version), acceptable_major=>major(required_version)) - if (major_version < acceptable_major) return - if (major_version > acceptable_major) then - acceptable = .true. - return - end if - associate(minor_version=>minor(actual_version), acceptable_minor=>minor(required_version)) - if (minor_version < acceptable_minor) return - if (minor_version > acceptable_minor) then - acceptable = .true. - return - end if - associate(patch_version=>patch(actual_version), acceptable_patch=>patch(required_version)) - if (patch_version < acceptable_patch) return - acceptable = .true. - end associate - end associate - end associate - end associate - - end function - - pure subroutine validate_command_line( command_line_status ) - integer, intent(in) :: command_line_status - select case(command_line_status) - case(-1) - error stop "acceptable_compiler.f90: insufficient string length in attempt to read command argument" - case(0) - ! successful command argument read - case(1:) - error stop "acceptable_compiler.f90: no version-number supplied" - case default - error stop "invalid status" - end select - end subroutine - - pure function major(version_string) result(major_value) - character(len=*), intent(in) :: version_string - integer major_value - character(len=:), allocatable :: leading_digits - - associate( first_dot => scan(version_string, '.') ) - associate( first_digit => scan( version_string(1:first_dot-1), '0123456789' ) ) - leading_digits = version_string( first_digit : first_dot-1 ) - read(leading_digits,*) major_value - end associate - end associate - - end function - - pure function minor(version_string) result(minor_value) - character(len=*), intent(in) :: version_string - integer minor_value - character(len=:), allocatable :: middle_digits - - associate( first_dot => scan(version_string, '.') ) - associate( second_dot => first_dot + scan(version_string(first_dot+1:), '.') ) - middle_digits = version_string( first_dot+1 : second_dot-1 ) - read(middle_digits,*) minor_value - end associate - end associate - - end function - - pure function patch(version_string) result(patch_value) - use iso_fortran_env, only : iostat_end - character(len=*), intent(in) :: version_string - integer patch_value, io_stat - character(len=:), allocatable :: trailing_digits - - associate( first_dot => scan(version_string, '.') ) - associate( second_dot => first_dot + scan(version_string(first_dot+1:), '.') ) - associate( next_non_digit=> second_dot + next_printable_non_digit(version_string(second_dot+1:)) ) - trailing_digits = version_string( second_dot+1 : next_non_digit-1 ) - read(trailing_digits, * , iostat=io_stat) patch_value - end associate - end associate - end associate - - end function - - pure function next_printable_non_digit( string ) result(location) - character(len=*), intent(in) :: string - integer i, location - integer, parameter :: ASCII_non_digit(*)=[(i,i=32,47),(i,i=58,126)] - character(len=1), parameter :: non_digit(*)=[( char(ASCII_non_digit(i)) , i=1, size(ASCII_non_digit) )] - character(len=size(non_digit)) non_digit_string - write(non_digit_string,'(85a)') non_digit - location = scan(string,non_digit_string) - if (location==0) location=len(string)+1 - end function - -end program diff --git a/prerequisites/build-functions/build_and_install.sh b/prerequisites/build-functions/build_and_install.sh deleted file mode 100644 index e995f4b0b..000000000 --- a/prerequisites/build-functions/build_and_install.sh +++ /dev/null @@ -1,153 +0,0 @@ -# shellcheck shell=bash -# Make the build directory, configure, and build -# shellcheck disable=SC2154 - -# shellcheck source=prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh -source "${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh" - -function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } - -build_and_install() -{ - num_threads=${arg_j} - build_path="${OPENCOARRAYS_SRC_DIR}/prerequisites/builds/${package_to_build}-${version_to_build}" - - info "Building ${package_to_build} ${version_to_build}" - info "Build path: ${build_path}" - info "Installation path: ${install_path}" - - set_SUDO_if_needed_to_write_to_directory "${build_path}" - set_SUDO_if_needed_to_write_to_directory "${install_path}" - if [[ -d "${build_path}" ]]; then - rm -rf "${build_path}" - fi - mkdir -p "${build_path}" - info "pushd ${build_path}" - pushd "${build_path}" || emergency "build_and_install.sh: pushd failed" - - if [[ "${package_to_build}" != "gcc" ]]; then - - if [[ "${package_to_build}" == "mpich" ]]; then - if [[ "${version_to_build}" == "3.2" ]]; then - info "Patching MPICH 3.2 on Mac OS due to segfault bug (see http://lists.mpich.org/pipermail/discuss/2016-May/004764.html)." - sed 's/} MPID_Request ATTRIBUTE((__aligned__(32)));/} ATTRIBUTE((__aligned__(32))) MPID_Request;/g' \ - "${download_path}/${package_source_directory}/src/include/mpiimpl.h" > "${download_path}/${package_source_directory}/src/include/mpiimpl.h.patched" - cp "${download_path}/${package_source_directory}/src/include/mpiimpl.h.patched" "${download_path}/${package_source_directory}/src/include/mpiimpl.h" - fi - - FC_version=$($FC --version) - text_before_dot="${FC_version%%.*}" # grab text before first dot - major_version="${text_before_dot##* }" # grab text after final space - if (( ${major_version} >= 10 )); then - export FFLAGS="-w -fallow-argument-mismatch" - fi - fi - - if [[ "${package_to_build}" == "cmake" && $(uname) == "Linux" ]]; then - - export cmake_binary_installer="${download_path}/cmake-${version_to_build}-Linux-x86_64.sh" - ${SUDO:-} mkdir -p "$install_path" - chmod u+x "${cmake_binary_installer}" - if [[ -n "${SUDO:-}" ]]; then - info "You do not have write permissions to the installation path ${install_path}" - info "If you have administrative privileges, enter your password to install ${package_to_build}" - fi - info "Installing Cmake with the following command: " - info "${SUDO:-} \"${cmake_binary_installer}\" --prefix=\"$install_path\" --exclude-subdir" - ${SUDO:-} "${cmake_binary_installer}" --prefix="$install_path" --exclude-subdir - - else # build from source - - info "Configuring ${package_to_build} ${version_to_build} with the following command:" - info "FFLAGS=${FFLAGS:-} FC=\"${FC:-'gfortran'}\" CC=\"${CC:-'gcc'}\" CXX=\"${CXX:-'g++'}\" \"${download_path}/${package_source_directory}\"/configure --prefix=\"${install_path}\"" - FFLAGS=${FFLAGS:-} FC="${FC:-'gfortran'}" CC="${CC:-'gcc'}" CXX="${CXX:-'g++'}" "${download_path}/${package_source_directory}"/configure --prefix="${install_path}" - info "Building with the following command:" - info "FC=\"${FC:-'gfortran'}\" CC=\"${CC:-'gcc'}\" CXX=\"${CXX:-'g++'}\" make -j\"${num_threads}\"" - FC="${FC:-'gfortran'}" CC="${CC:-'gcc'}" CXX="${CXX:-'g++'}" make "-j${num_threads}" - info "Installing ${package_to_build} in ${install_path}" - if [[ -n "${SUDO:-}" ]]; then - info "You do not have write permissions to the installation path ${install_path}" - info "If you have administrative privileges, enter your password to install ${package_to_build}" - fi - info "Installing with the following command: ${SUDO:-} make install" - ${SUDO:-} make install - - fi - - elif [[ ${package_to_build} == "gcc" ]]; then - - # Warn about header prerequisite on macOS Mojave or subsequent versions - if [[ $(uname) == "Darwin" ]]; then - export kernel=$(uname -r) - export Mojave="18.0.0" - export Catalina="19.0.0" - if [ $(version $kernel) -ge $(version $Mojave) ]; then - if [ $(version $kernel) -ge $(version $Catalina) ]; then - export with_sysroot="--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" - else - info "" - info "______________________________________________________________________________" - info "Detected Darwin $kernel (Mojave). If $package_to_build build fails due to a" - info "missing header (*.h) file, please try something like the following bash command:" - info "open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg" - info "Follow the prompts to install the missing headers. Then restart this $this_script." - info "See https://bit.ly/build-gcc-on-mojave for more details." - if [[ "${arg_y}" == "${__flag_present}" ]]; then - info "-y or --yes-to-all flag present. Proceeding with non-interactive build." - else - info "Would you like to proceed anyway? (Y/n)" - read -r proceed - if [[ "${proceed}" == "n" || "${proceed}" == "N" || "${proceed}" == "no" ]]; then - info "n" - emergency "Aborting. [exit 80]" - else - info "y" - fi - fi - fi - fi - fi - - info "pushd ${download_path}/${package_source_directory} " - pushd "${download_path}/${package_source_directory}" || emergency "build_and_install.sh: pushd failed" - - # Patch gfortran if necessary - export patches_dir="${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/patches/${package_to_build}/${version_to_build}" - if [[ -d "${patches_dir:-}" ]]; then - for patch in "${patches_dir%/}"/*.diff ; do - info "Applying patch ${patch##*/} to $package_to_build ${version_to_build}." - patch -p1 < "$patch" - done - fi - - # Use GCC's contrib/download_prerequisites script after modifying it, if necessary, to use the - # the preferred download mechanism set in prerequisites/build-functions/set_or_print_downloader.sh - - # Switch download mechanism if wget is not available - edit_GCC_download_prereqs_file_if_necessary - - # Download GCC prerequisities - "${PWD}"/contrib/download_prerequisites - - info "popd" - popd || emergency "build_and_install.sh: popd failed" - info "Configuring gcc/g++/gfortran builds with the following command:" - info "${download_path}/${package_source_directory}/configure --prefix=${install_path} --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror ${bootstrap_configure} ${with_sysroot:-}" - "${download_path}/${package_source_directory}/configure" --prefix="${install_path}" --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror "${bootstrap_configure}" "${with_sysroot:-}" - info "Building with the following command: make -j ${num_threads} ${bootstrap_build}" - make -j ${num_threads} ${bootstrap_build:-} - if [[ -n "${SUDO:-}" ]]; then - info "You do not have write permissions to the installation path ${install_path}" - info "If you have administrative privileges, enter your password to install ${package_to_build}" - fi - info "Installing with the following command: ${SUDO:-} make install" - ${SUDO:-} make install - - else - emergency "This branch should never be reached." - fi # end if [[ "${package_to_build}" != "gcc" && "${package_to_build}" != "cmake" ]]; then - - - info "popd" - popd || emergency "build_and_install.sh: popd failed" -} diff --git a/prerequisites/build-functions/download_if_necessary.sh b/prerequisites/build-functions/download_if_necessary.sh deleted file mode 100644 index 254ce64e6..000000000 --- a/prerequisites/build-functions/download_if_necessary.sh +++ /dev/null @@ -1,113 +0,0 @@ -# shellcheck shell=bash disable=SC2148 -# shellcheck source=./ftp_url.sh -source "${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp_url.sh" -# shellcheck source=./set_SUDO_if_needed_to_write_to_directory.sh -source "${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh" - -# Download package if the tar ball is not already in the present working directory -# shellcheck disable=SC2154 -download_if_necessary() -{ - download_path="${OPENCOARRAYS_SRC_DIR}/prerequisites/downloads" - set_SUDO_if_needed_to_write_to_directory "${download_path}" - - # We set args regardless of whether this function performs a download because - # GCC builds will need this to modify GCC's contrib/download_prerequisites script - - case "${fetch}" in - "wget" ) - args=("--no-check-certificate") - ;; - "ftp_url" ) - args=("-n") - ;; - "git" ) - args=("clone" "-b" "${arg_b}") - ;; - "curl" ) - first_three_characters=$(echo "${package_url}" | cut -c1-3) - case "${first_three_characters}" in - "ftp" ) - args=("-LO" "-u" "anonymous: ") - ;; - "htt" ) - args=("-LO") - ;; - *) - emergency "download_if_necessary.sh: Unrecognized URL." - ;; - esac - ;; - *) - emergency "download_if_necessary.sh: Unrecognized \${fetch}=${fetch}." - ;; - esac - - case "${gcc_prereqs_fetch}" in - "wget" ) - gcc_prereqs_fetch_args=("--no-check-certificate") - ;; - "ftp_url" ) - gcc_prereqs_fetch_args=("-n") - ;; - "curl" ) - gcc_prereqs_fetch_args=("-LO" "-u" "anonymous: ") - ;; - *) - emergency "download_if_necessary.sh: Unrecognized \${gcc_prereqs_fetch}=${gcc_prereqs_fetch}." - ;; - esac - - if [[ -f "${download_path}/${url_tail}" || -d "${download_path}/${url_tail}" ]]; then - info "Found '${url_tail##*branches/}' in ${download_path}." - info "If it resulted from an incomplete download, building ${package_name} could fail." - if [[ "${arg_y}" == "${__flag_present}" ]]; then - info "-y or --yes-to-all flag present. Proceeding with non-interactive build." - else - info "Would you like to proceed anyway? (Y/n)" - read -r proceed - if [[ "${proceed}" == "n" || "${proceed}" == "N" || "${proceed}" == "no" ]]; then - info "n" - info "Please remove ${url_tail##*branches/} and restart the installation to to ensure a fresh download." 1>&2 - emergency "Aborting. [exit 80]" - else - info "y" - fi - fi - elif ! type "${fetch}" &> /dev/null; then - # The download mechanism is missing - info "The default download mechanism for ${package_name} is ${fetch}." - info "Please either ensure that ${fetch} is installed and in your PATH" - info "or download the ${package_name} source from " - info "${package_url}" - info "Place the downloaded file in ${download_path} and restart this script." - emergency "Aborting [exit 90]" - else - - if [[ "${fetch}" == "git" ]]; then - package_source_directory="${package_name}" - else - package_source_directory="${package_name}-${version_to_build}" - fi - info "Downloading ${package_name} ${version_to_build-} to the following location:" - info "${download_path}/${package_source_directory}" - info "Download command: \"${fetch}\" ${args[@]:-} ${package_url}" - info "Depending on the file size and network bandwidth, this could take several minutes or longer." - pushd "${download_path}" - "${fetch}" ${args[@]:-} "${package_url}" - popd - if [[ "${fetch}" == "git" ]]; then - search_path="${download_path}/${package_name}" - else - search_path="${download_path}/${url_tail}" - fi - if [[ -f "${search_path}" || -d "${search_path}" ]]; then - info "Download succeeded. The ${package_name} source is in the following location:" - info "${search_path}" - else - info "Download failed. The ${package_name} source is not in the following, expected location:" - info "${search_path}" - emergency "Aborting. [exit 110]" - fi - fi -} diff --git a/prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh b/prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh deleted file mode 100644 index 5b4a6628a..000000000 --- a/prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh +++ /dev/null @@ -1,44 +0,0 @@ -# shellcheck disable=SC2154 -replace_wget() -{ - # Define a file extension for the download_prerequisites backup - backup_extension=".original" - backup_file="${download_prereqs_file}${backup_extension}" - if [[ -f ${backup_file} ]]; then - # Prevent overwriting an existing backup: - backup_extension="" - fi - - if [[ "${gcc_prereqs_fetch}" == "ftp_url" ]]; then - # Insert a new line after line 2 to include ftp_url.sh as a download option - sed -i${backup_extension} -e '2 a\'$'\n'". ${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp_url.sh"$'\n' "${download_prereqs_file}" - fi - - arg_string="${gcc_prereqs_fetch_args[*]:-}" - - info "Using the following command to replace wget in the GCC download_prerequisites file:" - info "sed -i${backup_extension} s/\"${wget_command}\"/\"${gcc_prereqs_fetch} ${arg_string} \"/ \"${download_prereqs_file}\"" - if [[ "${__operating_system}" == "Linux" ]]; then - sed -i"${backup_extension}" s/wget/"${gcc_prereqs_fetch} ${arg_string} "/ "${download_prereqs_file}" - else - sed -i "${backup_extension}" s/wget/"${gcc_prereqs_fetch} ${arg_string} "/ "${download_prereqs_file}" - fi -} - -edit_GCC_download_prereqs_file_if_necessary() -{ - __operating_system=$(uname) - download_prereqs_file="${PWD}/contrib/download_prerequisites" - - # Grab the line with the first occurence of 'wget' - wget_line=$(grep wget "${download_prereqs_file}" | head -1) || true - wget_command="${wget_line%%ftp*}" # grab everything before ftp - - # Check for wget format used before GCC 7 - if [[ ! -z "${wget_command}" ]]; then - # Check whether wget is available on this system - if ! type wget &> /dev/null; then - replace_wget - fi - fi -} diff --git a/prerequisites/build-functions/ftp_url.sh b/prerequisites/build-functions/ftp_url.sh deleted file mode 100644 index 8b15b08ed..000000000 --- a/prerequisites/build-functions/ftp_url.sh +++ /dev/null @@ -1,46 +0,0 @@ -#! /bin/sh -# Download a file from an anonymous ftp site -# -# Usage: -# ftp_url ftp://:// -# -# Example: -# ftp_url -n ftp://ftp.gnu.org:/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.bz2 -ftp_url() -{ - ftp_mode="${1}" - url="${2}" - - if [ "${ftp_mode}" != "-n" ]; then - echo "Unexpected ftp mode received by ftp_url.sh: ${ftp_mode}" - fi - - protocol="${url%%:*}" # grab text_before_first_colon - if [ "${protocol}" != "ftp" ]; then - echo "URL with unexpected protocol received by ftp_url.sh: ${text_before_first_colon}" - fi - - text_after_double_slash="${url##*//}" - FTP_SERVER="${text_after_double_slash%%/*}" # grab remaining text before first slash - FILE_NAME="${url##*/}" # grab text after final slash - - text_after_final_colon="${url##*:}" - FILE_PATH="${text_after_final_colon#*//}" - FILE_PATH="${FILE_PATH#*/}" - FILE_PATH="${FILE_PATH%/*}" - - USERNAME=anonymous - PASSWORD="noone@nowhere.com" - echo "starting anonymous download: ${protocol} ${ftp_mode} ${FTP_SERVER};... cd ${FILE_PATH}; ...; get ${FILE_NAME}" - -ftp "${ftp_mode}" "${FTP_SERVER}" <u.ar.codimen == 0 && rref->u.ar.codimen == 0) -+ dependency. */ -+ if (fin_dep < GFC_DEP_BACKWARD) - return 0; - - /* Keep checking. We only have a dependency if -diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c -index 00edd447bb2..87b3ca72c05 100644 ---- a/gcc/fortran/trans-intrinsic.c -+++ b/gcc/fortran/trans-intrinsic.c -@@ -1860,7 +1860,7 @@ conv_caf_send (gfc_code *code) { - - lhs_expr = code->ext.actual->expr; - rhs_expr = code->ext.actual->next->expr; -- may_require_tmp = gfc_check_dependency (lhs_expr, rhs_expr, false) == 0 -+ may_require_tmp = gfc_check_dependency (lhs_expr, rhs_expr, true) == 0 - ? boolean_false_node : boolean_true_node; - gfc_init_block (&block); - diff --git a/prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh b/prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh deleted file mode 100644 index 52182113a..000000000 --- a/prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh +++ /dev/null @@ -1,34 +0,0 @@ -# Define the sudo command to be used if the installation path requires administrative permissions -set_SUDO_if_needed_to_write_to_directory() -{ - if [[ $# != "1" ]]; then - emergency "set_SUDO_if_needed_to_write_to_directory takes exactly one argument" - else - directory_to_create=$1 - fi - if [[ -z "${LD_LIBRARY_PATH:-}" ]]; then - info "\${LD_LIBRARY_PATH} is empty. Try setting it if the compiler encounters linking problems." - fi - SUDO_COMMAND="sudo env LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-} PATH=${PATH:-}" - info "Checking whether the directory ${directory_to_create} exists... " - if [[ -d "${directory_to_create}" ]]; then - info "yes" - info "Checking whether I have write permissions to ${directory_to_create} ... " - if [[ -w "${directory_to_create}" ]]; then - info "yes" - else - info "no" - SUDO="${SUDO_COMMAND}" - fi - else - info "no" - info "Checking whether I can create ${directory_to_create} ... " - if mkdir -p "${directory_to_create}" >& /dev/null; then - info "yes." - else - info "no." - # shellcheck disable=SC2034 - SUDO="${SUDO_COMMAND}" - fi - fi -} diff --git a/prerequisites/build-functions/set_compilers.sh b/prerequisites/build-functions/set_compilers.sh deleted file mode 100644 index 642e1f4a3..000000000 --- a/prerequisites/build-functions/set_compilers.sh +++ /dev/null @@ -1,42 +0,0 @@ -# Set CC, CXX, and FC -# shellcheck disable=SC2154 -set_compilers() -{ - # If FC is already set, use the set value. - # Else if FC is empty, use the value specified via the -f or --with-fortran command-line arguments. - # Else use the default specifed in ../build.sh-usage. - FC=${FC:-${arg_f}} - info "Fortran compiler: ${FC}" - - if [[ $(uname) == "Darwin" && "${package_to_build}" == "cmake" ]]; then - if [[ -x "/usr/bin/gcc" ]]; then - [ ! -z "${CC:-}" ] && info "Overriding CC: cmake build requires Apple LLVM gcc, which XCode command-line tools puts in /usr/bin" - CC=/usr/bin/gcc - else - info "OS X detected. Please install XCode command-line tools and " - emergency "ensure that /usr/bin/gcc exists and is executable. Aborting." - fi - else - # If CC is already set, use the set value. - # Else if CC is empty, use the value specified via the -c or --with-c command-line arguments. - # Else use the default specifed in ../build.sh-usage. - CC=${CC:-${arg_c}} - fi - info "C compiler: ${CC}" - - if [[ $(uname) == "Darwin" && ${package_to_build} == "cmake" ]]; then - if [[ -x "/usr/bin/g++" ]]; then - [ ! -z "${CXX:-}" ] && info "Overriding CXX: cmake build requires Apple LLVM g++, which XCode command-line tools puts in /usr/bin" - CXX=/usr/bin/g++ - else - info "OS X detected. Please install XCode command-line tools and " - emergency "ensure that /usr/bin/g++ exists and is executable. Aborting." - fi - else - # If CXX is already set, use the set value. - # Else if CXX is empty, use the value specified via the -C or --with-cxx command-line arguments. - # Else use the default specifed in ../build.sh-usage. - CXX=${CXX:-${arg_C}} - fi - info "C++ compiler: ${CXX}" -} diff --git a/prerequisites/build-functions/set_or_print_default_version.sh b/prerequisites/build-functions/set_or_print_default_version.sh deleted file mode 100644 index 204d96cd1..000000000 --- a/prerequisites/build-functions/set_or_print_default_version.sh +++ /dev/null @@ -1,67 +0,0 @@ -# shellcheck shell=bash disable=SC2148 -# If -p, -D, -P, or -U specifies a package, set default_version -# If -V specifies a package, print the default_version and exit with normal status -# If -l is present, list all packages and versions and exit with normal status -# shellcheck disable=SC2154 -set_or_print_default_version() -{ - # Verify requirements - [ "${arg_l}" == "${__flag_present}" ] && [ ! -z "${arg_D:-${arg_p:-${arg_P:-${arg_U:-${arg_V}}}}}" ] && - emergency "Please pass only one of {-l, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected)." - - if [[ "${arg_l}" == "${__flag_present}" ]]; then - echo "This script can build the following packages:" - fi - # Get package name from argument passed with -p, -V, -D, or -U - package_name="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}" # not needed for -l - - if [[ "${package_name}" == "ofp" ]]; then - "${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh" "${@}" - exit 0 - fi - - if [[ $(uname) == "Darwin" ]]; then - apple_flex_version="2.5.35" - fi - - [ "${package_name}" == "opencoarrays" ] && - emergency "Please use this script with a previously downloaded opencoarrays source archive. This script does not download opencoarrays " - # This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common - # denominator because, for licensing reasons, OS X only has bash 3 by default.) - # See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash - package_version=( - "cmake:3.10.0" - "gcc:10.1.0" - "mpich:3.2" - "wget:1.16.3" - "flex:${apple_flex_version:-2.6.0}" - "bison:3.0.4" - "pkg-config:0.28" - "make:4.1" - "m4:1.4.17" - "subversion:1.9.4" - "ofp:sdf" - ) - for package in "${package_version[@]}" ; do - KEY="${package%%:*}" - VALUE="${package##*:}" - if [[ "${arg_l}" == "${__flag_present}" ]]; then - # If the list was requested, print the current element of the name:version list. - printf "%s (default version %s)\n" "${KEY}" "${VALUE}" - elif [[ "${package_name}" == "${KEY}" ]]; then - # We recognize the package name so we set the default version: - default_version=${VALUE} - # If a printout of the default version number was requested, then print it and exit with normal status - [[ ! -z "${arg_V}" ]] && printf "%s\n" "${default_version}" && exit 0 - break # exit the for loop - fi - done - - # Exit with normal status (package/version has been printed). - [ "${arg_l}" == "${__flag_present}" ] && exit 0 - - # Exit with error status and diagnostic output if empty default_version - if [[ -z "${default_version:-}" ]]; then - emergency "set_or_print_default.sh: Package ${package_name:-} not recognized. Use --l or --list-packages to list the allowable names." - fi -} diff --git a/prerequisites/build-functions/set_or_print_downloader.sh b/prerequisites/build-functions/set_or_print_downloader.sh deleted file mode 100644 index 711f37e33..000000000 --- a/prerequisites/build-functions/set_or_print_downloader.sh +++ /dev/null @@ -1,56 +0,0 @@ -# shellcheck shell=bash disable=SC2148 -# If -p, -P, -U, or -V specifies a package, set fetch variable -# If -D specifies a package, print "${fetch}" and exit with normal status -# If -l is present, list all packages and versions and exit with normal status -# shellcheck disable=SC2154 -set_or_print_downloader() -{ - # Verify requirements - [ ! -z "${arg_D}" ] && [ ! -z "${arg_p:-${arg_P:-${arg_U:-${arg_V}}}}" ] && - emergency "Please pass only one of {-D, -p, -P, -U, -V} or a longer equivalent (multiple detected)." - - package_name="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}" - - if [[ "${package_name}" == "ofp" ]]; then - "${OPENCOARRAYS_SRC_DIR}/prerequisites/install-ofp.sh" "${@}" - exit 0 - fi - - # Choose the first available download mechanism, prioritizing first any absolute requirement - # (git for gcc) and second robustness: - info "Checking available download mechanisms: ftp, wget, and curl." - info "\${package_name}=${package_name} \${arg_b:-}=${arg_b:-}" - - if type curl &> /dev/null; then - gcc_prereqs_fetch=curl - elif type wget &> /dev/null; then - gcc_prereqs_fetch=wget - elif type ftp &> /dev/null; then - if [[ "${package_name}" == "wget" || "${package_name}" == "make" || - "${package_name}" == "bison" || "${package_name}" == "m4" ]]; then - gcc_prereqs_fetch=ftp_url - fi - else - tried="curl, wget, and ftp" - fi - - if [[ "${package_name}" == "gcc" && ! -z ${arg_b:-} ]]; then - if type git &> /dev/null; then - fetch=git - else - tried="git" - fi - else - fetch=${gcc_prereqs_fetch} - fi - - if [[ -z "${fetch:-}" ]]; then - emergency "No available download mechanism. Option(s) tried: ${tried}" - fi - - # If a printout of the download mechanism was requested, then print it and exit with normal status - if [[ ! -z "${arg_D}" ]]; then - printf "%s\n" "${fetch}" - exit 0 - fi -} diff --git a/prerequisites/build-functions/set_or_print_installation_path.sh b/prerequisites/build-functions/set_or_print_installation_path.sh deleted file mode 100644 index f0778eb54..000000000 --- a/prerequisites/build-functions/set_or_print_installation_path.sh +++ /dev/null @@ -1,35 +0,0 @@ -# If -P specifies a package, print the installation path and exit with normal status -# Otherwise, set install_path -# shellcheck disable=SC2154 -set_or_print_installation_path() -{ - # Verify requirements - [ ! -z "${arg_P}" ] && [ ! -z "${arg_p:-${arg_D:-${arg_U:-${arg_V}}}}" ] && - emergency "Please pass only one of {-D, -p, -P, -U, -V} or a longer equivalent (multiple detected)." - - if [[ $arg_p == "opencoarrays" ]]; then - export version_to_build=$(${OPENCOARRAYS_SRC_DIR}/install.sh -V opencoarrays) - export package_name="opencoarrays" - fi - arg_i_default="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations/" - if [[ "${arg_i%/}" == "${arg_i_default}" ]]; then - if [[ -z "${arg_r}" ]]; then - export install_path="${arg_i%/}/${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}/${version_to_build}" - else - export install_path="${arg_r%/}/${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}/${version_to_build}" - fi - else - if [[ ! "${arg_i%/}" != "${arg_r}" ]]; then - emergency "Please pass only one of {-i,-r} or a longer equivalent (multiple detected). [exit 105]" - fi - install_path="${arg_i%/}" - fi - - # If -P is present, print ${install_path} and exit with normal status - if [[ ! -z "${arg_P:-}" ]]; then - printf "%s\n" "${install_path}" - exit 0 - fi - - info "${package_name} ${version_to_build} installation path: ${install_path}" -} diff --git a/prerequisites/build-functions/set_or_print_url.sh b/prerequisites/build-functions/set_or_print_url.sh deleted file mode 100644 index 4665098db..000000000 --- a/prerequisites/build-functions/set_or_print_url.sh +++ /dev/null @@ -1,95 +0,0 @@ -# shellcheck shell=bash -# If -p, -D, -P, or -V specifies a package, set package_url -# If -U specifies a package, print the package_url and exit with normal status -# shellcheck disable=SC2154 -set_or_print_url() -{ - # Verify requirements - [[ -n "${arg_U}" && -n "${arg_D:-${arg_p:-${arg_P:-${arg_V}}}}" ]] && - emergency "Please pass only one of {-B, -D, -p, -P, -U, -V} or a longer equivalent (multiple detected)." - - # Get package name from argument passed with -p, -D, -P, -V, or -U - package_to_build="${arg_p:-${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}}" - -if [[ -n "${arg_u:-}" ]]; then - # User specified a URL from which to download the package - url_tail="${arg_u##*/}" # set url_tail to text_after_final_slash, greedy expansion needed - url_head="${arg_u%${url_tail}}" # set url_head text before url_tail -else - - if [[ "${package_to_build}" == 'cmake' ]]; then - major_minor="${version_to_build%.*}" - fi - package_url_head=( - "gcc;https://ftp.gnu.org/gnu/gcc/gcc-${version_to_build-}/" - "wget;https://ftpmirror.gnu.org/gnu/wget/" - "m4;https://ftpmirror.gnu.org/gnu/m4/" - "pkg-config;https://pkgconfig.freedesktop.org/releases/" - "mpich;https://www.mpich.org/static/downloads/${version_to_build-}/" - "flex;https://sourceforge.net/projects/flex/files/" - "make;https://ftpmirror.gnu.org/gnu/make/" - "bison;https://ftpmirror.gnu.org/gnu/bison/" - "cmake;https://www.cmake.org/files/v${major_minor:-}/" - "subversion;https://www.eu.apache.org/dist/subversion/" - ) - for package in "${package_url_head[@]}" ; do - KEY="${package%%;*}" - VALUE="${package##*;}" - info "KEY=${KEY} VALUE=${VALUE}" - - if [[ "${package_to_build}" == "${KEY}" ]]; then - # We recognize the package name so we set the URL head: - url_head="${VALUE}" - break - fi - done - - if [[ ! -z ${arg_b:-} && ${package_to_build} == 'gcc' ]]; then - url_head="https://gcc.gnu.org/git/" - fi - - # Set differing tails for GCC release downloads versus development branch checkouts - package_url_tail=( - "gcc;gcc-${version_to_build-}.tar.gz" - "wget;wget-${version_to_build-}.tar.gz" - "m4;m4-${version_to_build-}.tar.bz2" - "pkg-config;pkg-config-${version_to_build-}.tar.gz" - "mpich;mpich-${version_to_build-}.tar.gz" - "flex;flex-${version_to_build-}.tar.bz2" - "bison;bison-${version_to_build-}.tar.gz" - "make;make-${version_to_build-}.tar.bz2" - "subversion;subversion-${version_to_build-}.tar.gz" - ) - if [[ $(uname) == "Linux" ]]; then - package_url_tail+=("cmake;cmake-${version_to_build}-Linux-x86_64.sh") - else - package_url_tail+=("cmake;cmake-${version_to_build-}.tar.gz") - fi - for package in "${package_url_tail[@]}" ; do - KEY="${package%%;*}" - VALUE="${package##*;}" - if [[ "${package_to_build}" == "${KEY}" ]]; then - # We recognize the package name so we set the URL tail: - url_tail="${VALUE}" - break - fi - done - - if [[ ! -z ${arg_b:-} && ${package_to_build} == 'gcc' ]]; then - url_tail="gcc" - fi - - if [[ -z "${url_head:-}" || -z "${url_tail}" ]]; then - emergency "Package ${package_name:-} not recognized. Use --l or --list-packages to list the allowable names." - fi - -fi # end if [[ -n "${arg_u:-}" ]]; then - - package_url="${url_head}""${url_tail}" - - # If a printout of the package URL was requested, then print it and exit with normal status - if [[ -n "${arg_U:-}" ]]; then - printf "%s\n" "${package_url}" - exit 0 - fi -} diff --git a/prerequisites/build-functions/unpack_if_necessary.sh b/prerequisites/build-functions/unpack_if_necessary.sh deleted file mode 100644 index 05cd66619..000000000 --- a/prerequisites/build-functions/unpack_if_necessary.sh +++ /dev/null @@ -1,22 +0,0 @@ -# Unpack if the unpacked tar ball is not in the present working directory -# shellcheck disable=SC2154 -unpack_if_necessary() -{ - if [[ "${fetch}" == "git" ]]; then - package_source_directory="${package_name}" - else - if [[ "${url_tail}" == *tar.gz || "${url_tail}" == *tar.bz2 || "${url_tail}" == *.tar.xz ]]; then - info "Unpacking ${url_tail}." - info "pushd ${download_path}" - pushd "${download_path}" - info "Unpack command: tar xf ${url_tail}" - tar xf "${url_tail}" - info "popd" - popd - else - info "Skipping unpacking because ${url_tail} is not a compressed archive (matching one of *.tar.{gz,bz2,xz}). " - fi - # shellcheck disable=SC2034 - package_source_directory="${package_name}-${version_to_build}" - fi -} diff --git a/prerequisites/build.sh b/prerequisites/build.sh deleted file mode 100755 index 7cfdfcbd2..000000000 --- a/prerequisites/build.sh +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/env bash -# BASH3 Boilerplate -# -# build.sh -# -# - Build OpenCoarrays prerequisite packages and their prerequisites -# -# Usage: LOG_LEVEL=7 B3B_USE_CASE=/opt/bash3boilerplate/src/use-case ./my-script.sh -f script_input.txt -# -# More info: -# -# - https://github.com/kvz/bash3boilerplate -# - http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/ -# -# Version: 2.0.0 -# -# Authors: -# -# - Kevin van Zonneveld (http://kvz.io) -# - Izaak Beekman (https://izaakbeekman.com/) -# - Alexander Rathai (Alexander.Rathai@gmail.com) -# - Dr. Damian Rouson (http://www.sourceryinstitute.org/) (documentation) -# -# Licensed under MIT -# Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io) - -# The invocation of bootstrap.sh below performs the following tasks: -# (1) Import several bash3boilerplate helper functions & default settings. -# (2) Set several variables describing the current file and its usage page. -# (3) Parse the usage information (default usage file name: current file's name with -usage appended). -# (4) Parse the command line using the usage information. - -export OPENCOARRAYS_SRC_DIR="${OPENCOARRAYS_SRC_DIR:-${PWD%prerequisites*}}" -export __usage=${OPENCOARRAYS_SRC_DIR}/prerequisites/build.sh-usage -if [[ ! -f "${OPENCOARRAYS_SRC_DIR}/src/libcaf.h" ]]; then - echo "Please run this script inside the OpenCoarrays source \"prerequisites\" subdirectory" - echo "or set OPENCOARRAYS_SRC_DIR to the top-level OpenCoarrays source directory path." - exit 1 -fi -export B3B_USE_CASE="${B3B_USE_CASE:-${OPENCOARRAYS_SRC_DIR}/prerequisites/use-case}" -if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then - echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path." - exit 2 -fi -# shellcheck source=./use-case/bootstrap.sh -source "${B3B_USE_CASE}/bootstrap.sh" "$@" - -# Set up a function to call when receiving an EXIT signal to do some cleanup. Remove if -# not needed. Other signals can be trapped too, like SIGINT and SIGTERM. -function cleanup_before_exit () { - info "Cleaning up. Done" -} -trap cleanup_before_exit EXIT # The signal is specified here. Could be SIGINT, SIGTERM etc. - -### Validation (decide what's required for running your script and error out) -##################################################################### - -export __flag_present=1 - -# shellcheck disable=SC2154 -if [[ "${arg_l}" != "${__flag_present}" && - "${arg_v}" != "${__flag_present}" && - "${arg_h}" != "${__flag_present}" && - -z "${arg_D:-${arg_p:-${arg_P:-${arg_U:-${arg_V}}}}}" ]]; then - help "${__base}: Insufficient arguments. Please pass either -B, -D, -h, -l, -L, -p, -P, -U, -v, -V, or a longer equivalent." -fi - -# Suppress info and debug messages if -B, -l, -P, -U, -V, -D, or their longer equivalent is present: - [[ "${arg_l}" == "${__flag_present}" || ! -z "${arg_P:-${arg_U:-${arg_V:-${arg_D}}}}" ]] && suppress_info_debug_messages - -[ -z "${LOG_LEVEL:-}" ] && emergency "Cannot continue without LOG_LEVEL. " - -### Enforce mutual exclusivity of arguments that print single-line output -[ ! -z "${arg_P:-}" ] && [ ! -z "${arg_V:-}" ] && emergency "Only specify one of -P, -U, -V, or their long-form equivalents." -[ ! -z "${arg_P:-}" ] && [ ! -z "${arg_U:-}" ] && emergency "Only specify one of -P, -U, -V, or their long-form equivalents." -[ ! -z "${arg_U:-}" ] && [ ! -z "${arg_V:-}" ] && emergency "Only specify one of -P, -U, -V, or their long-form equivalents." - -### Print bootstrapped magic variables to STDERR when LOG_LEVEL -### is at the default value (6) or above. -##################################################################### -# shellcheck disable=SC2154 -{ -info "__file: ${__file}" -info "__dir: ${__dir}" -info "__base: ${__base}" -info "__os: ${__os}" -info "__usage: ${__usage}" -info "LOG_LEVEL: ${LOG_LEVEL}" - -info "-b (--install-branch): ${arg_b} " -info "-c (--with-c): ${arg_c} " -info "-C (--with-cxx): ${arg_C} " -info "-d (--debug): ${arg_d} " -info "-D (--print-downloader): ${arg_D} " -info "-e (--verbose): ${arg_e} " -info "-f (--with-fortran): ${arg_f} " -info "-h (--help): ${arg_h} " -info "-i (--install-prefix): ${arg_i} " -info "-I (--install-version): ${arg_I} " -info "-j (--num-threads): ${arg_j} " -info "-l (--list-packages): ${arg_l} " -info "-m (--with-cmake): ${arg_m} " -info "-M (--with-mpi): ${arg_M} " -info "-n (--no-color): ${arg_n} " -info "-o (--only-download): ${arg_o} " -info "-p (--package): ${arg_p} " -info "-P (--print-path): ${arg_P} " -info "-r (--prefix-root): ${arg_r} " -info "-u (--from-url): ${arg_u} " -info "-U (--print-url): ${arg_U} " -info "-v (--version): ${arg_v} " -info "-V (--print-version): ${arg_V} " -info "-y (--yes-to-all): ${arg_y} " -info "-Z (--bootstrap): ${arg_Z} " -} - -# shellcheck source=./build-functions/set_or_print_default_version.sh -source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_default_version.sh" -# shellcheck disable=SC2119 -set_or_print_default_version -export version_to_build="${arg_I:-${arg_b:-${default_version}}}" - -# shellcheck source=./build-functions/set_or_print_downloader.sh -source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_downloader.sh" -# shellcheck disable=SC2119 -set_or_print_downloader $@ - -# shellcheck source=./build-functions/set_or_print_url.sh -source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_url.sh" -set_or_print_url - -# shellcheck source=./build-functions/set_or_print_installation_path.sh -source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_or_print_installation_path.sh" - -set_or_print_installation_path - -# shellcheck source=./build-functions/download_if_necessary.sh -source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/download_if_necessary.sh" -download_if_necessary - -# Exit if -o or --only-download was specified when invoking this script -if [[ ${arg_o:-} == "${__flag_present}" ]]; then - info "No installation to perform: -o or --only-download specified. Exiting." - exit 0 -fi - -# If -Z or --bootstrap was specified, enable bootstrap configure & build -if [[ ${arg_Z:-} != "${__flag_present}" ]]; then - info "Disabling bootstrap. If the gcc/g++/gfortran build fails, try './install.sh --bootstrap'." - export bootstrap_configure="--disable-bootstrap" - export bootstrap_build="" -else - export bootstrap_configure="" - export bootstrap_build="bootstrap" -fi - -# shellcheck source=./build-functions/unpack_if_necessary.sh -source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/unpack_if_necessary.sh" -unpack_if_necessary - -# shellcheck source=./build-functions/set_compilers.sh -source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_compilers.sh" -set_compilers - -# shellcheck source=./build-functions/build_and_install.sh -source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/build_and_install.sh" -build_and_install diff --git a/prerequisites/build.sh-usage b/prerequisites/build.sh-usage deleted file mode 100644 index 9eb637509..000000000 --- a/prerequisites/build.sh-usage +++ /dev/null @@ -1,25 +0,0 @@ - -b --install-branch [arg] Install the specified repository development branch (Examples: -b master). - -c --with-c [arg] Use the specified C compiler. Default="gcc" - -C --with-cxx [arg] Use the specified C++ compiler. Default="g++" - -d --debug Enable debug mode. - -D --print-downloader [arg] Print download program for package specified in argument. - -e --verbose Enable verbose mode, print script as it is executed. - -f --with-fortran [arg] Specify Fortran compiler location. Default="gfortran" - -h --help This page. - -i --install-prefix [arg] Install package in specified path. Default="${OPENCOARRAYS_SRC_DIR%/}/prerequisites/installations/" - -I --install-version [arg] Package version to install. (To see default, use -V or --print-version) - -j --num-threads [arg] Number of threads to use when invoking make. Default="4" - -l --list-packages List the packages this script can install. - -m --with-cmake [arg] Use the specified CMake installation. Default="cmake" - -M --with-mpi [arg] Use the specified MPI installation. - -n --no-color Disable color output. - -o --only-download Download (without building) the package source specified by -p or --package. - -p --package [arg] Package to install. - -P --print-path [arg] Print installation path for package specified in argument. - -r --prefix-root [arg] Installation path to which package name/version will be appended. (Example: -r /opt). - -u --from-url [arg] Specify a URL from which to download a package. - -U --print-url [arg] Print URL for package specified in argument. - -v --version Print OpenCoarrays version number. - -V --print-version [arg] Print installation version for package specified in argument. - -y --yes-to-all Build non-interactively by assuming affirmative user responses. - -Z --bootstrap Enable bootstrap build for robustness when building the required GCC version with an old GCC version. diff --git a/prerequisites/check_version.sh b/prerequisites/check_version.sh deleted file mode 100755 index fdc065c32..000000000 --- a/prerequisites/check_version.sh +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/bash -# -# check_version.sh -# -# -- Verify whether an OpenCoarrays prerequisite meets the required minimum version number. -# -# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License: -# Copyright (c) 2015-2020, Sourcery, Inc. -# Copyright (c) 2015-2020, Sourcery Institute -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright notice, this -# list of conditions and the following disclaimer in the documentation and/or -# other materials provided with the distribution. -# 3. Neither the names of the copyright holders nor the names of their contributors -# may be used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -# Interpret the first argument as the package executable name -package="$1" -# Interpret the second argument as the minimimum acceptable package version number -minimum_version="$2" -# Interpret the third argument as indicating the desired verbosity -verbose=$3 - -this_script=$(basename "$0") - -usage() -{ - echo "" - echo " $this_script - Bash script for verifying minimum version numbers for OpenCoarrays prerequisites" - echo "" - echo " Usage (optional arguments in square brackets): " - echo " $this_script [