missing revision 433d0511
1eaef79e5Smrg#! /bin/sh
2cbc4e2beSmrg# Common wrapper for a few potentially missing GNU programs.
3eaef79e5Smrg
4433d0511Smrgscriptversion=2018-03-07.03; # UTC
5eaef79e5Smrg
6433d0511Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc.
7cbc4e2beSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8eaef79e5Smrg
9eaef79e5Smrg# This program is free software; you can redistribute it and/or modify
10eaef79e5Smrg# it under the terms of the GNU General Public License as published by
11eaef79e5Smrg# the Free Software Foundation; either version 2, or (at your option)
12eaef79e5Smrg# any later version.
13eaef79e5Smrg
14eaef79e5Smrg# This program is distributed in the hope that it will be useful,
15eaef79e5Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16eaef79e5Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17eaef79e5Smrg# GNU General Public License for more details.
18eaef79e5Smrg
19eaef79e5Smrg# You should have received a copy of the GNU General Public License
20433d0511Smrg# along with this program.  If not, see <https://www.gnu.org/licenses/>.
21eaef79e5Smrg
22eaef79e5Smrg# As a special exception to the GNU General Public License, if you
23eaef79e5Smrg# distribute this file as part of a program that contains a
24eaef79e5Smrg# configuration script generated by Autoconf, you may include it under
25eaef79e5Smrg# the same distribution terms that you use for the rest of that program.
26eaef79e5Smrg
27eaef79e5Smrgif test $# -eq 0; then
28cbc4e2beSmrg  echo 1>&2 "Try '$0 --help' for more information"
29eaef79e5Smrg  exit 1
30eaef79e5Smrgfi
31eaef79e5Smrg
32cbc4e2beSmrgcase $1 in
33eaef79e5Smrg
34cbc4e2beSmrg  --is-lightweight)
35cbc4e2beSmrg    # Used by our autoconf macros to check whether the available missing
36cbc4e2beSmrg    # script is modern enough.
37cbc4e2beSmrg    exit 0
38cbc4e2beSmrg    ;;
39eaef79e5Smrg
40cbc4e2beSmrg  --run)
41cbc4e2beSmrg    # Back-compat with the calling convention used by older automake.
42cbc4e2beSmrg    shift
43cbc4e2beSmrg    ;;
44eaef79e5Smrg
45eaef79e5Smrg  -h|--h|--he|--hel|--help)
46eaef79e5Smrg    echo "\
47eaef79e5Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
48eaef79e5Smrg
49cbc4e2beSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50cbc4e2beSmrgto PROGRAM being missing or too old.
51eaef79e5Smrg
52eaef79e5SmrgOptions:
53eaef79e5Smrg  -h, --help      display this help and exit
54eaef79e5Smrg  -v, --version   output version information and exit
55eaef79e5Smrg
56eaef79e5SmrgSupported PROGRAM values:
57cbc4e2beSmrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
58cbc4e2beSmrg  bison     yacc      flex         lex       help2man
59eaef79e5Smrg
60cbc4e2beSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61cbc4e2beSmrg'g' are ignored when checking the name.
622b32c8f7Smrg
63eaef79e5SmrgSend bug reports to <bug-automake@gnu.org>."
64eaef79e5Smrg    exit $?
65eaef79e5Smrg    ;;
66eaef79e5Smrg
67eaef79e5Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68eaef79e5Smrg    echo "missing $scriptversion (GNU Automake)"
69eaef79e5Smrg    exit $?
70eaef79e5Smrg    ;;
71eaef79e5Smrg
72eaef79e5Smrg  -*)
73cbc4e2beSmrg    echo 1>&2 "$0: unknown '$1' option"
74cbc4e2beSmrg    echo 1>&2 "Try '$0 --help' for more information"
75eaef79e5Smrg    exit 1
76eaef79e5Smrg    ;;
77eaef79e5Smrg
78eaef79e5Smrgesac
79eaef79e5Smrg
80cbc4e2beSmrg# Run the given program, remember its exit status.
81cbc4e2beSmrg"$@"; st=$?
82cbc4e2beSmrg
83cbc4e2beSmrg# If it succeeded, we are done.
84cbc4e2beSmrgtest $st -eq 0 && exit 0
85cbc4e2beSmrg
86cbc4e2beSmrg# Also exit now if we it failed (or wasn't found), and '--version' was
87cbc4e2beSmrg# passed; such an option is passed most likely to detect whether the
88cbc4e2beSmrg# program is present and works.
89cbc4e2beSmrgcase $2 in --version|--help) exit $st;; esac
90cbc4e2beSmrg
91cbc4e2beSmrg# Exit code 63 means version mismatch.  This often happens when the user
92cbc4e2beSmrg# tries to use an ancient version of a tool on a file that requires a
93cbc4e2beSmrg# minimum version.
94cbc4e2beSmrgif test $st -eq 63; then
95cbc4e2beSmrg  msg="probably too old"
96cbc4e2beSmrgelif test $st -eq 127; then
97cbc4e2beSmrg  # Program was missing.
98cbc4e2beSmrg  msg="missing on your system"
99cbc4e2beSmrgelse
100cbc4e2beSmrg  # Program was found and executed, but failed.  Give up.
101cbc4e2beSmrg  exit $st
102cbc4e2beSmrgfi
103eaef79e5Smrg
104433d0511Smrgperl_URL=https://www.perl.org/
105433d0511Smrgflex_URL=https://github.com/westes/flex
106433d0511Smrggnu_software_URL=https://www.gnu.org/software
107cbc4e2beSmrg
108cbc4e2beSmrgprogram_details ()
109cbc4e2beSmrg{
110cbc4e2beSmrg  case $1 in
111cbc4e2beSmrg    aclocal|automake)
112cbc4e2beSmrg      echo "The '$1' program is part of the GNU Automake package:"
113cbc4e2beSmrg      echo "<$gnu_software_URL/automake>"
114cbc4e2beSmrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115cbc4e2beSmrg      echo "<$gnu_software_URL/autoconf>"
116cbc4e2beSmrg      echo "<$gnu_software_URL/m4/>"
117cbc4e2beSmrg      echo "<$perl_URL>"
118cbc4e2beSmrg      ;;
119cbc4e2beSmrg    autoconf|autom4te|autoheader)
120cbc4e2beSmrg      echo "The '$1' program is part of the GNU Autoconf package:"
121cbc4e2beSmrg      echo "<$gnu_software_URL/autoconf/>"
122cbc4e2beSmrg      echo "It also requires GNU m4 and Perl in order to run:"
123cbc4e2beSmrg      echo "<$gnu_software_URL/m4/>"
124cbc4e2beSmrg      echo "<$perl_URL>"
125cbc4e2beSmrg      ;;
126cbc4e2beSmrg  esac
127cbc4e2beSmrg}
128cbc4e2beSmrg
129cbc4e2beSmrggive_advice ()
130cbc4e2beSmrg{
131cbc4e2beSmrg  # Normalize program name to check for.
132cbc4e2beSmrg  normalized_program=`echo "$1" | sed '
133cbc4e2beSmrg    s/^gnu-//; t
134cbc4e2beSmrg    s/^gnu//; t
135cbc4e2beSmrg    s/^g//; t'`
136cbc4e2beSmrg
137cbc4e2beSmrg  printf '%s\n' "'$1' is $msg."
138cbc4e2beSmrg
139cbc4e2beSmrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140cbc4e2beSmrg  case $normalized_program in
141cbc4e2beSmrg    autoconf*)
142cbc4e2beSmrg      echo "You should only need it if you modified 'configure.ac',"
143cbc4e2beSmrg      echo "or m4 files included by it."
144cbc4e2beSmrg      program_details 'autoconf'
145cbc4e2beSmrg      ;;
146cbc4e2beSmrg    autoheader*)
147cbc4e2beSmrg      echo "You should only need it if you modified 'acconfig.h' or"
148cbc4e2beSmrg      echo "$configure_deps."
149cbc4e2beSmrg      program_details 'autoheader'
150cbc4e2beSmrg      ;;
151cbc4e2beSmrg    automake*)
152cbc4e2beSmrg      echo "You should only need it if you modified 'Makefile.am' or"
153cbc4e2beSmrg      echo "$configure_deps."
154cbc4e2beSmrg      program_details 'automake'
155cbc4e2beSmrg      ;;
156cbc4e2beSmrg    aclocal*)
157cbc4e2beSmrg      echo "You should only need it if you modified 'acinclude.m4' or"
158cbc4e2beSmrg      echo "$configure_deps."
159cbc4e2beSmrg      program_details 'aclocal'
160cbc4e2beSmrg      ;;
161cbc4e2beSmrg   autom4te*)
162cbc4e2beSmrg      echo "You might have modified some maintainer files that require"
163d1a7ce7bSmrg      echo "the 'autom4te' program to be rebuilt."
164cbc4e2beSmrg      program_details 'autom4te'
165cbc4e2beSmrg      ;;
166cbc4e2beSmrg    bison*|yacc*)
167cbc4e2beSmrg      echo "You should only need it if you modified a '.y' file."
168cbc4e2beSmrg      echo "You may want to install the GNU Bison package:"
169cbc4e2beSmrg      echo "<$gnu_software_URL/bison/>"
170cbc4e2beSmrg      ;;
171cbc4e2beSmrg    lex*|flex*)
172cbc4e2beSmrg      echo "You should only need it if you modified a '.l' file."
173cbc4e2beSmrg      echo "You may want to install the Fast Lexical Analyzer package:"
174cbc4e2beSmrg      echo "<$flex_URL>"
175cbc4e2beSmrg      ;;
176cbc4e2beSmrg    help2man*)
177cbc4e2beSmrg      echo "You should only need it if you modified a dependency" \
178cbc4e2beSmrg           "of a man page."
179cbc4e2beSmrg      echo "You may want to install the GNU Help2man package:"
180cbc4e2beSmrg      echo "<$gnu_software_URL/help2man/>"
181cbc4e2beSmrg    ;;
182cbc4e2beSmrg    makeinfo*)
183cbc4e2beSmrg      echo "You should only need it if you modified a '.texi' file, or"
184cbc4e2beSmrg      echo "any other file indirectly affecting the aspect of the manual."
185cbc4e2beSmrg      echo "You might want to install the Texinfo package:"
186cbc4e2beSmrg      echo "<$gnu_software_URL/texinfo/>"
187cbc4e2beSmrg      echo "The spurious makeinfo call might also be the consequence of"
188cbc4e2beSmrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189cbc4e2beSmrg      echo "want to install GNU make:"
190cbc4e2beSmrg      echo "<$gnu_software_URL/make/>"
191cbc4e2beSmrg      ;;
192cbc4e2beSmrg    *)
193cbc4e2beSmrg      echo "You might have modified some files without having the proper"
194cbc4e2beSmrg      echo "tools for further handling them.  Check the 'README' file, it"
195cbc4e2beSmrg      echo "often tells you about the needed prerequisites for installing"
196cbc4e2beSmrg      echo "this package.  You may also peek at any GNU archive site, in"
197cbc4e2beSmrg      echo "case some other package contains this missing '$1' program."
198cbc4e2beSmrg      ;;
199cbc4e2beSmrg  esac
200cbc4e2beSmrg}
201cbc4e2beSmrg
202cbc4e2beSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
203cbc4e2beSmrg                       -e '2,$s/^/         /' >&2
204cbc4e2beSmrg
205cbc4e2beSmrg# Propagate the correct exit status (expected to be 127 for a program
206cbc4e2beSmrg# not found, 63 for a program that failed due to version mismatch).
207cbc4e2beSmrgexit $st
208eaef79e5Smrg
209eaef79e5Smrg# Local variables:
210433d0511Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
211eaef79e5Smrg# time-stamp-start: "scriptversion="
212eaef79e5Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
213433d0511Smrg# time-stamp-time-zone: "UTC0"
2142b32c8f7Smrg# time-stamp-end: "; # UTC"
215eaef79e5Smrg# End:
216