missing revision 0568f49b
1444c061aSmrg#! /bin/sh
29e7bcd65Smrg# Common wrapper for a few potentially missing GNU programs.
3444c061aSmrg
40568f49bSmrgscriptversion=2018-03-07.03; # UTC
5444c061aSmrg
60568f49bSmrg# Copyright (C) 1996-2018 Free Software Foundation, Inc.
79e7bcd65Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8444c061aSmrg
9444c061aSmrg# This program is free software; you can redistribute it and/or modify
10444c061aSmrg# it under the terms of the GNU General Public License as published by
11444c061aSmrg# the Free Software Foundation; either version 2, or (at your option)
12444c061aSmrg# any later version.
13444c061aSmrg
14444c061aSmrg# This program is distributed in the hope that it will be useful,
15444c061aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16444c061aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17444c061aSmrg# GNU General Public License for more details.
18444c061aSmrg
19444c061aSmrg# You should have received a copy of the GNU General Public License
200568f49bSmrg# along with this program.  If not, see <https://www.gnu.org/licenses/>.
21444c061aSmrg
22444c061aSmrg# As a special exception to the GNU General Public License, if you
23444c061aSmrg# distribute this file as part of a program that contains a
24444c061aSmrg# configuration script generated by Autoconf, you may include it under
25444c061aSmrg# the same distribution terms that you use for the rest of that program.
26444c061aSmrg
27444c061aSmrgif test $# -eq 0; then
289e7bcd65Smrg  echo 1>&2 "Try '$0 --help' for more information"
29444c061aSmrg  exit 1
30444c061aSmrgfi
31444c061aSmrg
329e7bcd65Smrgcase $1 in
33444c061aSmrg
349e7bcd65Smrg  --is-lightweight)
359e7bcd65Smrg    # Used by our autoconf macros to check whether the available missing
369e7bcd65Smrg    # script is modern enough.
379e7bcd65Smrg    exit 0
389e7bcd65Smrg    ;;
39444c061aSmrg
409e7bcd65Smrg  --run)
419e7bcd65Smrg    # Back-compat with the calling convention used by older automake.
429e7bcd65Smrg    shift
439e7bcd65Smrg    ;;
44444c061aSmrg
45444c061aSmrg  -h|--h|--he|--hel|--help)
46444c061aSmrg    echo "\
47444c061aSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
48444c061aSmrg
499e7bcd65SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
509e7bcd65Smrgto PROGRAM being missing or too old.
51444c061aSmrg
52444c061aSmrgOptions:
53444c061aSmrg  -h, --help      display this help and exit
54444c061aSmrg  -v, --version   output version information and exit
55444c061aSmrg
56444c061aSmrgSupported PROGRAM values:
579e7bcd65Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
589e7bcd65Smrg  bison     yacc      flex         lex       help2man
59444c061aSmrg
609e7bcd65SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
619e7bcd65Smrg'g' are ignored when checking the name.
622ae83157Smrg
63444c061aSmrgSend bug reports to <bug-automake@gnu.org>."
64444c061aSmrg    exit $?
65444c061aSmrg    ;;
66444c061aSmrg
67444c061aSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68444c061aSmrg    echo "missing $scriptversion (GNU Automake)"
69444c061aSmrg    exit $?
70444c061aSmrg    ;;
71444c061aSmrg
72444c061aSmrg  -*)
739e7bcd65Smrg    echo 1>&2 "$0: unknown '$1' option"
749e7bcd65Smrg    echo 1>&2 "Try '$0 --help' for more information"
75444c061aSmrg    exit 1
76444c061aSmrg    ;;
77444c061aSmrg
78444c061aSmrgesac
79444c061aSmrg
809e7bcd65Smrg# Run the given program, remember its exit status.
819e7bcd65Smrg"$@"; st=$?
829e7bcd65Smrg
839e7bcd65Smrg# If it succeeded, we are done.
849e7bcd65Smrgtest $st -eq 0 && exit 0
859e7bcd65Smrg
869e7bcd65Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
879e7bcd65Smrg# passed; such an option is passed most likely to detect whether the
889e7bcd65Smrg# program is present and works.
899e7bcd65Smrgcase $2 in --version|--help) exit $st;; esac
909e7bcd65Smrg
919e7bcd65Smrg# Exit code 63 means version mismatch.  This often happens when the user
929e7bcd65Smrg# tries to use an ancient version of a tool on a file that requires a
939e7bcd65Smrg# minimum version.
949e7bcd65Smrgif test $st -eq 63; then
959e7bcd65Smrg  msg="probably too old"
969e7bcd65Smrgelif test $st -eq 127; then
979e7bcd65Smrg  # Program was missing.
989e7bcd65Smrg  msg="missing on your system"
999e7bcd65Smrgelse
1009e7bcd65Smrg  # Program was found and executed, but failed.  Give up.
1019e7bcd65Smrg  exit $st
1029e7bcd65Smrgfi
103444c061aSmrg
1040568f49bSmrgperl_URL=https://www.perl.org/
1050568f49bSmrgflex_URL=https://github.com/westes/flex
1060568f49bSmrggnu_software_URL=https://www.gnu.org/software
1079e7bcd65Smrg
1089e7bcd65Smrgprogram_details ()
1099e7bcd65Smrg{
1109e7bcd65Smrg  case $1 in
1119e7bcd65Smrg    aclocal|automake)
1129e7bcd65Smrg      echo "The '$1' program is part of the GNU Automake package:"
1139e7bcd65Smrg      echo "<$gnu_software_URL/automake>"
1149e7bcd65Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1159e7bcd65Smrg      echo "<$gnu_software_URL/autoconf>"
1169e7bcd65Smrg      echo "<$gnu_software_URL/m4/>"
1179e7bcd65Smrg      echo "<$perl_URL>"
1189e7bcd65Smrg      ;;
1199e7bcd65Smrg    autoconf|autom4te|autoheader)
1209e7bcd65Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
1219e7bcd65Smrg      echo "<$gnu_software_URL/autoconf/>"
1229e7bcd65Smrg      echo "It also requires GNU m4 and Perl in order to run:"
1239e7bcd65Smrg      echo "<$gnu_software_URL/m4/>"
1249e7bcd65Smrg      echo "<$perl_URL>"
1259e7bcd65Smrg      ;;
1269e7bcd65Smrg  esac
1279e7bcd65Smrg}
1289e7bcd65Smrg
1299e7bcd65Smrggive_advice ()
1309e7bcd65Smrg{
1319e7bcd65Smrg  # Normalize program name to check for.
1329e7bcd65Smrg  normalized_program=`echo "$1" | sed '
1339e7bcd65Smrg    s/^gnu-//; t
1349e7bcd65Smrg    s/^gnu//; t
1359e7bcd65Smrg    s/^g//; t'`
1369e7bcd65Smrg
1379e7bcd65Smrg  printf '%s\n' "'$1' is $msg."
1389e7bcd65Smrg
1399e7bcd65Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1409e7bcd65Smrg  case $normalized_program in
1419e7bcd65Smrg    autoconf*)
1429e7bcd65Smrg      echo "You should only need it if you modified 'configure.ac',"
1439e7bcd65Smrg      echo "or m4 files included by it."
1449e7bcd65Smrg      program_details 'autoconf'
1459e7bcd65Smrg      ;;
1469e7bcd65Smrg    autoheader*)
1479e7bcd65Smrg      echo "You should only need it if you modified 'acconfig.h' or"
1489e7bcd65Smrg      echo "$configure_deps."
1499e7bcd65Smrg      program_details 'autoheader'
1509e7bcd65Smrg      ;;
1519e7bcd65Smrg    automake*)
1529e7bcd65Smrg      echo "You should only need it if you modified 'Makefile.am' or"
1539e7bcd65Smrg      echo "$configure_deps."
1549e7bcd65Smrg      program_details 'automake'
1559e7bcd65Smrg      ;;
1569e7bcd65Smrg    aclocal*)
1579e7bcd65Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
1589e7bcd65Smrg      echo "$configure_deps."
1599e7bcd65Smrg      program_details 'aclocal'
1609e7bcd65Smrg      ;;
1619e7bcd65Smrg   autom4te*)
1629e7bcd65Smrg      echo "You might have modified some maintainer files that require"
163339a7c43Smrg      echo "the 'autom4te' program to be rebuilt."
1649e7bcd65Smrg      program_details 'autom4te'
1659e7bcd65Smrg      ;;
1669e7bcd65Smrg    bison*|yacc*)
1679e7bcd65Smrg      echo "You should only need it if you modified a '.y' file."
1689e7bcd65Smrg      echo "You may want to install the GNU Bison package:"
1699e7bcd65Smrg      echo "<$gnu_software_URL/bison/>"
1709e7bcd65Smrg      ;;
1719e7bcd65Smrg    lex*|flex*)
1729e7bcd65Smrg      echo "You should only need it if you modified a '.l' file."
1739e7bcd65Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
1749e7bcd65Smrg      echo "<$flex_URL>"
1759e7bcd65Smrg      ;;
1769e7bcd65Smrg    help2man*)
1779e7bcd65Smrg      echo "You should only need it if you modified a dependency" \
1789e7bcd65Smrg           "of a man page."
1799e7bcd65Smrg      echo "You may want to install the GNU Help2man package:"
1809e7bcd65Smrg      echo "<$gnu_software_URL/help2man/>"
1819e7bcd65Smrg    ;;
1829e7bcd65Smrg    makeinfo*)
1839e7bcd65Smrg      echo "You should only need it if you modified a '.texi' file, or"
1849e7bcd65Smrg      echo "any other file indirectly affecting the aspect of the manual."
1859e7bcd65Smrg      echo "You might want to install the Texinfo package:"
1869e7bcd65Smrg      echo "<$gnu_software_URL/texinfo/>"
1879e7bcd65Smrg      echo "The spurious makeinfo call might also be the consequence of"
1889e7bcd65Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1899e7bcd65Smrg      echo "want to install GNU make:"
1909e7bcd65Smrg      echo "<$gnu_software_URL/make/>"
1919e7bcd65Smrg      ;;
1929e7bcd65Smrg    *)
1939e7bcd65Smrg      echo "You might have modified some files without having the proper"
1949e7bcd65Smrg      echo "tools for further handling them.  Check the 'README' file, it"
1959e7bcd65Smrg      echo "often tells you about the needed prerequisites for installing"
1969e7bcd65Smrg      echo "this package.  You may also peek at any GNU archive site, in"
1979e7bcd65Smrg      echo "case some other package contains this missing '$1' program."
1989e7bcd65Smrg      ;;
1999e7bcd65Smrg  esac
2009e7bcd65Smrg}
2019e7bcd65Smrg
2029e7bcd65Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
2039e7bcd65Smrg                       -e '2,$s/^/         /' >&2
2049e7bcd65Smrg
2059e7bcd65Smrg# Propagate the correct exit status (expected to be 127 for a program
2069e7bcd65Smrg# not found, 63 for a program that failed due to version mismatch).
2079e7bcd65Smrgexit $st
208444c061aSmrg
209444c061aSmrg# Local variables:
2100568f49bSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
211444c061aSmrg# time-stamp-start: "scriptversion="
212444c061aSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
2130568f49bSmrg# time-stamp-time-zone: "UTC0"
2142ae83157Smrg# time-stamp-end: "; # UTC"
215444c061aSmrg# End:
216