missing revision 01395c31
192bb16f8Smrg#! /bin/sh
201395c31Smrg# Common wrapper for a few potentially missing GNU programs.
392bb16f8Smrg
401395c31Smrgscriptversion=2018-03-07.03; # UTC
592bb16f8Smrg
601395c31Smrg# Copyright (C) 1996-2018 Free Software Foundation, Inc.
701395c31Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
892bb16f8Smrg
992bb16f8Smrg# This program is free software; you can redistribute it and/or modify
1092bb16f8Smrg# it under the terms of the GNU General Public License as published by
1192bb16f8Smrg# the Free Software Foundation; either version 2, or (at your option)
1292bb16f8Smrg# any later version.
1392bb16f8Smrg
1492bb16f8Smrg# This program is distributed in the hope that it will be useful,
1592bb16f8Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1692bb16f8Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1792bb16f8Smrg# GNU General Public License for more details.
1892bb16f8Smrg
1992bb16f8Smrg# You should have received a copy of the GNU General Public License
2001395c31Smrg# along with this program.  If not, see <https://www.gnu.org/licenses/>.
2192bb16f8Smrg
2292bb16f8Smrg# As a special exception to the GNU General Public License, if you
2392bb16f8Smrg# distribute this file as part of a program that contains a
2492bb16f8Smrg# configuration script generated by Autoconf, you may include it under
2592bb16f8Smrg# the same distribution terms that you use for the rest of that program.
2692bb16f8Smrg
2792bb16f8Smrgif test $# -eq 0; then
2801395c31Smrg  echo 1>&2 "Try '$0 --help' for more information"
2992bb16f8Smrg  exit 1
3092bb16f8Smrgfi
3192bb16f8Smrg
3201395c31Smrgcase $1 in
3392bb16f8Smrg
3401395c31Smrg  --is-lightweight)
3501395c31Smrg    # Used by our autoconf macros to check whether the available missing
3601395c31Smrg    # script is modern enough.
3701395c31Smrg    exit 0
3801395c31Smrg    ;;
3992bb16f8Smrg
4001395c31Smrg  --run)
4101395c31Smrg    # Back-compat with the calling convention used by older automake.
4201395c31Smrg    shift
4301395c31Smrg    ;;
4492bb16f8Smrg
4592bb16f8Smrg  -h|--h|--he|--hel|--help)
4692bb16f8Smrg    echo "\
4792bb16f8Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
4892bb16f8Smrg
4901395c31SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
5001395c31Smrgto PROGRAM being missing or too old.
5192bb16f8Smrg
5292bb16f8SmrgOptions:
5392bb16f8Smrg  -h, --help      display this help and exit
5492bb16f8Smrg  -v, --version   output version information and exit
5592bb16f8Smrg
5692bb16f8SmrgSupported PROGRAM values:
5701395c31Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
5801395c31Smrg  bison     yacc      flex         lex       help2man
5992bb16f8Smrg
6001395c31SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
6101395c31Smrg'g' are ignored when checking the name.
628255a313Smrg
6392bb16f8SmrgSend bug reports to <bug-automake@gnu.org>."
6492bb16f8Smrg    exit $?
6592bb16f8Smrg    ;;
6692bb16f8Smrg
6792bb16f8Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
6892bb16f8Smrg    echo "missing $scriptversion (GNU Automake)"
6992bb16f8Smrg    exit $?
7092bb16f8Smrg    ;;
7192bb16f8Smrg
7292bb16f8Smrg  -*)
7301395c31Smrg    echo 1>&2 "$0: unknown '$1' option"
7401395c31Smrg    echo 1>&2 "Try '$0 --help' for more information"
7592bb16f8Smrg    exit 1
7692bb16f8Smrg    ;;
7792bb16f8Smrg
7892bb16f8Smrgesac
7992bb16f8Smrg
8001395c31Smrg# Run the given program, remember its exit status.
8101395c31Smrg"$@"; st=$?
8201395c31Smrg
8301395c31Smrg# If it succeeded, we are done.
8401395c31Smrgtest $st -eq 0 && exit 0
8501395c31Smrg
8601395c31Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
8701395c31Smrg# passed; such an option is passed most likely to detect whether the
8801395c31Smrg# program is present and works.
8901395c31Smrgcase $2 in --version|--help) exit $st;; esac
9001395c31Smrg
9101395c31Smrg# Exit code 63 means version mismatch.  This often happens when the user
9201395c31Smrg# tries to use an ancient version of a tool on a file that requires a
9301395c31Smrg# minimum version.
9401395c31Smrgif test $st -eq 63; then
9501395c31Smrg  msg="probably too old"
9601395c31Smrgelif test $st -eq 127; then
9701395c31Smrg  # Program was missing.
9801395c31Smrg  msg="missing on your system"
9901395c31Smrgelse
10001395c31Smrg  # Program was found and executed, but failed.  Give up.
10101395c31Smrg  exit $st
10201395c31Smrgfi
10392bb16f8Smrg
10401395c31Smrgperl_URL=https://www.perl.org/
10501395c31Smrgflex_URL=https://github.com/westes/flex
10601395c31Smrggnu_software_URL=https://www.gnu.org/software
10701395c31Smrg
10801395c31Smrgprogram_details ()
10901395c31Smrg{
11001395c31Smrg  case $1 in
11101395c31Smrg    aclocal|automake)
11201395c31Smrg      echo "The '$1' program is part of the GNU Automake package:"
11301395c31Smrg      echo "<$gnu_software_URL/automake>"
11401395c31Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
11501395c31Smrg      echo "<$gnu_software_URL/autoconf>"
11601395c31Smrg      echo "<$gnu_software_URL/m4/>"
11701395c31Smrg      echo "<$perl_URL>"
11801395c31Smrg      ;;
11901395c31Smrg    autoconf|autom4te|autoheader)
12001395c31Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
12101395c31Smrg      echo "<$gnu_software_URL/autoconf/>"
12201395c31Smrg      echo "It also requires GNU m4 and Perl in order to run:"
12301395c31Smrg      echo "<$gnu_software_URL/m4/>"
12401395c31Smrg      echo "<$perl_URL>"
12501395c31Smrg      ;;
12601395c31Smrg  esac
12701395c31Smrg}
12801395c31Smrg
12901395c31Smrggive_advice ()
13001395c31Smrg{
13101395c31Smrg  # Normalize program name to check for.
13201395c31Smrg  normalized_program=`echo "$1" | sed '
13301395c31Smrg    s/^gnu-//; t
13401395c31Smrg    s/^gnu//; t
13501395c31Smrg    s/^g//; t'`
13601395c31Smrg
13701395c31Smrg  printf '%s\n' "'$1' is $msg."
13801395c31Smrg
13901395c31Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
14001395c31Smrg  case $normalized_program in
14101395c31Smrg    autoconf*)
14201395c31Smrg      echo "You should only need it if you modified 'configure.ac',"
14301395c31Smrg      echo "or m4 files included by it."
14401395c31Smrg      program_details 'autoconf'
14501395c31Smrg      ;;
14601395c31Smrg    autoheader*)
14701395c31Smrg      echo "You should only need it if you modified 'acconfig.h' or"
14801395c31Smrg      echo "$configure_deps."
14901395c31Smrg      program_details 'autoheader'
15001395c31Smrg      ;;
15101395c31Smrg    automake*)
15201395c31Smrg      echo "You should only need it if you modified 'Makefile.am' or"
15301395c31Smrg      echo "$configure_deps."
15401395c31Smrg      program_details 'automake'
15501395c31Smrg      ;;
15601395c31Smrg    aclocal*)
15701395c31Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
15801395c31Smrg      echo "$configure_deps."
15901395c31Smrg      program_details 'aclocal'
16001395c31Smrg      ;;
16101395c31Smrg   autom4te*)
16201395c31Smrg      echo "You might have modified some maintainer files that require"
16301395c31Smrg      echo "the 'autom4te' program to be rebuilt."
16401395c31Smrg      program_details 'autom4te'
16501395c31Smrg      ;;
16601395c31Smrg    bison*|yacc*)
16701395c31Smrg      echo "You should only need it if you modified a '.y' file."
16801395c31Smrg      echo "You may want to install the GNU Bison package:"
16901395c31Smrg      echo "<$gnu_software_URL/bison/>"
17001395c31Smrg      ;;
17101395c31Smrg    lex*|flex*)
17201395c31Smrg      echo "You should only need it if you modified a '.l' file."
17301395c31Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
17401395c31Smrg      echo "<$flex_URL>"
17501395c31Smrg      ;;
17601395c31Smrg    help2man*)
17701395c31Smrg      echo "You should only need it if you modified a dependency" \
17801395c31Smrg           "of a man page."
17901395c31Smrg      echo "You may want to install the GNU Help2man package:"
18001395c31Smrg      echo "<$gnu_software_URL/help2man/>"
18101395c31Smrg    ;;
18201395c31Smrg    makeinfo*)
18301395c31Smrg      echo "You should only need it if you modified a '.texi' file, or"
18401395c31Smrg      echo "any other file indirectly affecting the aspect of the manual."
18501395c31Smrg      echo "You might want to install the Texinfo package:"
18601395c31Smrg      echo "<$gnu_software_URL/texinfo/>"
18701395c31Smrg      echo "The spurious makeinfo call might also be the consequence of"
18801395c31Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
18901395c31Smrg      echo "want to install GNU make:"
19001395c31Smrg      echo "<$gnu_software_URL/make/>"
19101395c31Smrg      ;;
19201395c31Smrg    *)
19301395c31Smrg      echo "You might have modified some files without having the proper"
19401395c31Smrg      echo "tools for further handling them.  Check the 'README' file, it"
19501395c31Smrg      echo "often tells you about the needed prerequisites for installing"
19601395c31Smrg      echo "this package.  You may also peek at any GNU archive site, in"
19701395c31Smrg      echo "case some other package contains this missing '$1' program."
19801395c31Smrg      ;;
19901395c31Smrg  esac
20001395c31Smrg}
20101395c31Smrg
20201395c31Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
20301395c31Smrg                       -e '2,$s/^/         /' >&2
20401395c31Smrg
20501395c31Smrg# Propagate the correct exit status (expected to be 127 for a program
20601395c31Smrg# not found, 63 for a program that failed due to version mismatch).
20701395c31Smrgexit $st
20892bb16f8Smrg
20992bb16f8Smrg# Local variables:
21001395c31Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
21192bb16f8Smrg# time-stamp-start: "scriptversion="
21292bb16f8Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
21301395c31Smrg# time-stamp-time-zone: "UTC0"
2148255a313Smrg# time-stamp-end: "; # UTC"
21592bb16f8Smrg# End:
216