@@ -41,10 +41,10 @@ find_or_install()
4141 package_in_path=false
4242 fi
4343
44- package_install_path =$( ./build.sh -P " $package " )
44+ export default_package_install_path =$( ./build.sh -P " $package " )
4545
46- printf " Checking whether %s is in %s..." " $executable " " $package_install_path "
47- if [[ -x " $package_install_path /bin/$executable " ]]; then
46+ printf " Checking whether %s is in %s..." " $executable " " $default_package_install_path "
47+ if [[ -x " $default_package_install_path /bin/$executable " ]]; then
4848 printf " yes.\n"
4949 script_installed_package=true
5050 stack_push script_installed " $package " " $executable "
@@ -78,7 +78,7 @@ find_or_install()
7878
7979 elif [[ " $script_installed_package " == true ]]; then
8080 echo -e " $this_script : Using the $package installed by $this_script \n"
81- export CMAKE=$package_install_path /bin/$executable
81+ export CMAKE=$default_package_install_path /bin/$executable
8282 stack_push dependency_pkg " none"
8383 stack_push dependency_exe " none"
8484 stack_push dependency_path " none"
@@ -136,9 +136,9 @@ find_or_install()
136136 elif [[ " $script_installed_package " == true ]]; then
137137
138138 echo -e " $this_script : Using the $package installed by $this_script \n"
139- export MPIFC=$package_install_path /bin/mpifort
140- export MPICC=$package_install_path /bin/mpicc
141- export MPICXX=$package_install_path /bin/mpicxx
139+ export MPIFC=$default_package_install_path /bin/mpifort
140+ export MPICC=$default_package_install_path /bin/mpicc
141+ export MPICXX=$default_package_install_path /bin/mpicxx
142142 # Halt the recursion
143143 stack_push dependency_pkg " none"
144144 stack_push dependency_exe " none"
@@ -248,10 +248,10 @@ find_or_install()
248248
249249 elif [[ " $script_installed_package " == true ]]; then
250250 echo -e " $this_script : Using the $package executable $executable installed by $this_script \n"
251- export FC=$package_install_path /bin/gfortran
252- export CC=$package_install_path /bin/gcc
253- export CXX=$package_install_path /bin/g++
254- gfortran_lib_paths=" $package_install_path /lib64/:$package_install_path /lib"
251+ export FC=$default_package_install_path /bin/gfortran
252+ export CC=$default_package_install_path /bin/gcc
253+ export CXX=$default_package_install_path /bin/g++
254+ gfortran_lib_paths=" $default_package_install_path /lib64/:$default_package_install_path /lib"
255255 if [[ -z " ${LD_LIBRARY_PATH:- } " ]]; then
256256 echo " $this_script : export LD_LIBRARY_PATH=\" $gfortran_lib_paths \" "
257257 export LD_LIBRARY_PATH=" $gfortran_lib_paths "
@@ -327,7 +327,7 @@ find_or_install()
327327
328328 if [[ " $script_installed_package " == true ]]; then
329329 echo -e " $this_script : Using the $executable installed by $this_script \n"
330- export FLEX=$package_install_path /bin/$executable
330+ export FLEX=$default_package_install_path /bin/$executable
331331 # Remove flex from the dependency stack
332332 stack_pop dependency_pkg package_done
333333 stack_pop dependency_exe executable_done
@@ -347,7 +347,7 @@ find_or_install()
347347 if ! ./check_version.sh " $package " " $( ./build.sh -V " $package " ) " ; then
348348 printf " yes\n"
349349
350- export FLEX=" $package_install_path /bin/$executable "
350+ export FLEX=" $default_package_install_path /bin/$executable "
351351 # Trigger 'find_or_install bison' and subsequent build of $package
352352 stack_push dependency_pkg " bison"
353353 stack_push dependency_exe " yacc"
@@ -387,7 +387,7 @@ find_or_install()
387387
388388 if [[ " $script_installed_package " == true ]]; then
389389 echo -e " $this_script : Using the $package executable $executable installed by $this_script \n"
390- export YACC=$package_install_path /bin/yacc
390+ export YACC=$default_package_install_path /bin/yacc
391391 # Remove bison from the dependency stack
392392 stack_pop dependency_pkg package_done
393393 stack_pop dependency_exe executable_done
@@ -405,7 +405,7 @@ find_or_install()
405405 echo -e " $this_script : Checking whether $package executable $executable in PATH is version < $minimum_version ... "
406406 if ! ./check_version.sh " $package " " $( ./build.sh -V " $package " ) " ; then
407407 printf " yes.\n"
408- export YACC=" $package_install_path /bin/$executable "
408+ export YACC=" $default_package_install_path /bin/$executable "
409409 # Trigger 'find_or_install m4' and subsequent build of $package
410410 stack_push dependency_pkg " m4"
411411 stack_push dependency_exe " m4"
@@ -445,7 +445,7 @@ find_or_install()
445445
446446 if [[ " $script_installed_package " == true ]]; then
447447 echo -e " $this_script : Using the $package executable $executable installed by $this_script \n"
448- export M4=$package_install_path /bin/m4
448+ export M4=$default_package_install_path /bin/m4
449449 # Remove m4 from the dependency stack
450450 stack_pop dependency_pkg package_done
451451 stack_pop dependency_exe executable_done
@@ -463,7 +463,7 @@ find_or_install()
463463 echo -e " $this_script : Checking whether $package executable $executable in PATH is version < $minimum_version ... "
464464 if ! ./check_version.sh " $package " " $( ./build.sh -V " $package " ) " ; then
465465 printf " yes.\n"
466- export M4=" $package_install_path /bin/m4"
466+ export M4=" $default_package_install_path /bin/m4"
467467 # Halt the recursion and signal that there are no prerequisites to build
468468 stack_push dependency_pkg " none"
469469 stack_push dependency_exe " none"
@@ -488,7 +488,7 @@ find_or_install()
488488
489489 else # $package not in PATH and not yet installed by this script
490490 # Halt the recursion and signal that there are no prerequisites to build
491- export M4=" $package_install_path /bin/m4"
491+ export M4=" $default_package_install_path /bin/m4"
492492 stack_push dependency_pkg " none"
493493 stack_push dependency_exe " none"
494494 stack_push dependency_path " none"
@@ -532,16 +532,30 @@ find_or_install()
532532
533533 stack_pop dependency_pkg package
534534 stack_pop dependency_exe executable
535- stack_pop dependency_path package_install_path
535+ stack_pop dependency_path default_package_install_path
536536
537537 if [[ $package != " none" ]]; then
538538
539+ export default_package_version=$( ./build.sh -V " ${package} " )
540+ export package_version_to_install=${arg_I:- ${default_package_version} }
541+
542+ prefix_root=" ${prefix_root:- ${default_package_install_path% ${package} / ${package_version_to_install} } } "
543+
544+ if [[ ${package} == " gcc" ]]; then
545+ export package_directory_name=" gnu"
546+ else
547+ export package_directory_name=${package}
548+ fi
549+
550+ package_install_prefix=" ${prefix_root} /${package_directory_name} /${package_version_to_install} "
551+
539552 if [[ " $package " == " $executable " ]]; then
540- echo " $this_script : Ready to install $executable in $package_install_path "
553+ echo " $this_script : Ready to install $executable in $package_install_prefix "
541554 else
542- echo " $this_script : Ready to install $package executable $executable in $package_install_path "
555+ echo " $this_script : Ready to install $package executable $executable in $package_install_prefix "
543556 fi
544557
558+
545559 if [[ " ${arg_y} " == " ${__flag_present} " ]]; then
546560 info " -y or --yes-to-all flag present. Proceeding with non-interactive build."
547561 else
@@ -590,11 +604,6 @@ find_or_install()
590604 FC=gfortran
591605 fi
592606
593-
594- # Strip trailing package name and version number, if present, from installation path
595- default_package_version=$( ./build.sh -V " ${package} " )
596- package_install_prefix=" ${package_install_path% ${package} / ${arg_I:- ${default_package_version} } * } "
597-
598607 if [[ " ${arg_y} " == " ${__flag_present} " ]]; then
599608 yes_to_all=" -y"
600609 fi
@@ -605,66 +614,65 @@ find_or_install()
605614
606615 echo -e " $this_script : Downloading, building, and installing $package \n"
607616 echo " $this_script : Build command: FC=$FC CC=$CC CXX=$CXX ./build.sh -p $package -i $package_install_prefix -j $num_threads ${yes_to_all:- } ${bootstrap:- } "
617+
608618 FC=" $FC " CC=" $CC " CXX=" $CXX " ./build.sh -p " $package " -i " $package_install_prefix " -j " $num_threads " " ${yes_to_all:- } " " ${bootstrap:- } "
609619
610- if [[ -x " $package_install_path /bin/$executable " ]]; then
620+ if [[ ! -x " $package_install_prefix /bin/$executable " ]]; then
621+
622+ echo -e " $this_script : Installation unsuccessful. "
623+ emergency " $executable is not in the path ($package_install_prefix /bin) or the user lacks executable permission."
624+
625+ else
611626 echo -e " $this_script : Installation successful.\n"
612627 if [[ " $package " == " $executable " ]]; then
613- echo -e " $this_script : $executable is in $package_install_path /bin \n"
628+ echo -e " $this_script : $executable is in $default_package_install_path /bin \n"
614629 else
615- echo -e " $this_script : $package executable $executable is in $package_install_path /bin \n"
630+ echo -e " $this_script : $package executable $executable is in $default_package_install_path /bin \n"
616631 fi
617- # TODO Merge all applicable branches under one 'if [[ $package == $executable ]]; then'
632+
618633 if [[ $package == " cmake" ]]; then
619- echo " $this_script : export CMAKE=$package_install_path /bin/$executable "
620- export CMAKE=" $package_install_path /bin/$executable "
634+ echo " $this_script : export CMAKE=$default_package_install_path /bin/$executable "
635+ export CMAKE=" $default_package_install_path /bin/$executable "
621636 elif [[ $package == " bison" ]]; then
622- echo " $this_script : export YACC=$package_install_path /bin/$executable "
623- export YACC=" $package_install_path /bin/$executable "
637+ echo " $this_script : export YACC=$default_package_install_path /bin/$executable "
638+ export YACC=" $default_package_install_path /bin/$executable "
624639 elif [[ $package == " flex" ]]; then
625- echo " $this_script : export FLEX=$package_install_path /bin/$executable "
626- export FLEX=" $package_install_path /bin/$executable "
640+ echo " $this_script : export FLEX=$default_package_install_path /bin/$executable "
641+ export FLEX=" $default_package_install_path /bin/$executable "
627642 elif [[ $package == " m4" ]]; then
628- echo " $this_script : export M4=$package_install_path /bin/$executable "
629- export M4=" $package_install_path /bin/$executable "
643+ echo " $this_script : export M4=$default_package_install_path /bin/$executable "
644+ export M4=" $default_package_install_path /bin/$executable "
630645 elif [[ $package == " gcc" ]]; then
631- echo " $this_script : export FC=$package_install_path /bin/gfortran"
632- export FC=" $package_install_path /bin/gfortran"
633- echo " $this_script : export CC=$package_install_path /bin/gcc"
634- export CC=" $package_install_path /bin/gcc"
635- echo " $this_script : export CXX=$package_install_path /bin/g++"
636- export CXX=" $package_install_path /bin/g++"
637- gfortran_lib_paths=" $package_install_path /lib64/:$package_install_path /lib"
646+ echo " $this_script : export FC=$default_package_install_path /bin/gfortran"
647+ export FC=" $default_package_install_path /bin/gfortran"
648+ echo " $this_script : export CC=$default_package_install_path /bin/gcc"
649+ export CC=" $default_package_install_path /bin/gcc"
650+ echo " $this_script : export CXX=$default_package_install_path /bin/g++"
651+ export CXX=" $default_package_install_path /bin/g++"
652+ gfortran_lib_paths=" $default_package_install_path /lib64/:$default_package_install_path /lib"
638653 if [[ -z " ${LD_LIBRARY_PATH:- } " ]]; then
639654 export LD_LIBRARY_PATH=" $gfortran_lib_paths "
640655 else
641656 export LD_LIBRARY_PATH=" $gfortran_lib_paths :$LD_LIBRARY_PATH "
642657 fi
643658 elif [[ $package == " mpich" ]]; then
644- echo " $this_script : export MPIFC=$package_install_path /bin/mpifort"
645- export MPIFC=" $package_install_path /bin/mpifort"
646- echo " $this_script : export MPICC= $package_install_path /bin/mpicc"
647- export MPICC=" $package_install_path /bin/mpicc"
648- echo " $this_script : export MPICXX=$package_install_path /bin/mpicxx"
649- export MPICXX=" $package_install_path /bin/mpicxx"
659+ echo " $this_script : export MPIFC=$default_package_install_path /bin/mpifort"
660+ export MPIFC=" $default_package_install_path /bin/mpifort"
661+ echo " $this_script : export MPICC= $default_package_install_path /bin/mpicc"
662+ export MPICC=" $default_package_install_path /bin/mpicc"
663+ echo " $this_script : export MPICXX=$default_package_install_path /bin/mpicxx"
664+ export MPICXX=" $default_package_install_path /bin/mpicxx"
650665 else
651666 echo -e " $this_script : WARNING: $package executable $executable installed correctly but the \n"
652667 echo -e " $this_script : corresponding environment variable(s) have not been set. This \n"
653668 echo -e " $this_script : could prevent a complete build of OpenCoarrays. Please report this\n"
654669 echo -e " $this_script : issue at https://github.com/sourceryinstitute/opencoarrays/issues\n"
655670 fi
656671 if [[ -z " ${PATH:- } " ]]; then
657- export PATH=" $package_install_path /bin"
672+ export PATH=" $default_package_install_path /bin"
658673 else
659- export PATH=" $package_install_path /bin:$PATH "
674+ export PATH=" $default_package_install_path /bin:$PATH "
660675 fi
661- else
662- echo -e " $this_script : Installation unsuccessful. "
663- echo -e " $executable is not in the following expected path or the user lacks executable permission for it:\n"
664- echo -e " $package_install_path /bin \n"
665- printf " Aborting. [exit 80]"
666- exit 80
667- fi # End 'if [[ -x "$package_install_path/bin/$executable" ]]'
668-
669- fi # End 'if [[ "$package" != "none" ]]; then'
676+ fi
677+ fi # End 'if [[ ! -x "$package_install_prefix/bin/$executable" ]]; then'
670678}
0 commit comments