missing revision d21ab8bc
11f0ac6a5Smrg#! /bin/sh
289c04b6cSmrg# Common wrapper for a few potentially missing GNU programs.
31f0ac6a5Smrg
4d21ab8bcSmrgscriptversion=2018-03-07.03; # UTC
51f0ac6a5Smrg
6d21ab8bcSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc.
789c04b6cSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
81f0ac6a5Smrg
91f0ac6a5Smrg# This program is free software; you can redistribute it and/or modify
101f0ac6a5Smrg# it under the terms of the GNU General Public License as published by
111f0ac6a5Smrg# the Free Software Foundation; either version 2, or (at your option)
121f0ac6a5Smrg# any later version.
131f0ac6a5Smrg
141f0ac6a5Smrg# This program is distributed in the hope that it will be useful,
151f0ac6a5Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
161f0ac6a5Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
171f0ac6a5Smrg# GNU General Public License for more details.
181f0ac6a5Smrg
191f0ac6a5Smrg# You should have received a copy of the GNU General Public License
20d21ab8bcSmrg# along with this program.  If not, see <https://www.gnu.org/licenses/>.
211f0ac6a5Smrg
221f0ac6a5Smrg# As a special exception to the GNU General Public License, if you
231f0ac6a5Smrg# distribute this file as part of a program that contains a
241f0ac6a5Smrg# configuration script generated by Autoconf, you may include it under
251f0ac6a5Smrg# the same distribution terms that you use for the rest of that program.
261f0ac6a5Smrg
271f0ac6a5Smrgif test $# -eq 0; then
2889c04b6cSmrg  echo 1>&2 "Try '$0 --help' for more information"
291f0ac6a5Smrg  exit 1
301f0ac6a5Smrgfi
311f0ac6a5Smrg
3289c04b6cSmrgcase $1 in
331f0ac6a5Smrg
3489c04b6cSmrg  --is-lightweight)
3589c04b6cSmrg    # Used by our autoconf macros to check whether the available missing
3689c04b6cSmrg    # script is modern enough.
3789c04b6cSmrg    exit 0
3889c04b6cSmrg    ;;
391f0ac6a5Smrg
4089c04b6cSmrg  --run)
4189c04b6cSmrg    # Back-compat with the calling convention used by older automake.
4289c04b6cSmrg    shift
4389c04b6cSmrg    ;;
441f0ac6a5Smrg
451f0ac6a5Smrg  -h|--h|--he|--hel|--help)
461f0ac6a5Smrg    echo "\
471f0ac6a5Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
481f0ac6a5Smrg
4989c04b6cSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
5089c04b6cSmrgto PROGRAM being missing or too old.
511f0ac6a5Smrg
521f0ac6a5SmrgOptions:
531f0ac6a5Smrg  -h, --help      display this help and exit
541f0ac6a5Smrg  -v, --version   output version information and exit
551f0ac6a5Smrg
561f0ac6a5SmrgSupported PROGRAM values:
5789c04b6cSmrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
5889c04b6cSmrg  bison     yacc      flex         lex       help2man
591f0ac6a5Smrg
6089c04b6cSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
6189c04b6cSmrg'g' are ignored when checking the name.
62e5410a46Smrg
631f0ac6a5SmrgSend bug reports to <bug-automake@gnu.org>."
641f0ac6a5Smrg    exit $?
651f0ac6a5Smrg    ;;
661f0ac6a5Smrg
671f0ac6a5Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
681f0ac6a5Smrg    echo "missing $scriptversion (GNU Automake)"
691f0ac6a5Smrg    exit $?
701f0ac6a5Smrg    ;;
711f0ac6a5Smrg
721f0ac6a5Smrg  -*)
7389c04b6cSmrg    echo 1>&2 "$0: unknown '$1' option"
7489c04b6cSmrg    echo 1>&2 "Try '$0 --help' for more information"
751f0ac6a5Smrg    exit 1
761f0ac6a5Smrg    ;;
771f0ac6a5Smrg
781f0ac6a5Smrgesac
791f0ac6a5Smrg
8089c04b6cSmrg# Run the given program, remember its exit status.
8189c04b6cSmrg"$@"; st=$?
8289c04b6cSmrg
8389c04b6cSmrg# If it succeeded, we are done.
8489c04b6cSmrgtest $st -eq 0 && exit 0
8589c04b6cSmrg
8689c04b6cSmrg# Also exit now if we it failed (or wasn't found), and '--version' was
8789c04b6cSmrg# passed; such an option is passed most likely to detect whether the
8889c04b6cSmrg# program is present and works.
8989c04b6cSmrgcase $2 in --version|--help) exit $st;; esac
9089c04b6cSmrg
9189c04b6cSmrg# Exit code 63 means version mismatch.  This often happens when the user
9289c04b6cSmrg# tries to use an ancient version of a tool on a file that requires a
9389c04b6cSmrg# minimum version.
9489c04b6cSmrgif test $st -eq 63; then
9589c04b6cSmrg  msg="probably too old"
9689c04b6cSmrgelif test $st -eq 127; then
9789c04b6cSmrg  # Program was missing.
9889c04b6cSmrg  msg="missing on your system"
9989c04b6cSmrgelse
10089c04b6cSmrg  # Program was found and executed, but failed.  Give up.
10189c04b6cSmrg  exit $st
10289c04b6cSmrgfi
1031f0ac6a5Smrg
104d21ab8bcSmrgperl_URL=https://www.perl.org/
105d21ab8bcSmrgflex_URL=https://github.com/westes/flex
106d21ab8bcSmrggnu_software_URL=https://www.gnu.org/software
10789c04b6cSmrg
10889c04b6cSmrgprogram_details ()
10989c04b6cSmrg{
11089c04b6cSmrg  case $1 in
11189c04b6cSmrg    aclocal|automake)
11289c04b6cSmrg      echo "The '$1' program is part of the GNU Automake package:"
11389c04b6cSmrg      echo "<$gnu_software_URL/automake>"
11489c04b6cSmrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
11589c04b6cSmrg      echo "<$gnu_software_URL/autoconf>"
11689c04b6cSmrg      echo "<$gnu_software_URL/m4/>"
11789c04b6cSmrg      echo "<$perl_URL>"
11889c04b6cSmrg      ;;
11989c04b6cSmrg    autoconf|autom4te|autoheader)
12089c04b6cSmrg      echo "The '$1' program is part of the GNU Autoconf package:"
12189c04b6cSmrg      echo "<$gnu_software_URL/autoconf/>"
12289c04b6cSmrg      echo "It also requires GNU m4 and Perl in order to run:"
12389c04b6cSmrg      echo "<$gnu_software_URL/m4/>"
12489c04b6cSmrg      echo "<$perl_URL>"
12589c04b6cSmrg      ;;
12689c04b6cSmrg  esac
12789c04b6cSmrg}
12889c04b6cSmrg
12989c04b6cSmrggive_advice ()
13089c04b6cSmrg{
13189c04b6cSmrg  # Normalize program name to check for.
13289c04b6cSmrg  normalized_program=`echo "$1" | sed '
13389c04b6cSmrg    s/^gnu-//; t
13489c04b6cSmrg    s/^gnu//; t
13589c04b6cSmrg    s/^g//; t'`
13689c04b6cSmrg
13789c04b6cSmrg  printf '%s\n' "'$1' is $msg."
13889c04b6cSmrg
13989c04b6cSmrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
14089c04b6cSmrg  case $normalized_program in
14189c04b6cSmrg    autoconf*)
14289c04b6cSmrg      echo "You should only need it if you modified 'configure.ac',"
14389c04b6cSmrg      echo "or m4 files included by it."
14489c04b6cSmrg      program_details 'autoconf'
14589c04b6cSmrg      ;;
14689c04b6cSmrg    autoheader*)
14789c04b6cSmrg      echo "You should only need it if you modified 'acconfig.h' or"
14889c04b6cSmrg      echo "$configure_deps."
14989c04b6cSmrg      program_details 'autoheader'
15089c04b6cSmrg      ;;
15189c04b6cSmrg    automake*)
15289c04b6cSmrg      echo "You should only need it if you modified 'Makefile.am' or"
15389c04b6cSmrg      echo "$configure_deps."
15489c04b6cSmrg      program_details 'automake'
15589c04b6cSmrg      ;;
15689c04b6cSmrg    aclocal*)
15789c04b6cSmrg      echo "You should only need it if you modified 'acinclude.m4' or"
15889c04b6cSmrg      echo "$configure_deps."
15989c04b6cSmrg      program_details 'aclocal'
16089c04b6cSmrg      ;;
16189c04b6cSmrg   autom4te*)
16289c04b6cSmrg      echo "You might have modified some maintainer files that require"
163b9867631Smrg      echo "the 'autom4te' program to be rebuilt."
16489c04b6cSmrg      program_details 'autom4te'
16589c04b6cSmrg      ;;
16689c04b6cSmrg    bison*|yacc*)
16789c04b6cSmrg      echo "You should only need it if you modified a '.y' file."
16889c04b6cSmrg      echo "You may want to install the GNU Bison package:"
16989c04b6cSmrg      echo "<$gnu_software_URL/bison/>"
17089c04b6cSmrg      ;;
17189c04b6cSmrg    lex*|flex*)
17289c04b6cSmrg      echo "You should only need it if you modified a '.l' file."
17389c04b6cSmrg      echo "You may want to install the Fast Lexical Analyzer package:"
17489c04b6cSmrg      echo "<$flex_URL>"
17589c04b6cSmrg      ;;
17689c04b6cSmrg    help2man*)
17789c04b6cSmrg      echo "You should only need it if you modified a dependency" \
17889c04b6cSmrg           "of a man page."
17989c04b6cSmrg      echo "You may want to install the GNU Help2man package:"
18089c04b6cSmrg      echo "<$gnu_software_URL/help2man/>"
18189c04b6cSmrg    ;;
18289c04b6cSmrg    makeinfo*)
18389c04b6cSmrg      echo "You should only need it if you modified a '.texi' file, or"
18489c04b6cSmrg      echo "any other file indirectly affecting the aspect of the manual."
18589c04b6cSmrg      echo "You might want to install the Texinfo package:"
18689c04b6cSmrg      echo "<$gnu_software_URL/texinfo/>"
18789c04b6cSmrg      echo "The spurious makeinfo call might also be the consequence of"
18889c04b6cSmrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
18989c04b6cSmrg      echo "want to install GNU make:"
19089c04b6cSmrg      echo "<$gnu_software_URL/make/>"
19189c04b6cSmrg      ;;
19289c04b6cSmrg    *)
19389c04b6cSmrg      echo "You might have modified some files without having the proper"
19489c04b6cSmrg      echo "tools for further handling them.  Check the 'README' file, it"
19589c04b6cSmrg      echo "often tells you about the needed prerequisites for installing"
19689c04b6cSmrg      echo "this package.  You may also peek at any GNU archive site, in"
19789c04b6cSmrg      echo "case some other package contains this missing '$1' program."
19889c04b6cSmrg      ;;
19989c04b6cSmrg  esac
20089c04b6cSmrg}
20189c04b6cSmrg
20289c04b6cSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
20389c04b6cSmrg                       -e '2,$s/^/         /' >&2
20489c04b6cSmrg
20589c04b6cSmrg# Propagate the correct exit status (expected to be 127 for a program
20689c04b6cSmrg# not found, 63 for a program that failed due to version mismatch).
20789c04b6cSmrgexit $st
2081f0ac6a5Smrg
2091f0ac6a5Smrg# Local variables:
210d21ab8bcSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
2111f0ac6a5Smrg# time-stamp-start: "scriptversion="
2121f0ac6a5Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
213d21ab8bcSmrg# time-stamp-time-zone: "UTC0"
214e5410a46Smrg# time-stamp-end: "; # UTC"
2151f0ac6a5Smrg# End:
216