@@ -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
@@ -479,9 +480,68 @@ find_or_install()
479480 stack_push dependency_path " none"
480481 fi
481482
483+ else # $package not in PATH and not yet installed by this script
484+ # Trigger 'find_or_install bison' and subsequent build of $package
485+ stack_push dependency_pkg " m4"
486+ stack_push dependency_exe " m4"
487+ stack_push dependency_path ` ./build m4 --default --query-path`
488+ fi
489+
490+ elif [[ $package == " m4" ]]; then
491+
492+ # We arrive when the 'elif [[ $package == "bison" ]]' block pushes "m4" onto the
493+ # the dependency_pkg stack, resulting in the recursive call 'find_or_install m4'
494+
495+ # Every branch that discovers an acceptable pre-existing installation must set the
496+ # M4 environment variable. Every branch must also manage the dependency stack.
497+
498+ if [[ " $script_installed_package " == true ]]; then
499+ printf " $this_script : Using the $package executable $executable installed by $this_script \n"
500+ export M4=$package_install_path /bin/m4
501+ # Remove m4 from the dependency stack
502+ stack_pop dependency_pkg package_done
503+ stack_pop dependency_exe executable_done
504+ stack_pop dependency_path package_done_path
505+ # Put $package onto the script_installed log
506+ stack_push script_installed package_done
507+ stack_push script_installed executable_done
508+ stack_push script_installed package_done_path
509+ # Halt the recursion and signal that there are no prerequisites to build
510+ stack_push dependency_pkg " none"
511+ stack_push dependency_exe " none"
512+ stack_push dependency_path " none"
513+
514+ elif [[ " $package_in_path " == " true" ]]; then
515+ printf " $this_script : Checking whether $package executable $executable in PATH is version < $minimum_version ... "
516+ if [[ " $package_version_in_path " < " $package (GNU Bison) $minimum_version " ]]; then
517+ printf " yes.\n"
518+ export M4=" $package_install_path /bin/m4"
519+ # Halt the recursion and signal that there are no prerequisites to build
520+ stack_push dependency_pkg " none"
521+ stack_push dependency_exe " none"
522+ stack_push dependency_path " none"
523+ else
524+ printf " no.\n"
525+ printf " $this_script : Using the $package executable $executable found in the PATH.\n"
526+ M4=m4
527+ stack_push acceptable_in_path $package $executable
528+ # Remove m4 from the dependency stack
529+ stack_pop dependency_pkg package_done
530+ stack_pop dependency_exe executable_done
531+ stack_pop dependency_path package_done_path
532+ # Put $package onto the script_installed log
533+ stack_push script_installed package_done
534+ stack_push script_installed executable_done
535+ stack_push script_installed package_done_path
536+ # Halt the recursion and signal that there are no prerequisites to build
537+ stack_push dependency_pkg " none"
538+ stack_push dependency_exe " none"
539+ stack_push dependency_path " none"
540+ fi
541+
482542 else # $package not in PATH and not yet installed by this script
483543 # Halt the recursion and signal that there are no prerequisites to build
484- export YACC =" $package_install_path /bin/yacc "
544+ export M4 =" $package_install_path /bin/m4 "
485545 stack_push dependency_pkg " none"
486546 stack_push dependency_exe " none"
487547 stack_push dependency_path " none"
0 commit comments