8080# (4) Parse the command line using the usage information.
8181
8282# ## Start of boilerplate -- do not edit this block #######################
83- export OPENCOARRAYS_SRC_DIR=" ${OPENCOARRAYS_SRC_DIR:- ${PWD} } "
83+ export OPENCOARRAYS_SRC_DIR=" ${OPENCOARRAYS_SRC_DIR:- ${PWD%/ } } "
8484if [[ ! -f " ${OPENCOARRAYS_SRC_DIR} /src/libcaf.h" ]]; then
8585 echo " Please run this script inside the top-level OpenCoarrays source directory or "
8686 echo " set OPENCOARRAYS_SRC_DIR to the OpenCoarrays source directory path."
@@ -149,7 +149,7 @@ info "-D (--print-downloader): ${arg_D}"
149149info " -e (--verbose): ${arg_e} "
150150info " -f (--with-fortran): ${arg_f} "
151151info " -h (--help): ${arg_h} "
152- info " -i (--install-dir): ${arg_i} "
152+ info " -i (--install-prefix): ${arg_i} "
153153info " -I (--install-version): ${arg_I} "
154154info " -j (--num-threads): ${arg_j} "
155155info " -l (--list-packages): ${arg_l} "
@@ -188,21 +188,20 @@ info "-V (--print-version): ${arg_V}"
188188this_script=" $( basename " $0 " ) "
189189export this_script
190190
191- export install_path=" ${arg_i} "
192- info " install_path=${arg_i} "
191+ export install_path=" ${arg_i%/ } "
192+ info " install_path=\" ${install_path} \" "
193193
194194export num_threads=" ${arg_j} "
195- info " num_threads=${arg_j} "
195+ info " num_threads=\" ${arg_j} \" "
196196
197197export opencoarrays_src_dir=" ${OPENCOARRAYS_SRC_DIR} "
198198info " opencoarrays_src_dir=${OPENCOARRAYS_SRC_DIR} "
199199
200- export build_path=$opencoarrays_src_dir /prerequisites/builds
201- info " build_path=$opencoarrays_src_dir /prerequisites/builds"
202-
203- export build_script=$opencoarrays_src_dir /prerequisites/build.sh
204- info " build_script=$opencoarrays_src_dir /prerequisites/build.sh"
200+ export build_path=" ${opencoarrays_src_dir} " /prerequisites/builds
201+ info " build_path=\" ${opencoarrays_src_dir} \" /prerequisites/builds"
205202
203+ export build_script=" ${opencoarrays_src_dir} " /prerequisites/build.sh
204+ info " build_script=\" ${opencoarrays_src_dir} \" /prerequisites/build.sh"
206205
207206# ___________________ Define functions for use in the Main Body ___________________
208207
@@ -214,12 +213,16 @@ stack_new dependency_pkg
214213stack_new dependency_exe
215214stack_new dependency_path
216215stack_new script_installed
216+
217217# shellcheck source=./prerequisites/install-functions/find_or_install.sh
218218source $opencoarrays_src_dir /prerequisites/install-functions/find_or_install.sh
219+
219220# shellcheck source=./prerequisites/install-functions/print_header.sh
220221source $opencoarrays_src_dir /prerequisites/install-functions/print_header.sh
222+
221223# shellcheck source=./prerequisites/install-functions/build_opencoarrays.sh
222224source $opencoarrays_src_dir /prerequisites/install-functions/build_opencoarrays.sh
225+
223226# shellcheck source=./prerequisites/install-functions/report_results.sh
224227source $opencoarrays_src_dir /prerequisites/install-functions/report_results.sh
225228
@@ -232,7 +235,7 @@ source $opencoarrays_src_dir/prerequisites/install-functions/report_results.sh
232235if [[ " ${arg_v} " == " ${__flag_present} " || " ${arg_V} " == " opencoarrays" ]]; then
233236
234237 # Print script copyright if invoked with -v, -V, or --version argument
235- cmake_project_line=$( grep project CMakeLists.txt | grep VERSION)
238+ cmake_project_line=$( grep project ${opencoarrays_src_dir} / CMakeLists.txt | grep VERSION)
236239 text_after_version_keyword=" ${cmake_project_line##* VERSION} "
237240 text_before_language_keyword=" ${text_after_version_keyword%% LANGUAGES* } "
238241 opencoarrays_version=$text_before_language_keyword
@@ -249,7 +252,7 @@ if [[ "${arg_v}" == "${__flag_present}" || "${arg_V}" == "opencoarrays" ]]; then
249252 echo " http://www.sourceryinstitute.org/license.html"
250253 echo " "
251254 elif [[ " ${arg_V} " == " opencoarrays" ]]; then
252- echo " ${opencoarrays_version} "
255+ echo " ${opencoarrays_version// [[:space:]] / } "
253256 fi
254257
255258elif [[ ! -z " ${arg_D:- ${arg_P:- ${arg_U:- ${arg_V} } } } " || " ${arg_l} " == " ${__flag_present} " ]]; then
@@ -261,29 +264,48 @@ elif [[ ! -z "${arg_D:-${arg_P:-${arg_U:-${arg_V}}}}" || "${arg_l}" == "${__fla
261264 [ ! -z " ${arg_U} " ] && build_flag=" -U"
262265 [ ! -z " ${arg_V} " ] && build_flag=" -V"
263266 [ " ${arg_l} " == " ${__flag_present} " ] && build_flag=" -l"
264- " ${opencoarrays_src_dir} " /prerequisites/build.sh " ${build_flag} " " ${build_arg} "
265- # Add lines other packages the current script builds
266- if [[ " ${arg_l} " == " ${__flag_present} " ]]; then
267- echo " opencoarrays (version $( " ${opencoarrays_src_dir} /install.sh" -V opencoarrays) )"
268- echo " ofp (version: ofp-sdf for OS X )"
267+
268+ if [[ " ${arg_P} " == " opencoarrays" ]]; then
269+
270+ version=" $( " ${opencoarrays_src_dir} /install.sh" -V opencoarrays) "
271+ echo " ${install_path%/ } /opencoarrays/${version} "
272+
273+ else
274+
275+ info " Invoking build script with the following command:"
276+ info " \" ${opencoarrays_src_dir} \" /prerequisites/build.sh \" ${build_flag} \" \" ${build_arg} \" "
277+ " ${opencoarrays_src_dir} " /prerequisites/build.sh " ${build_flag} " " ${build_arg} "
278+
279+ # Add lines other packages the current script builds
280+ if [[ " ${arg_l} " == " ${__flag_present} " ]]; then
281+ echo " opencoarrays (version $( " ${opencoarrays_src_dir} /install.sh" -V opencoarrays) )"
282+ echo " ofp (version: ofp-sdf for OS X )"
283+ fi
269284 fi
270285
271286elif [[ " ${arg_p:- } " == " opencoarrays" ]]; then
272287
288+
273289 cd prerequisites || exit 1
274290 installation_record=install-opencoarrays.log
275291 # shellcheck source=./prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh
276292 source " ${OPENCOARRAYS_SRC_DIR:- } /prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh"
293+ version=" $( " ${opencoarrays_src_dir} /install.sh" -V opencoarrays) "
294+ install_path=" ${install_path} /opencoarrays/${version} "
277295 set_SUDO_if_needed_to_write_to_directory " ${install_path} "
278296 build_opencoarrays 2>&1 | tee ../" ${installation_record} "
279297 report_results 2>&1 | tee -a ../" ${installation_record} "
280298
281299elif [[ " ${arg_p:- } " == " ofp" ]]; then
282300
301+ info " Invoking Open Fortran Parser build script with the following command:"
302+ info " \" ${opencoarrays_src_dir} \" /prerequisites/install-ofp.sh"
283303 " ${opencoarrays_src_dir} " /prerequisites/install-ofp.sh
284304
285305elif [[ ! -z " ${arg_p:- } " ]]; then
286306
307+ info " Invoking build script with the following command:"
308+ info " \" ${opencoarrays_src_dir} \" /prerequisites/build.sh ${@:- } "
287309 " ${opencoarrays_src_dir} " /prerequisites/build.sh ${@:- }
288310
289311fi
0 commit comments