missing revision d422ce2e
1fc5a983dSmrg#! /bin/sh
26257f37dSmrg# Common wrapper for a few potentially missing GNU programs.
3fc5a983dSmrg
4d422ce2eSmrgscriptversion=2018-03-07.03; # UTC
5fc5a983dSmrg
6d422ce2eSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc.
76257f37dSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8fc5a983dSmrg
9fc5a983dSmrg# This program is free software; you can redistribute it and/or modify
10fc5a983dSmrg# it under the terms of the GNU General Public License as published by
11fc5a983dSmrg# the Free Software Foundation; either version 2, or (at your option)
12fc5a983dSmrg# any later version.
13fc5a983dSmrg
14fc5a983dSmrg# This program is distributed in the hope that it will be useful,
15fc5a983dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16fc5a983dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17fc5a983dSmrg# GNU General Public License for more details.
18fc5a983dSmrg
19fc5a983dSmrg# You should have received a copy of the GNU General Public License
20d422ce2eSmrg# along with this program.  If not, see <https://www.gnu.org/licenses/>.
21fc5a983dSmrg
22fc5a983dSmrg# As a special exception to the GNU General Public License, if you
23fc5a983dSmrg# distribute this file as part of a program that contains a
24fc5a983dSmrg# configuration script generated by Autoconf, you may include it under
25fc5a983dSmrg# the same distribution terms that you use for the rest of that program.
26fc5a983dSmrg
27fc5a983dSmrgif test $# -eq 0; then
286257f37dSmrg  echo 1>&2 "Try '$0 --help' for more information"
29fc5a983dSmrg  exit 1
30fc5a983dSmrgfi
31fc5a983dSmrg
326257f37dSmrgcase $1 in
33fc5a983dSmrg
346257f37dSmrg  --is-lightweight)
356257f37dSmrg    # Used by our autoconf macros to check whether the available missing
366257f37dSmrg    # script is modern enough.
376257f37dSmrg    exit 0
386257f37dSmrg    ;;
39fc5a983dSmrg
406257f37dSmrg  --run)
416257f37dSmrg    # Back-compat with the calling convention used by older automake.
426257f37dSmrg    shift
436257f37dSmrg    ;;
44fc5a983dSmrg
45fc5a983dSmrg  -h|--h|--he|--hel|--help)
46fc5a983dSmrg    echo "\
47fc5a983dSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
48fc5a983dSmrg
496257f37dSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
506257f37dSmrgto PROGRAM being missing or too old.
51fc5a983dSmrg
52fc5a983dSmrgOptions:
53fc5a983dSmrg  -h, --help      display this help and exit
54fc5a983dSmrg  -v, --version   output version information and exit
55fc5a983dSmrg
56fc5a983dSmrgSupported PROGRAM values:
576257f37dSmrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
586257f37dSmrg  bison     yacc      flex         lex       help2man
59fc5a983dSmrg
606257f37dSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
616257f37dSmrg'g' are ignored when checking the name.
62bd304fc0Smrg
63fc5a983dSmrgSend bug reports to <bug-automake@gnu.org>."
64fc5a983dSmrg    exit $?
65fc5a983dSmrg    ;;
66fc5a983dSmrg
67fc5a983dSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68fc5a983dSmrg    echo "missing $scriptversion (GNU Automake)"
69fc5a983dSmrg    exit $?
70fc5a983dSmrg    ;;
71fc5a983dSmrg
72fc5a983dSmrg  -*)
736257f37dSmrg    echo 1>&2 "$0: unknown '$1' option"
746257f37dSmrg    echo 1>&2 "Try '$0 --help' for more information"
75fc5a983dSmrg    exit 1
76fc5a983dSmrg    ;;
77fc5a983dSmrg
78fc5a983dSmrgesac
79fc5a983dSmrg
806257f37dSmrg# Run the given program, remember its exit status.
816257f37dSmrg"$@"; st=$?
826257f37dSmrg
836257f37dSmrg# If it succeeded, we are done.
846257f37dSmrgtest $st -eq 0 && exit 0
856257f37dSmrg
866257f37dSmrg# Also exit now if we it failed (or wasn't found), and '--version' was
876257f37dSmrg# passed; such an option is passed most likely to detect whether the
886257f37dSmrg# program is present and works.
896257f37dSmrgcase $2 in --version|--help) exit $st;; esac
906257f37dSmrg
916257f37dSmrg# Exit code 63 means version mismatch.  This often happens when the user
926257f37dSmrg# tries to use an ancient version of a tool on a file that requires a
936257f37dSmrg# minimum version.
946257f37dSmrgif test $st -eq 63; then
956257f37dSmrg  msg="probably too old"
966257f37dSmrgelif test $st -eq 127; then
976257f37dSmrg  # Program was missing.
986257f37dSmrg  msg="missing on your system"
996257f37dSmrgelse
1006257f37dSmrg  # Program was found and executed, but failed.  Give up.
1016257f37dSmrg  exit $st
1026257f37dSmrgfi
103fc5a983dSmrg
104d422ce2eSmrgperl_URL=https://www.perl.org/
105d422ce2eSmrgflex_URL=https://github.com/westes/flex
106d422ce2eSmrggnu_software_URL=https://www.gnu.org/software
1076257f37dSmrg
1086257f37dSmrgprogram_details ()
1096257f37dSmrg{
1106257f37dSmrg  case $1 in
1116257f37dSmrg    aclocal|automake)
1126257f37dSmrg      echo "The '$1' program is part of the GNU Automake package:"
1136257f37dSmrg      echo "<$gnu_software_URL/automake>"
1146257f37dSmrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1156257f37dSmrg      echo "<$gnu_software_URL/autoconf>"
1166257f37dSmrg      echo "<$gnu_software_URL/m4/>"
1176257f37dSmrg      echo "<$perl_URL>"
1186257f37dSmrg      ;;
1196257f37dSmrg    autoconf|autom4te|autoheader)
1206257f37dSmrg      echo "The '$1' program is part of the GNU Autoconf package:"
1216257f37dSmrg      echo "<$gnu_software_URL/autoconf/>"
1226257f37dSmrg      echo "It also requires GNU m4 and Perl in order to run:"
1236257f37dSmrg      echo "<$gnu_software_URL/m4/>"
1246257f37dSmrg      echo "<$perl_URL>"
1256257f37dSmrg      ;;
1266257f37dSmrg  esac
1276257f37dSmrg}
1286257f37dSmrg
1296257f37dSmrggive_advice ()
1306257f37dSmrg{
1316257f37dSmrg  # Normalize program name to check for.
1326257f37dSmrg  normalized_program=`echo "$1" | sed '
1336257f37dSmrg    s/^gnu-//; t
1346257f37dSmrg    s/^gnu//; t
1356257f37dSmrg    s/^g//; t'`
1366257f37dSmrg
1376257f37dSmrg  printf '%s\n' "'$1' is $msg."
1386257f37dSmrg
1396257f37dSmrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1406257f37dSmrg  case $normalized_program in
1416257f37dSmrg    autoconf*)
1426257f37dSmrg      echo "You should only need it if you modified 'configure.ac',"
1436257f37dSmrg      echo "or m4 files included by it."
1446257f37dSmrg      program_details 'autoconf'
1456257f37dSmrg      ;;
1466257f37dSmrg    autoheader*)
1476257f37dSmrg      echo "You should only need it if you modified 'acconfig.h' or"
1486257f37dSmrg      echo "$configure_deps."
1496257f37dSmrg      program_details 'autoheader'
1506257f37dSmrg      ;;
1516257f37dSmrg    automake*)
1526257f37dSmrg      echo "You should only need it if you modified 'Makefile.am' or"
1536257f37dSmrg      echo "$configure_deps."
1546257f37dSmrg      program_details 'automake'
1556257f37dSmrg      ;;
1566257f37dSmrg    aclocal*)
1576257f37dSmrg      echo "You should only need it if you modified 'acinclude.m4' or"
1586257f37dSmrg      echo "$configure_deps."
1596257f37dSmrg      program_details 'aclocal'
1606257f37dSmrg      ;;
1616257f37dSmrg   autom4te*)
1626257f37dSmrg      echo "You might have modified some maintainer files that require"
1636257f37dSmrg      echo "the 'autom4te' program to be rebuilt."
1646257f37dSmrg      program_details 'autom4te'
1656257f37dSmrg      ;;
1666257f37dSmrg    bison*|yacc*)
1676257f37dSmrg      echo "You should only need it if you modified a '.y' file."
1686257f37dSmrg      echo "You may want to install the GNU Bison package:"
1696257f37dSmrg      echo "<$gnu_software_URL/bison/>"
1706257f37dSmrg      ;;
1716257f37dSmrg    lex*|flex*)
1726257f37dSmrg      echo "You should only need it if you modified a '.l' file."
1736257f37dSmrg      echo "You may want to install the Fast Lexical Analyzer package:"
1746257f37dSmrg      echo "<$flex_URL>"
1756257f37dSmrg      ;;
1766257f37dSmrg    help2man*)
1776257f37dSmrg      echo "You should only need it if you modified a dependency" \
1786257f37dSmrg           "of a man page."
1796257f37dSmrg      echo "You may want to install the GNU Help2man package:"
1806257f37dSmrg      echo "<$gnu_software_URL/help2man/>"
181fc5a983dSmrg    ;;
1826257f37dSmrg    makeinfo*)
1836257f37dSmrg      echo "You should only need it if you modified a '.texi' file, or"
1846257f37dSmrg      echo "any other file indirectly affecting the aspect of the manual."
1856257f37dSmrg      echo "You might want to install the Texinfo package:"
1866257f37dSmrg      echo "<$gnu_software_URL/texinfo/>"
1876257f37dSmrg      echo "The spurious makeinfo call might also be the consequence of"
1886257f37dSmrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1896257f37dSmrg      echo "want to install GNU make:"
1906257f37dSmrg      echo "<$gnu_software_URL/make/>"
1916257f37dSmrg      ;;
1926257f37dSmrg    *)
1936257f37dSmrg      echo "You might have modified some files without having the proper"
1946257f37dSmrg      echo "tools for further handling them.  Check the 'README' file, it"
1956257f37dSmrg      echo "often tells you about the needed prerequisites for installing"
1966257f37dSmrg      echo "this package.  You may also peek at any GNU archive site, in"
1976257f37dSmrg      echo "case some other package contains this missing '$1' program."
1986257f37dSmrg      ;;
1996257f37dSmrg  esac
2006257f37dSmrg}
2016257f37dSmrg
2026257f37dSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
2036257f37dSmrg                       -e '2,$s/^/         /' >&2
2046257f37dSmrg
2056257f37dSmrg# Propagate the correct exit status (expected to be 127 for a program
2066257f37dSmrg# not found, 63 for a program that failed due to version mismatch).
2076257f37dSmrgexit $st
208fc5a983dSmrg
209fc5a983dSmrg# Local variables:
210d422ce2eSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
211fc5a983dSmrg# time-stamp-start: "scriptversion="
212fc5a983dSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
213d422ce2eSmrg# time-stamp-time-zone: "UTC0"
214bd304fc0Smrg# time-stamp-end: "; # UTC"
215fc5a983dSmrg# End:
216