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