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