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