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