missing revision e24f450b
129459361Smrg#! /bin/sh
2fb4ebca8Smrg# Common wrapper for a few potentially missing GNU programs.
329459361Smrg
4e24f450bSmrgscriptversion=2018-03-07.03; # UTC
529459361Smrg
6e24f450bSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc.
7fb4ebca8Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
829459361Smrg
929459361Smrg# This program is free software; you can redistribute it and/or modify
1029459361Smrg# it under the terms of the GNU General Public License as published by
1129459361Smrg# the Free Software Foundation; either version 2, or (at your option)
1229459361Smrg# any later version.
1329459361Smrg
1429459361Smrg# This program is distributed in the hope that it will be useful,
1529459361Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1629459361Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1729459361Smrg# GNU General Public License for more details.
1829459361Smrg
1929459361Smrg# You should have received a copy of the GNU General Public License
20e24f450bSmrg# along with this program.  If not, see <https://www.gnu.org/licenses/>.
2129459361Smrg
2229459361Smrg# As a special exception to the GNU General Public License, if you
2329459361Smrg# distribute this file as part of a program that contains a
2429459361Smrg# configuration script generated by Autoconf, you may include it under
2529459361Smrg# the same distribution terms that you use for the rest of that program.
2629459361Smrg
2729459361Smrgif test $# -eq 0; then
28fb4ebca8Smrg  echo 1>&2 "Try '$0 --help' for more information"
2929459361Smrg  exit 1
3029459361Smrgfi
3129459361Smrg
32fb4ebca8Smrgcase $1 in
3329459361Smrg
34fb4ebca8Smrg  --is-lightweight)
35fb4ebca8Smrg    # Used by our autoconf macros to check whether the available missing
36fb4ebca8Smrg    # script is modern enough.
37fb4ebca8Smrg    exit 0
38fb4ebca8Smrg    ;;
3929459361Smrg
40fb4ebca8Smrg  --run)
41fb4ebca8Smrg    # Back-compat with the calling convention used by older automake.
42fb4ebca8Smrg    shift
43fb4ebca8Smrg    ;;
4429459361Smrg
4529459361Smrg  -h|--h|--he|--hel|--help)
4629459361Smrg    echo "\
4729459361Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
4829459361Smrg
49fb4ebca8SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50fb4ebca8Smrgto PROGRAM being missing or too old.
5129459361Smrg
5229459361SmrgOptions:
5329459361Smrg  -h, --help      display this help and exit
5429459361Smrg  -v, --version   output version information and exit
5529459361Smrg
5629459361SmrgSupported PROGRAM values:
57fb4ebca8Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
58fb4ebca8Smrg  bison     yacc      flex         lex       help2man
5929459361Smrg
60fb4ebca8SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61fb4ebca8Smrg'g' are ignored when checking the name.
6247202d7bSmrg
6329459361SmrgSend bug reports to <bug-automake@gnu.org>."
6429459361Smrg    exit $?
6529459361Smrg    ;;
6629459361Smrg
6729459361Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
6829459361Smrg    echo "missing $scriptversion (GNU Automake)"
6929459361Smrg    exit $?
7029459361Smrg    ;;
7129459361Smrg
7229459361Smrg  -*)
73fb4ebca8Smrg    echo 1>&2 "$0: unknown '$1' option"
74fb4ebca8Smrg    echo 1>&2 "Try '$0 --help' for more information"
7529459361Smrg    exit 1
7629459361Smrg    ;;
7729459361Smrg
7829459361Smrgesac
7929459361Smrg
80fb4ebca8Smrg# Run the given program, remember its exit status.
81fb4ebca8Smrg"$@"; st=$?
82fb4ebca8Smrg
83fb4ebca8Smrg# If it succeeded, we are done.
84fb4ebca8Smrgtest $st -eq 0 && exit 0
85fb4ebca8Smrg
86fb4ebca8Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
87fb4ebca8Smrg# passed; such an option is passed most likely to detect whether the
88fb4ebca8Smrg# program is present and works.
89fb4ebca8Smrgcase $2 in --version|--help) exit $st;; esac
90fb4ebca8Smrg
91fb4ebca8Smrg# Exit code 63 means version mismatch.  This often happens when the user
92fb4ebca8Smrg# tries to use an ancient version of a tool on a file that requires a
93fb4ebca8Smrg# minimum version.
94fb4ebca8Smrgif test $st -eq 63; then
95fb4ebca8Smrg  msg="probably too old"
96fb4ebca8Smrgelif test $st -eq 127; then
97fb4ebca8Smrg  # Program was missing.
98fb4ebca8Smrg  msg="missing on your system"
99fb4ebca8Smrgelse
100fb4ebca8Smrg  # Program was found and executed, but failed.  Give up.
101fb4ebca8Smrg  exit $st
102fb4ebca8Smrgfi
10329459361Smrg
104e24f450bSmrgperl_URL=https://www.perl.org/
105e24f450bSmrgflex_URL=https://github.com/westes/flex
106e24f450bSmrggnu_software_URL=https://www.gnu.org/software
107fb4ebca8Smrg
108fb4ebca8Smrgprogram_details ()
109fb4ebca8Smrg{
110fb4ebca8Smrg  case $1 in
111fb4ebca8Smrg    aclocal|automake)
112fb4ebca8Smrg      echo "The '$1' program is part of the GNU Automake package:"
113fb4ebca8Smrg      echo "<$gnu_software_URL/automake>"
114fb4ebca8Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115fb4ebca8Smrg      echo "<$gnu_software_URL/autoconf>"
116fb4ebca8Smrg      echo "<$gnu_software_URL/m4/>"
117fb4ebca8Smrg      echo "<$perl_URL>"
118fb4ebca8Smrg      ;;
119fb4ebca8Smrg    autoconf|autom4te|autoheader)
120fb4ebca8Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
121fb4ebca8Smrg      echo "<$gnu_software_URL/autoconf/>"
122fb4ebca8Smrg      echo "It also requires GNU m4 and Perl in order to run:"
123fb4ebca8Smrg      echo "<$gnu_software_URL/m4/>"
124fb4ebca8Smrg      echo "<$perl_URL>"
125fb4ebca8Smrg      ;;
126fb4ebca8Smrg  esac
127fb4ebca8Smrg}
128fb4ebca8Smrg
129fb4ebca8Smrggive_advice ()
130fb4ebca8Smrg{
131fb4ebca8Smrg  # Normalize program name to check for.
132fb4ebca8Smrg  normalized_program=`echo "$1" | sed '
133fb4ebca8Smrg    s/^gnu-//; t
134fb4ebca8Smrg    s/^gnu//; t
135fb4ebca8Smrg    s/^g//; t'`
136fb4ebca8Smrg
137fb4ebca8Smrg  printf '%s\n' "'$1' is $msg."
138fb4ebca8Smrg
139fb4ebca8Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140fb4ebca8Smrg  case $normalized_program in
141fb4ebca8Smrg    autoconf*)
142fb4ebca8Smrg      echo "You should only need it if you modified 'configure.ac',"
143fb4ebca8Smrg      echo "or m4 files included by it."
144fb4ebca8Smrg      program_details 'autoconf'
145fb4ebca8Smrg      ;;
146fb4ebca8Smrg    autoheader*)
147fb4ebca8Smrg      echo "You should only need it if you modified 'acconfig.h' or"
148fb4ebca8Smrg      echo "$configure_deps."
149fb4ebca8Smrg      program_details 'autoheader'
150fb4ebca8Smrg      ;;
151fb4ebca8Smrg    automake*)
152fb4ebca8Smrg      echo "You should only need it if you modified 'Makefile.am' or"
153fb4ebca8Smrg      echo "$configure_deps."
154fb4ebca8Smrg      program_details 'automake'
155fb4ebca8Smrg      ;;
156fb4ebca8Smrg    aclocal*)
157fb4ebca8Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
158fb4ebca8Smrg      echo "$configure_deps."
159fb4ebca8Smrg      program_details 'aclocal'
160fb4ebca8Smrg      ;;
161fb4ebca8Smrg   autom4te*)
162fb4ebca8Smrg      echo "You might have modified some maintainer files that require"
163fb4ebca8Smrg      echo "the 'autom4te' program to be rebuilt."
164fb4ebca8Smrg      program_details 'autom4te'
165fb4ebca8Smrg      ;;
166fb4ebca8Smrg    bison*|yacc*)
167fb4ebca8Smrg      echo "You should only need it if you modified a '.y' file."
168fb4ebca8Smrg      echo "You may want to install the GNU Bison package:"
169fb4ebca8Smrg      echo "<$gnu_software_URL/bison/>"
170fb4ebca8Smrg      ;;
171fb4ebca8Smrg    lex*|flex*)
172fb4ebca8Smrg      echo "You should only need it if you modified a '.l' file."
173fb4ebca8Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
174fb4ebca8Smrg      echo "<$flex_URL>"
175fb4ebca8Smrg      ;;
176fb4ebca8Smrg    help2man*)
177fb4ebca8Smrg      echo "You should only need it if you modified a dependency" \
178fb4ebca8Smrg           "of a man page."
179fb4ebca8Smrg      echo "You may want to install the GNU Help2man package:"
180fb4ebca8Smrg      echo "<$gnu_software_URL/help2man/>"
181fb4ebca8Smrg    ;;
182fb4ebca8Smrg    makeinfo*)
183fb4ebca8Smrg      echo "You should only need it if you modified a '.texi' file, or"
184fb4ebca8Smrg      echo "any other file indirectly affecting the aspect of the manual."
185fb4ebca8Smrg      echo "You might want to install the Texinfo package:"
186fb4ebca8Smrg      echo "<$gnu_software_URL/texinfo/>"
187fb4ebca8Smrg      echo "The spurious makeinfo call might also be the consequence of"
188fb4ebca8Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189fb4ebca8Smrg      echo "want to install GNU make:"
190fb4ebca8Smrg      echo "<$gnu_software_URL/make/>"
191fb4ebca8Smrg      ;;
192fb4ebca8Smrg    *)
193fb4ebca8Smrg      echo "You might have modified some files without having the proper"
194fb4ebca8Smrg      echo "tools for further handling them.  Check the 'README' file, it"
195fb4ebca8Smrg      echo "often tells you about the needed prerequisites for installing"
196fb4ebca8Smrg      echo "this package.  You may also peek at any GNU archive site, in"
197fb4ebca8Smrg      echo "case some other package contains this missing '$1' program."
198fb4ebca8Smrg      ;;
199fb4ebca8Smrg  esac
200fb4ebca8Smrg}
201fb4ebca8Smrg
202fb4ebca8Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
203fb4ebca8Smrg                       -e '2,$s/^/         /' >&2
204fb4ebca8Smrg
205fb4ebca8Smrg# Propagate the correct exit status (expected to be 127 for a program
206fb4ebca8Smrg# not found, 63 for a program that failed due to version mismatch).
207fb4ebca8Smrgexit $st
20829459361Smrg
20929459361Smrg# Local variables:
210e24f450bSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
21129459361Smrg# time-stamp-start: "scriptversion="
21229459361Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
213fa2b3b63Smrg# time-stamp-time-zone: "UTC0"
21447202d7bSmrg# time-stamp-end: "; # UTC"
21529459361Smrg# End:
216