@@ -526,89 +526,93 @@ find_or_install()
526526 echo " $this_script : Ready to install $package executable $executable in $package_install_path "
527527 fi
528528
529- echo -e " $this_script : Ok to download (if necessary), build, and install $package from source? (Y/n) "
530- read -r proceed_with_build
531-
532- if [[ " $proceed_with_build " == " n" || " $proceed_with_build " == " no" ]]; then
533- printf " n\n"
534- echo -e " $this_script : OpenCoarrays installation requires $package . Aborting. [exit 70]\n"
535- exit 70
536-
537- else # permission granted to build
538- printf " Y\n"
539-
540- # On OS X, CMake must be built with Apple LLVM gcc, which XCode command-line tools puts in /usr/bin
541- if [[ $( uname) == " Darwin" && $package == " cmake" ]]; then
542- if [[ -x " /usr/bin/gcc" ]]; then
543- CC=/usr/bin/gcc
544- else
545- echo -e " $this_script : OS X detected. Please install XCode command-line tools and \n"
546- echo -e " $this_script : ensure that /usr/bin/gcc exists and is executable. Aborting. [exit 75]\n"
547- exit 75
548- fi
549- # Otherwise, if no CC has been defined yet, use the gcc in the user's PATH
550- elif [[ -z " ${CC:- } " ]]; then
551- CC=gcc
529+ if [[ " ${arg_y} " == " ${__flag_present} " ]]; then
530+ info " -y or --yes-to-all flag present. Proceeding with non-interactive build."
531+ else
532+ echo -e " $this_script : Ok to download (if necessary), build, and install $package from source? (Y/n) "
533+ read -r proceed_with_build
534+
535+ if [[ " $proceed_with_build " == " n" || " $proceed_with_build " == " no" ]]; then
536+ printf " n\n"
537+ echo -e " $this_script : OpenCoarrays installation requires $package . Aborting. [exit 70]\n"
538+ exit 70
539+ else # permission granted to build
540+ printf " Y\n"
552541 fi
542+ fi
553543
554- # On OS X, CMake must be built with Apple LLVM g++, which XCode command-line tools puts in /usr/bin
555- if [[ $( uname) == " Darwin" && $package == " cmake" ]]; then
556- if [[ -x " /usr/bin/g++" ]]; then
557- CXX=/usr/bin/g++
558- else
559- echo -e " $this_script : OS X detected. Please install XCode command-line tools \n"
560- echo -e " $this_script : and ensure that /usr/bin/g++ exists and is executable. Aborting. [exit 76]\n"
561- exit 76
562- fi
563- # Otherwise, if no CXX has been defined yet, use the g++ in the user's PATH
564- elif [[ -z " ${CXX:- } " ]]; then
565- CXX=g++
544+ # On OS X, CMake must be built with Apple LLVM gcc, which XCode command-line tools puts in /usr/bin
545+ if [[ $( uname) == " Darwin" && $package == " cmake" ]]; then
546+ if [[ -x " /usr/bin/gcc" ]]; then
547+ CC=/usr/bin/gcc
548+ else
549+ echo -e " $this_script : OS X detected. Please install XCode command-line tools and \n"
550+ echo -e " $this_script : ensure that /usr/bin/gcc exists and is executable. Aborting. [exit 75]\n"
551+ exit 75
566552 fi
553+ # Otherwise, if no CC has been defined yet, use the gcc in the user's PATH
554+ elif [[ -z " ${CC:- } " ]]; then
555+ CC=gcc
556+ fi
567557
568- # If no FC has been defined yet, use the gfortran in the user's PATH
569- if [[ -z " ${FC:- } " ]]; then
570- FC=gfortran
558+ # On OS X, CMake must be built with Apple LLVM g++, which XCode command-line tools puts in /usr/bin
559+ if [[ $( uname) == " Darwin" && $package == " cmake" ]]; then
560+ if [[ -x " /usr/bin/g++" ]]; then
561+ CXX=/usr/bin/g++
562+ else
563+ echo -e " $this_script : OS X detected. Please install XCode command-line tools \n"
564+ echo -e " $this_script : and ensure that /usr/bin/g++ exists and is executable. Aborting. [exit 76]\n"
565+ exit 76
571566 fi
567+ # Otherwise, if no CXX has been defined yet, use the g++ in the user's PATH
568+ elif [[ -z " ${CXX:- } " ]]; then
569+ CXX=g++
570+ fi
572571
572+ # If no FC has been defined yet, use the gfortran in the user's PATH
573+ if [[ -z " ${FC:- } " ]]; then
574+ FC=gfortran
575+ fi
573576
574- # Strip trailing package name and version number, if present, from installation path
575- default_package_version=$( ./build.sh -V ${package} )
576- package_install_prefix=" ${package_install_path% ${package} / ${arg_I:- ${default_package_version} } * } "
577577
578- echo -e " $this_script : Downloading, building, and installing $package \n "
579- echo " $this_script : Build command: FC= $FC CC= $CC CXX= $CXX ./build.sh -p $ package -i $package_install_prefix -j $num_threads "
580- FC =" $FC " CC= " $CC " CXX= " $CXX " ./build.sh -p " $package " -i " $package_install_prefix " -j " $num_threads "
578+ # Strip trailing package name and version number, if present, from installation path
579+ default_package_version= $( ./build.sh -V ${ package} )
580+ package_install_prefix =" ${package_install_path % ${package} / ${arg_I :- ${default_package_version} } * } "
581581
582- if [[ -x " $package_install_path /bin/$executable " ]]; then
583- echo -e " $this_script : Installation successful.\n"
584- if [[ " $package " == " $executable " ]]; then
585- echo -e " $this_script : $executable is in $package_install_path /bin \n"
586- else
587- echo -e " $this_script : $package executable $executable is in $package_install_path /bin \n"
588- fi
589- # TODO Merge all applicable branches under one 'if [[ $package == $executable ]]; then'
590- if [[ $package == " cmake" ]]; then
591- echo " $this_script : export CMAKE=$package_install_path /bin/$executable "
592- export CMAKE=" $package_install_path /bin/$executable "
593- elif [[ $package == " bison" ]]; then
594- echo " $this_script : export YACC=$package_install_path /bin/$executable "
595- export YACC=" $package_install_path /bin/$executable "
596- elif [[ $package == " flex" ]]; then
597- echo " $this_script : export FLEX=$package_install_path /bin/$executable "
598- export FLEX=" $package_install_path /bin/$executable "
599- elif [[ $package == " m4" ]]; then
600- echo " $this_script : export M4=$package_install_path /bin/$executable "
601- export M4=" $package_install_path /bin/$executable "
602- elif [[ $package == " gcc" ]]; then
603- echo " $this_script : export FC=$package_install_path /bin/gfortran"
604- export FC=" $package_install_path /bin/gfortran"
605- echo " $this_script : export CC=$package_install_path /bin/gcc"
606- export CC=" $package_install_path /bin/gcc"
607- echo " $this_script : export CXX=$package_install_path /bin/g++"
608- export CXX=" $package_install_path /bin/g++"
609- gfortran_lib_paths=" $package_install_path /lib64/:$package_install_path /lib"
610- if [[ -z " ${LD_LIBRARY_PATH:- } " ]]; then
611- export LD_LIBRARY_PATH=" $gfortran_lib_paths "
582+ echo -e " $this_script : Downloading, building, and installing $package \n"
583+ echo " $this_script : Build command: FC=$FC CC=$CC CXX=$CXX ./build.sh -p $package -i $package_install_prefix -j $num_threads "
584+ FC=" $FC " CC=" $CC " CXX=" $CXX " ./build.sh -p " $package " -i " $package_install_prefix " -j " $num_threads "
585+
586+ if [[ -x " $package_install_path /bin/$executable " ]]; then
587+ echo -e " $this_script : Installation successful.\n"
588+ if [[ " $package " == " $executable " ]]; then
589+ echo -e " $this_script : $executable is in $package_install_path /bin \n"
590+ else
591+ echo -e " $this_script : $package executable $executable is in $package_install_path /bin \n"
592+ fi
593+ # TODO Merge all applicable branches under one 'if [[ $package == $executable ]]; then'
594+ if [[ $package == " cmake" ]]; then
595+ echo " $this_script : export CMAKE=$package_install_path /bin/$executable "
596+ export CMAKE=" $package_install_path /bin/$executable "
597+ elif [[ $package == " bison" ]]; then
598+ echo " $this_script : export YACC=$package_install_path /bin/$executable "
599+ export YACC=" $package_install_path /bin/$executable "
600+ elif [[ $package == " flex" ]]; then
601+ echo " $this_script : export FLEX=$package_install_path /bin/$executable "
602+ export FLEX=" $package_install_path /bin/$executable "
603+ elif [[ $package == " m4" ]]; then
604+ echo " $this_script : export M4=$package_install_path /bin/$executable "
605+ export M4=" $package_install_path /bin/$executable "
606+ elif [[ $package == " gcc" ]]; then
607+ echo " $this_script : export FC=$package_install_path /bin/gfortran"
608+ export FC=" $package_install_path /bin/gfortran"
609+ echo " $this_script : export CC=$package_install_path /bin/gcc"
610+ export CC=" $package_install_path /bin/gcc"
611+ echo " $this_script : export CXX=$package_install_path /bin/g++"
612+ export CXX=" $package_install_path /bin/g++"
613+ gfortran_lib_paths=" $package_install_path /lib64/:$package_install_path /lib"
614+ if [[ -z " ${LD_LIBRARY_PATH:- } " ]]; then
615+ export LD_LIBRARY_PATH=" $gfortran_lib_paths "
612616 else
613617 export LD_LIBRARY_PATH=" $gfortran_lib_paths :$LD_LIBRARY_PATH "
614618 fi
@@ -638,7 +642,5 @@ find_or_install()
638642 exit 80
639643 fi # End 'if [[ -x "$package_install_path/bin/$executable" ]]'
640644
641- fi # End 'if [[ "$proceed_with_build" == "y" ]]; then'
642-
643645 fi # End 'if [[ "$package" != "none" ]]; then'
644646}
0 commit comments