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