@@ -14,28 +14,28 @@ function usage()
1414 echo " Usage:"
1515 echo " "
1616 echo " cd <opencoarrays-source-directory>"
17- echo " ./developer_scripts/gcc-trunk-install.sh [--patch-file <patch-file-name>] [--install-prefix <installation-path>]"
17+ echo " ./developer_scripts/gcc-trunk-install.sh [--patch-file <patch-file-name>] [--packages-root <installation-path>]"
1818 echo " or"
19- echo " ./developer_scripts/gcc-trunk-install.sh [-p <patch-file-name>] [-i <installation-path>]"
19+ echo " ./developer_scripts/gcc-trunk-install.sh [-p <patch-file-name>] [-r <installation-path>]"
2020 echo " "
2121 echo " Square brackets surround optional arguments."
2222 exit 0
2323}
2424[[ " ${1:- } " == " -h" || " ${1:- } " == " --help" || ! -f src/libcaf.h ]] && usage
2525
26- if [[ " ${1:- } " == " -i " || " ${1:- } " == " --install-prefix " ]]; then
27- export install_prefix =" ${2} "
28- if [[ " ${3:- } " == " -i " || " ${3:- } " == " --install-prefix " ]]; then
26+ if [[ " ${1:- } " == " -r " || " ${1:- } " == " --packages-root " ]]; then
27+ export packages_root =" ${2} "
28+ if [[ " ${3:- } " == " -r " || " ${3:- } " == " --packages-root " ]]; then
2929 export patch_file=" ${4} "
3030 fi
3131elif [[ " ${1:- } " == " -p" || " ${1:- } " == " --patch-file" ]]; then
3232 export patch_file=" ${2:- } "
33- if [[ " ${3:- } " == " -i " || " ${3:- } " == " --install-prefix " ]]; then
34- export install_prefix =" ${4} "
33+ if [[ " ${3:- } " == " -r " || " ${3:- } " == " --packages-root " ]]; then
34+ export packages_root =" ${4} "
3535 fi
3636fi
3737export default_prefix=" ${HOME} /opt"
38- export install_prefix =" ${install_prefix :- ${default_prefix} } "
38+ export packages_root =" ${packages_root :- ${default_prefix} } "
3939
4040function set_absolute_path()
4141{
@@ -146,10 +146,13 @@ if [[ ! -z "${absolute_path:-}" ]]; then
146146 pushd prerequisites/downloads/trunk
147147 patch -p0 < " ${absolute_path} "
148148 popd
149+ export patched=" patched"
149150fi
150151
151- export GCC_install_prefix=${install_prefix} /gnu/trunk
152+
153+ export GCC_install_prefix=${packages_root} /gnu/trunk
152154# Build the patched GCC trunk
155+
153156echo " Rebuilding the patched GCC source."
154157./install.sh \
155158 --package gcc \
@@ -166,34 +169,33 @@ if ! type "${GCC_install_prefix}"/bin/gfortran >& /dev/null; then
166169fi
167170
168171# Ensure that the just-installed GCC libraries are used when linking
169- echo " Setting and exporting LD_LIBRARY_PATH"
172+ echo " Setting and exporting PATH and LD_LIBRARY_PATH"
173+
174+ function prepend() {
170175
171- function prepend_to_LD_LIBRARY_PATH() {
172- : ${1?' set_LD_LIBRARY_PATH: missing path' }
173- new_path=" ${1} "
174- if [[ -z " ${LD_LIBRARY_PATH:- } " ]]; then
175- export LD_LIBRARY_PATH=" ${new_path} "
176+ : " ${1?' prepend(): missing prefix' } "
177+ : " ${2?' prepend(): missing environment variable name' } "
178+
179+ new_prefix=" $1 "
180+ export env_var_name=" $2 "
181+ eval env_var_val=" \$ $2 "
182+ if [[ -z $env_var_val ]]; then
183+ export $env_var_name =" $new_prefix "
176184 else
177- export LD_LIBRARY_PATH =" ${new_path} : ${LD_LIBRARY_PATH} "
185+ export $env_var_name =" ${new_prefix} " : $env_var_val
178186 fi
179187}
180188
181- old_path=" ${LD_LIBRARY_PATH:- } "
182-
183- if [[ -d " ${GCC_install_prefix} /lib64" ]]; then
184- prepend_to_LD_LIBRARY_PATH " ${GCC_install_prefix} /lib64/"
189+ if type " ${GCC_install_prefix} " /bin/gfortran; then
190+ prepend " ${GCC_install_prefix} /bin/" PATH
191+ prepend " ${GCC_install_prefix} /lib64/" LD_LIBRARY_PATH
192+ else
193+ echo " GCC is not installed in the expected location ${GCC_install_prefix} "
185194fi
186195
187- echo " \$ {LD_LIBRARY_PATH}=${LD_LIBRARY_PATH:= } "
196+ echo " Building MPICH with the ${patched:- } compilers."
197+ export mpich_install_prefix=" ${packages_root} /mpich/3.2/gnu/trunk"
188198
189- if [[ " ${LD_LIBRARY_PATH} " == " ${old_path} " ]]; then
190- echo " gfortran libraries did not install where expected: ${GCC_install_prefix} /lib64 or ${GCC_install_prefix} /lib"
191- exit 1
192- fi
193-
194- # Build MPICH with the patched compilers.
195- echo " Building MPICH with the patched compilers."
196- export mpich_install_prefix=" ${install_prefix} /mpich/3.2/gnu/trunk"
197199./install.sh \
198200 --package mpich \
199201 --num-threads 4 \
@@ -204,21 +206,31 @@ export mpich_install_prefix="${install_prefix}/mpich/3.2/gnu/trunk"
204206 --install-prefix " ${mpich_install_prefix} "
205207
206208# Verify that MPICH installed where expected
207- if ! type " ${mpich_install_prefix} " /bin/mpifort; then
209+ if type " ${mpich_install_prefix} " /bin/mpifort; then
210+ prepend " ${mpich_install_prefix} /bin/" PATH
211+ else
208212 echo " MPICH is not installed in the expected location ${mpich_install_prefix} ."
209213 exit 1
210214fi
211215
212- # Build OpenCoarrays with the patched compilers and the just-built MPICH
216+ # Build OpenCoarrays with the just-built compilers and the just-built MPICH
213217echo " Building OpenCoarrays."
214- export opencoarrays_version=$( ./install.sh --version)
218+ export opencoarrays_version=$( ./install.sh -V opencoarrays)
219+ export opencoarrays_install_prefix=" ${packages_root} /opencoarrays/${opencoarrays_version} /gnu/trunk"
220+
215221./install.sh \
216- --package opencoarrays \
217- --disable-bootstrap \
218222 --num-threads 4 \
219223 --yes-to-all \
220- --with-fortran " ${GCC_install_prefix} /bin/gfortran" \
221- --with-c " ${GCC_install_prefix} /bin/gcc" \
222- --with-cxx " ${GCC_install_prefix} /bin/g++" \
223- --with-mpi " ${mpich_install_prefix} " \
224- --install-prefix " ${install_prefix} /opencoarrays/${opencoarrays_version} /gnu/trunk"
224+ --with-mpi " $mpich_install_prefix " \
225+ --install-prefix " $opencoarrays_install_prefix "
226+
227+ # Verify that OpenCoarrays installed where expected
228+ if type " ${opencoarrays_install_prefix:- } " /bin/caf >& /dev/null; then
229+ echo " "
230+ echo " OpenCoarrays is in $opencoarrays_install_prefix "
231+ echo " To set up your environment for using OpenCoarrays, execute the following command:"
232+ echo " source ${opencoarrays_install_prefix} /setup.sh"
233+ else
234+ echo " OpenCoarrays is not in the expected location: ${opencoarrays_install_prefix:- " (no expected location found)" } ."
235+ exit 1
236+ fi
0 commit comments