55# -- This script installs OpenCoarrays and its prerequisites.
66#
77# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
8- # Copyright (c) 2015, Sourcery, Inc.
9- # Copyright (c) 2015, Sourcery Institute
8+ # Copyright (c) 2015-2016 , Sourcery, Inc.
9+ # Copyright (c) 2015-2016 , Sourcery Institute
1010# All rights reserved.
1111#
1212# Redistribution and use in source and binary forms, with or without modification,
@@ -141,6 +141,7 @@ find_or_install()
141141 " mpich:mpif90"
142142 " flex:flex"
143143 " bison:yacc"
144+ " m4:m4"
144145 " _unknown:0"
145146 )
146147 for element in " ${package_executable_array[@]} " ; do
@@ -206,7 +207,7 @@ find_or_install()
206207 elif [[ " $package_in_path " == " true" ]]; then
207208 printf " $this_script : Checking whether $package in PATH is version < $minimum_version ... "
208209
209- if [[ " $package_version_in_path " < " $executable version $minimum_version " ]] ; then
210+ if ! ./check_version.sh $package ` ./build $package --default --query-version ` ; then
210211 printf " yes.\n"
211212 # Here we place $package on the dependency stack to trigger the build of the above file:
212213 stack_push dependency_pkg $package " none"
@@ -264,7 +265,7 @@ find_or_install()
264265 stack_push dependency_path " none" ` ./build $package --default --query-path` ` ./build gcc --default --query-path`
265266 else
266267 printf " yes.\n"
267- printf " $this_script : Checking whether $executable in PATH wraps gfortran version 5.1 .0 or later... "
268+ printf " $this_script : Checking whether $executable in PATH wraps gfortran version 5.3 .0 or later... "
268269 $executable acceptable_compiler.f90 -o acceptable_compiler
269270 $executable print_true.f90 -o print_true
270271 acceptable=` ./acceptable_compiler`
@@ -331,7 +332,7 @@ find_or_install()
331332 stack_push dependency_path " none"
332333
333334 elif [[ " $package_in_path " == " true" ]]; then
334- printf " $this_script : Checking whether $executable in PATH is version 5.1 .0 or later..."
335+ printf " $this_script : Checking whether $executable in PATH is version 5.3 .0 or later..."
335336 $executable -o acceptable_compiler acceptable_compiler.f90
336337 $executable -o print_true print_true.f90
337338 is_true=` ./print_true`
@@ -399,22 +400,28 @@ find_or_install()
399400 elif [[ " $package_in_path " == " true" ]]; then
400401
401402 printf " $this_script : Checking whether $package in PATH is version < $minimum_version ... "
402- if [[ " $package_version_in_path " < " $executable $minimum_version " ]] ; then
403+ if ! ./check_version.sh $package ` ./build $package --default --query-version ` ; then
403404 printf " yes\n"
404405
405406 export FLEX=" $package_install_path /bin/$executable "
406407 # Trigger 'find_or_install bison' and subsequent build of $package
407408 stack_push dependency_pkg " bison"
408409 stack_push dependency_exe " yacc"
409410 stack_push dependency_path ` ./build bison --default --query-path`
410-
411411 else
412412 printf " no.\n"
413413 printf " $this_script : Using the $executable found in the PATH.\n"
414414 export FLEX=$executable
415415 stack_push acceptable_in_path $package $executable
416- # Halt the recursion by removing flex from the dependency stack and indicating
417- # that none of the prerequisites required to build flex are needed.
416+ # Remove $package from the dependency stack
417+ stack_pop dependency_pkg package_done
418+ stack_pop dependency_exe executable_done
419+ stack_pop dependency_path package_done_path
420+ # Put $package onto the script_installed log
421+ stack_push script_installed package_done
422+ stack_push script_installed executable_done
423+ stack_push script_installed package_done_path
424+ # Halt the recursion and signal that none of $package's prerequisites need to be built
418425 stack_push dependency_pkg " none"
419426 stack_push dependency_exe " none"
420427 stack_push dependency_path " none"
@@ -453,19 +460,78 @@ find_or_install()
453460
454461 elif [[ " $package_in_path " == " true" ]]; then
455462 printf " $this_script : Checking whether $package executable $executable in PATH is version < $minimum_version ... "
456- if [[ " $package_version_in_path " < " $package (GNU Bison) $minimum_version " ]] ; then
463+ if ! ./check_version.sh $package ` ./build $package --default --query-version ` ; then
457464 printf " yes.\n"
458- export YACC=" $package_install_path /bin/yacc"
465+ export YACC=" $package_install_path /bin/$executable "
466+ # Trigger 'find_or_install m4' and subsequent build of $package
467+ stack_push dependency_pkg " m4"
468+ stack_push dependency_exe " m4"
469+ stack_push dependency_path ` ./build m4 --default --query-path`
470+ else
471+ printf " no.\n"
472+ printf " $this_script : Using the $package executable $executable found in the PATH.\n"
473+ YACC=yacc
474+ stack_push acceptable_in_path $package $executable
475+ # Remove bison from the dependency stack
476+ stack_pop dependency_pkg package_done
477+ stack_pop dependency_exe executable_done
478+ stack_pop dependency_path package_done_path
479+ # Put $package onto the script_installed log
480+ stack_push script_installed package_done
481+ stack_push script_installed executable_done
482+ stack_push script_installed package_done_path
483+ # Halt the recursion and signal that there are no prerequisites to build
484+ stack_push dependency_pkg " none"
485+ stack_push dependency_exe " none"
486+ stack_push dependency_path " none"
487+ fi
488+
489+ else # $package not in PATH and not yet installed by this script
490+ # Trigger 'find_or_install m4' and subsequent build of $package
491+ stack_push dependency_pkg " m4"
492+ stack_push dependency_exe " m4"
493+ stack_push dependency_path ` ./build m4 --default --query-path`
494+ fi
495+
496+ elif [[ $package == " m4" ]]; then
497+
498+ # We arrive when the 'elif [[ $package == "bison" ]]' block pushes "m4" onto the
499+ # the dependency_pkg stack, resulting in the recursive call 'find_or_install m4'
500+
501+ # Every branch that discovers an acceptable pre-existing installation must set the
502+ # M4 environment variable. Every branch must also manage the dependency stack.
503+
504+ if [[ " $script_installed_package " == true ]]; then
505+ printf " $this_script : Using the $package executable $executable installed by $this_script \n"
506+ export M4=$package_install_path /bin/m4
507+ # Remove m4 from the dependency stack
508+ stack_pop dependency_pkg package_done
509+ stack_pop dependency_exe executable_done
510+ stack_pop dependency_path package_done_path
511+ # Put $package onto the script_installed log
512+ stack_push script_installed package_done
513+ stack_push script_installed executable_done
514+ stack_push script_installed package_done_path
515+ # Halt the recursion and signal that there are no prerequisites to build
516+ stack_push dependency_pkg " none"
517+ stack_push dependency_exe " none"
518+ stack_push dependency_path " none"
519+
520+ elif [[ " $package_in_path " == " true" ]]; then
521+ printf " $this_script : Checking whether $package executable $executable in PATH is version < $minimum_version ... "
522+ if ! ./check_version.sh $package ` ./build $package --default --query-version` ; then
523+ printf " yes.\n"
524+ export M4=" $package_install_path /bin/m4"
459525 # Halt the recursion and signal that there are no prerequisites to build
460526 stack_push dependency_pkg " none"
461527 stack_push dependency_exe " none"
462528 stack_push dependency_path " none"
463529 else
464530 printf " no.\n"
465531 printf " $this_script : Using the $package executable $executable found in the PATH.\n"
466- YACC=yacc
532+ M4=m4
467533 stack_push acceptable_in_path $package $executable
468- # Remove bison from the dependency stack
534+ # Remove m4 from the dependency stack
469535 stack_pop dependency_pkg package_done
470536 stack_pop dependency_exe executable_done
471537 stack_pop dependency_path package_done_path
@@ -481,7 +547,7 @@ find_or_install()
481547
482548 else # $package not in PATH and not yet installed by this script
483549 # Halt the recursion and signal that there are no prerequisites to build
484- export YACC =" $package_install_path /bin/yacc "
550+ export M4 =" $package_install_path /bin/m4 "
485551 stack_push dependency_pkg " none"
486552 stack_push dependency_exe " none"
487553 stack_push dependency_path " none"
@@ -599,6 +665,9 @@ find_or_install()
599665 elif [[ $package == " flex" ]]; then
600666 echo " $this_script : export FLEX=$package_install_path /bin/$executable "
601667 export FLEX=" $package_install_path /bin/$executable "
668+ elif [[ $package == " m4" ]]; then
669+ echo " $this_script : export M4=$package_install_path /bin/$executable "
670+ export M4=" $package_install_path /bin/$executable "
602671 elif [[ $package == " gcc" ]]; then
603672 echo " $this_script : export FC=$package_install_path /bin/gfortran"
604673 export FC=" $package_install_path /bin/gfortran"
@@ -652,7 +721,7 @@ print_header()
652721 clear
653722 echo " "
654723 echo " *** A default build of OpenCoarrays requires CMake 3.4.0 or later ***"
655- echo " *** and MPICH 3.1.4 wrapping GCC Fortran (gfortran) 5.1 .0 or later. ***"
724+ echo " *** and MPICH 3.1.4 wrapping GCC Fortran (gfortran) 5.3 .0 or later. ***"
656725 echo " *** Additionally, CMake, MPICH, and GCC have their own prerequisites. ***"
657726 echo " *** This script will check for most known requirements in your PATH ***"
658727 echo " *** environment variable and in the default installation directory ***"
@@ -783,6 +852,14 @@ report_results()
783852 echo " export PATH=\" $bison_install_path /bin\" :\$ PATH " >> setup.sh
784853 echo " fi " >> setup.sh
785854 fi
855+ m4_install_path=` ./build m4 --default --query-path`
856+ if [[ -x " $m4_install_path /bin/yacc" ]]; then
857+ echo " if [[ -z \"\$ PATH\" ]]; then " >> setup.sh
858+ echo " export PATH=\" $m4_install_path /bin\" " >> setup.sh
859+ echo " else " >> setup.sh
860+ echo " export PATH=\" $m4_install_path /bin\" :\$ PATH " >> setup.sh
861+ echo " fi " >> setup.sh
862+ fi
786863 setup_sh_location=$install_path
787864 $SUDO mv setup.sh $install_path || setup_sh_location=${PWD}
788865 echo " *** Before using caf, cafrun, or build, please execute the following command ***"
@@ -828,8 +905,8 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
828905 echo " opencoarrays $opencoarrays_version "
829906 echo " "
830907 echo " OpenCoarrays installer"
831- echo " Copyright (C) 2015 Sourcery, Inc."
832- echo " Copyright (C) 2015 Sourcery Institute"
908+ echo " Copyright (C) 2015-2016 Sourcery, Inc."
909+ echo " Copyright (C) 2015-2016 Sourcery Institute"
833910 echo " "
834911 echo " OpenCoarrays comes with NO WARRANTY, to the extent permitted by law."
835912 echo " You may redistribute copies of $this_script under the terms of the"
0 commit comments