11# shellcheck shell=bash disable=SC2154,SC2129,SC2148
22report_results ()
33{
4- # Report installation success or failure:
5- if [[ -x " $install_path /bin/caf" && -x " $install_path /bin/cafrun" ]]; then
4+ type_FC=` type ${FC} `
5+ fully_qualified_FC=" /${type_FC#*/ } "
6+ if [[ ${fully_qualified_FC} != * gfortran* ]]; then
7+ emergency " report_results.sh: non-gfortran compiler: \$ {fully_qualified_FC}=${fully_qualified_FC} "
8+ fi
9+ # Set path_to_FC fully-qualified gfortran location
10+ compiler_install_root=" ${fully_qualified_FC%% bin/ gfortran* } "
11+
12+ type_MPIFC=` type ${MPIFC} `
13+ fully_qualified_MPIFC=" /${type_MPIFC#*/ } "
14+ mpi_install_root=" ${fully_qualified_MPIFC%% bin/ mpif90* } "
15+
16+ type_CMAKE=` type ${CMAKE} `
17+ fully_qualified_CMAKE=" /${type_CMAKE#*/ } "
18+ cmake_install_path=" ${fully_qualified_CMAKE%%/ cmake* } "
19+
20+ # Report installation success or failure and record locations for software stack:
21+ if [[ -x " ${install_path%/ } /bin/caf" && -x " ${install_path%/ } /bin/cafrun" ]]; then
622
723 # Installation succeeded
8- echo " $this_script : Done."
9- echo " "
10- echo " *** The OpenCoarrays compiler wrapper (caf) and program ***"
11- echo " *** launcher (cafrun) are in the following directory: ***"
12- echo " "
13- echo " $install_path /bin."
14- echo " "
24+ info " $this_script : Done."
25+ info " "
26+ info " *** The OpenCoarrays compiler wrapper (caf) and program ***"
27+ info " *** launcher (cafrun) are in the following directory: ***"
28+ info " "
29+ info " ${ install_path%/ } /bin."
30+ info " "
1531 if [[ -f setup.sh ]]; then
1632 ${SUDO:- } rm setup.sh
1733 fi
@@ -25,47 +41,51 @@ report_results()
2541 while IFS=' ' read -r line || [[ -n " $line " ]]; do
2642 echo " # $line " >> setup.csh
2743 done < " ${opencoarrays_src_dir} /LICENSE"
28- echo " # " | tee -a setup.csh setup.sh
29- echo " # Execute this script via the following command: " | tee -a setup.csh setup.sh
30- echo " # source $install_path /setup.sh " | tee -a setup.csh setup.sh
31- echo " " | tee -a setup.csh setup.sh
32- gcc_install_path=$( " ${build_script} " -P gcc)
33- if [[ -x " $gcc_install_path /bin/gfortran" ]]; then
34- echo " if [[ -z \"\$ PATH\" ]]; then " >> setup.sh
35- echo " export PATH=\" $gcc_install_path /bin\" " >> setup.sh
36- echo " else " >> setup.sh
37- echo " export PATH=\" $gcc_install_path /bin:\$ PATH\" " >> setup.sh
38- echo " fi " >> setup.sh
39- echo " set path = (\" $gcc_install_path \" /bin \"\$ path\" ) " >> setup.csh
44+ echo " # " | tee -a setup.csh setup.sh
45+ echo " # Execute this script via the following command: " | tee -a setup.csh setup.sh
46+ echo " # source ${install_path%/ } /setup.sh " | tee -a setup.csh setup.sh
47+ echo " " | tee -a setup.csh setup.sh
48+ if [[ -x " $fully_qualified_FC " ]]; then
49+ echo " if [[ -z \"\$ PATH\" ]]; then " >> setup.sh
50+ echo " export PATH=\" ${compiler_install_root%/ } /bin\" " >> setup.sh
51+ echo " else " >> setup.sh
52+ echo " export PATH=\" ${compiler_install_root%/ } /bin:\$ PATH\" " >> setup.sh
53+ echo " fi " >> setup.sh
54+ echo " set path = (\" ${compiler_install_root%/ } \" /bin \"\$ path\" ) " >> setup.csh
4055 fi
41- if [[ -d " $gcc_install_path / lib" || -d " $gcc_install_path /lib64" ]]; then
42- gfortran_lib_paths =" $gcc_install_path / lib64/:$gcc_install_path /lib"
43- echo " if [[ -z \"\$ LD_LIBRARY_PATH\" ]]; then " >> setup.sh
44- echo " export LD_LIBRARY_PATH=\" $gfortran_lib_paths \" " >> setup.sh
45- echo " else " >> setup.sh
46- echo " export LD_LIBRARY_PATH=\" $gfortran_lib_paths :\$ LD_LIBRARY_PATH\" " >> setup.sh
47- echo " fi " >> setup.sh
48- echo " set LD_LIBRARY_PATH = (\" $gfortran_lib_paths \" /bin \"\$ LD_LIBRARY_PATH\" ) " >> setup.csh
56+ if [[ -d " ${compiler_install_root %/ } / lib" || -d " ${compiler_install_root %/ } /lib64" ]]; then
57+ compiler_lib_paths =" ${compiler_install_root %/ } / lib64/:${compiler_install_root %/ } /lib"
58+ echo " if [[ -z \"\$ LD_LIBRARY_PATH\" ]]; then " >> setup.sh
59+ echo " export LD_LIBRARY_PATH=\" ${compiler_lib_paths %/ } \" " >> setup.sh
60+ echo " else " >> setup.sh
61+ echo " export LD_LIBRARY_PATH=\" ${compiler_lib_paths %/ } :\$ LD_LIBRARY_PATH\" " >> setup.sh
62+ echo " fi " >> setup.sh
63+ echo " set LD_LIBRARY_PATH = (\" ${compiler_lib_paths %/ } \" /bin \"\$ LD_LIBRARY_PATH\" ) " >> setup.csh
4964 fi
5065 echo " " >> setup.sh
51- mpich_install_path=$( " ${build_script} " -P mpich)
52- if [[ -x " $mpich_install_path /bin/mpif90" ]]; then
66+ if [[ -x " $mpi_install_root /bin/mpif90" ]]; then
5367 echo " if [[ -z \"\$ PATH\" ]]; then " >> setup.sh
54- echo " export PATH=\" $mpich_install_path / bin\" " >> setup.sh
68+ echo " export PATH=\" ${mpi_install_root %/ } / bin\" " >> setup.sh
5569 echo " else " >> setup.sh
56- echo " export PATH=\" $mpich_install_path / bin\" :\$ PATH " >> setup.sh
70+ echo " export PATH=\" ${mpi_install_root %/ } / bin\" :\$ PATH " >> setup.sh
5771 echo " fi " >> setup.sh
58- echo " set path = (\" $mpich_install_path \" /bin \"\$ path\" ) " >> setup.csh
72+ echo " set path = (\" ${mpi_install_root %/ } \" /bin \"\$ path\" ) " >> setup.csh
5973 fi
60- cmake_install_path=$( " ${build_script} " -P cmake)
61- if [[ -x " $cmake_install_path /bin/cmake" ]]; then
74+ if [[ -x " $cmake_install_path /cmake" ]]; then
6275 echo " if [[ -z \"\$ PATH\" ]]; then " >> setup.sh
63- echo " export PATH=\" $cmake_install_path /bin \" " >> setup.sh
76+ echo " export PATH=\" ${ cmake_install_path%/ } / \" " >> setup.sh
6477 echo " else " >> setup.sh
65- echo " export PATH=\" $cmake_install_path /bin \" :\$ PATH " >> setup.sh
78+ echo " export PATH=\" ${ cmake_install_path%/ } / \" :\$ PATH " >> setup.sh
6679 echo " fi " >> setup.sh
67- echo " set path = (\" $cmake_install_path \" /bin \"\$ path\" ) " >> setup.csh
80+ echo " set path = (\" ${ cmake_install_path%/ } \" /\"\$ path\" ) " >> setup.csh
6881 fi
82+ # In all likelihood, the following paths are only needed if OpenCoarrays built them,
83+ # In by far the most common such use case, they would have been built in a recursive
84+ # build of all the OpenCoarrays dependency tree (rather than built indvidually via
85+ # ./install --package) so we only need check the default location in which OpenCoarrays
86+ # would install them. If they are not there, then it is very likely the case that the
87+ # the system versions of these packages are present and in the user's path or that the
88+ # user doesn't need them at all (e.g. there was no need to build gfortran from source).
6989 flex_install_path=$( " ${build_script} " -P flex)
7090 if [[ -x " $flex_install_path /bin/flex" ]]; then
7191 echo " if [[ -z \"\$ PATH\" ]]; then " >> setup.sh
@@ -96,11 +116,11 @@ report_results()
96116 opencoarrays_install_path=" ${install_path} "
97117 if [[ -x " $opencoarrays_install_path /bin/caf" ]]; then
98118 echo " if [[ -z \"\$ PATH\" ]]; then " >> setup.sh
99- echo " export PATH=\" $opencoarrays_install_path /bin\" " >> setup.sh
119+ echo " export PATH=\" ${ opencoarrays_install_path%/ } /bin\" " >> setup.sh
100120 echo " else " >> setup.sh
101- echo " export PATH=\" $opencoarrays_install_path /bin\" :\$ PATH " >> setup.sh
121+ echo " export PATH=\" ${ opencoarrays_install_path%/ } /bin\" :\$ PATH " >> setup.sh
102122 echo " fi " >> setup.sh
103- echo " set path = (\" $opencoarrays_install_path \" /bin \"\$ path\" ) " >> setup.csh
123+ echo " set path = (\" ${ opencoarrays_install_path%/ } \" /bin \"\$ path\" ) " >> setup.csh
104124 fi
105125 if ${SUDO:- } mv setup.sh " $opencoarrays_install_path " ; then
106126 setup_sh_location=$opencoarrays_install_path
@@ -117,8 +137,8 @@ report_results()
117137 echo " *** setup.csh in a C-shell or add one of the following statements ***"
118138 echo " *** to your login file: ***"
119139 echo " "
120- echo " source $setup_sh_location /setup.sh"
121- echo " source $setup_csh_location /setup.csh"
140+ echo " source ${ setup_sh_location%/ } /setup.sh"
141+ echo " source ${ setup_csh_location%/ } /setup.csh"
122142 echo " "
123143 echo " *** Installation complete. ***"
124144
0 commit comments