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