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