xref: /netbsd-src/external/lgpl3/mpc/dist/missing (revision 062d2d48d34d3e4901797f81befe658ca0cf6792)
18fa80f29Smrg#!/bin/sh
2*062d2d48Smrg# Common wrapper for a few potentially missing GNU programs.
38fa80f29Smrg
4*062d2d48Smrgscriptversion=2013-10-28.13; # UTC
58fa80f29Smrg
6*062d2d48Smrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
7*062d2d48Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
88fa80f29Smrg
98fa80f29Smrg# This program is free software; you can redistribute it and/or modify
108fa80f29Smrg# it under the terms of the GNU General Public License as published by
118fa80f29Smrg# the Free Software Foundation; either version 2, or (at your option)
128fa80f29Smrg# any later version.
138fa80f29Smrg
148fa80f29Smrg# This program is distributed in the hope that it will be useful,
158fa80f29Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
168fa80f29Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
178fa80f29Smrg# GNU General Public License for more details.
188fa80f29Smrg
198fa80f29Smrg# You should have received a copy of the GNU General Public License
208fa80f29Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
218fa80f29Smrg
228fa80f29Smrg# As a special exception to the GNU General Public License, if you
238fa80f29Smrg# distribute this file as part of a program that contains a
248fa80f29Smrg# configuration script generated by Autoconf, you may include it under
258fa80f29Smrg# the same distribution terms that you use for the rest of that program.
268fa80f29Smrg
278fa80f29Smrgif test $# -eq 0; then
28*062d2d48Smrg  echo 1>&2 "Try '$0 --help' for more information"
298fa80f29Smrg  exit 1
308fa80f29Smrgfi
318fa80f29Smrg
328fa80f29Smrgcase $1 in
33*062d2d48Smrg
34*062d2d48Smrg  --is-lightweight)
35*062d2d48Smrg    # Used by our autoconf macros to check whether the available missing
36*062d2d48Smrg    # script is modern enough.
37*062d2d48Smrg    exit 0
38*062d2d48Smrg    ;;
39*062d2d48Smrg
408fa80f29Smrg  --run)
41*062d2d48Smrg    # Back-compat with the calling convention used by older automake.
428fa80f29Smrg    shift
438fa80f29Smrg    ;;
448fa80f29Smrg
458fa80f29Smrg  -h|--h|--he|--hel|--help)
468fa80f29Smrg    echo "\
478fa80f29Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
488fa80f29Smrg
49*062d2d48SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50*062d2d48Smrgto PROGRAM being missing or too old.
518fa80f29Smrg
528fa80f29SmrgOptions:
538fa80f29Smrg  -h, --help      display this help and exit
548fa80f29Smrg  -v, --version   output version information and exit
558fa80f29Smrg
568fa80f29SmrgSupported PROGRAM values:
57*062d2d48Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
58*062d2d48Smrg  bison     yacc      flex         lex       help2man
598fa80f29Smrg
60*062d2d48SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61*062d2d48Smrg'g' are ignored when checking the name.
628fa80f29Smrg
638fa80f29SmrgSend bug reports to <bug-automake@gnu.org>."
648fa80f29Smrg    exit $?
658fa80f29Smrg    ;;
668fa80f29Smrg
678fa80f29Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
688fa80f29Smrg    echo "missing $scriptversion (GNU Automake)"
698fa80f29Smrg    exit $?
708fa80f29Smrg    ;;
718fa80f29Smrg
728fa80f29Smrg  -*)
73*062d2d48Smrg    echo 1>&2 "$0: unknown '$1' option"
74*062d2d48Smrg    echo 1>&2 "Try '$0 --help' for more information"
758fa80f29Smrg    exit 1
768fa80f29Smrg    ;;
778fa80f29Smrg
788fa80f29Smrgesac
798fa80f29Smrg
80*062d2d48Smrg# Run the given program, remember its exit status.
81*062d2d48Smrg"$@"; st=$?
82*062d2d48Smrg
83*062d2d48Smrg# If it succeeded, we are done.
84*062d2d48Smrgtest $st -eq 0 && exit 0
85*062d2d48Smrg
86*062d2d48Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
87*062d2d48Smrg# passed; such an option is passed most likely to detect whether the
88*062d2d48Smrg# program is present and works.
89*062d2d48Smrgcase $2 in --version|--help) exit $st;; esac
90*062d2d48Smrg
91*062d2d48Smrg# Exit code 63 means version mismatch.  This often happens when the user
92*062d2d48Smrg# tries to use an ancient version of a tool on a file that requires a
93*062d2d48Smrg# minimum version.
94*062d2d48Smrgif test $st -eq 63; then
95*062d2d48Smrg  msg="probably too old"
96*062d2d48Smrgelif test $st -eq 127; then
97*062d2d48Smrg  # Program was missing.
98*062d2d48Smrg  msg="missing on your system"
99*062d2d48Smrgelse
100*062d2d48Smrg  # Program was found and executed, but failed.  Give up.
101*062d2d48Smrg  exit $st
102*062d2d48Smrgfi
103*062d2d48Smrg
104*062d2d48Smrgperl_URL=http://www.perl.org/
105*062d2d48Smrgflex_URL=http://flex.sourceforge.net/
106*062d2d48Smrggnu_software_URL=http://www.gnu.org/software
107*062d2d48Smrg
108*062d2d48Smrgprogram_details ()
109*062d2d48Smrg{
110*062d2d48Smrg  case $1 in
111*062d2d48Smrg    aclocal|automake)
112*062d2d48Smrg      echo "The '$1' program is part of the GNU Automake package:"
113*062d2d48Smrg      echo "<$gnu_software_URL/automake>"
114*062d2d48Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115*062d2d48Smrg      echo "<$gnu_software_URL/autoconf>"
116*062d2d48Smrg      echo "<$gnu_software_URL/m4/>"
117*062d2d48Smrg      echo "<$perl_URL>"
118*062d2d48Smrg      ;;
119*062d2d48Smrg    autoconf|autom4te|autoheader)
120*062d2d48Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
121*062d2d48Smrg      echo "<$gnu_software_URL/autoconf/>"
122*062d2d48Smrg      echo "It also requires GNU m4 and Perl in order to run:"
123*062d2d48Smrg      echo "<$gnu_software_URL/m4/>"
124*062d2d48Smrg      echo "<$perl_URL>"
125*062d2d48Smrg      ;;
126*062d2d48Smrg  esac
127*062d2d48Smrg}
128*062d2d48Smrg
129*062d2d48Smrggive_advice ()
130*062d2d48Smrg{
131*062d2d48Smrg  # Normalize program name to check for.
132*062d2d48Smrg  normalized_program=`echo "$1" | sed '
1338fa80f29Smrg    s/^gnu-//; t
1348fa80f29Smrg    s/^gnu//; t
1358fa80f29Smrg    s/^g//; t'`
1368fa80f29Smrg
137*062d2d48Smrg  printf '%s\n' "'$1' is $msg."
1388fa80f29Smrg
139*062d2d48Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140*062d2d48Smrg  case $normalized_program in
1418fa80f29Smrg    autoconf*)
142*062d2d48Smrg      echo "You should only need it if you modified 'configure.ac',"
143*062d2d48Smrg      echo "or m4 files included by it."
144*062d2d48Smrg      program_details 'autoconf'
1458fa80f29Smrg      ;;
1468fa80f29Smrg    autoheader*)
147*062d2d48Smrg      echo "You should only need it if you modified 'acconfig.h' or"
148*062d2d48Smrg      echo "$configure_deps."
149*062d2d48Smrg      program_details 'autoheader'
1508fa80f29Smrg      ;;
1518fa80f29Smrg    automake*)
152*062d2d48Smrg      echo "You should only need it if you modified 'Makefile.am' or"
153*062d2d48Smrg      echo "$configure_deps."
154*062d2d48Smrg      program_details 'automake'
1558fa80f29Smrg      ;;
156*062d2d48Smrg    aclocal*)
157*062d2d48Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
158*062d2d48Smrg      echo "$configure_deps."
159*062d2d48Smrg      program_details 'aclocal'
160*062d2d48Smrg      ;;
1618fa80f29Smrg   autom4te*)
162*062d2d48Smrg      echo "You might have modified some maintainer files that require"
163*062d2d48Smrg      echo "the 'autom4te' program to be rebuilt."
164*062d2d48Smrg      program_details 'autom4te'
1658fa80f29Smrg      ;;
1668fa80f29Smrg    bison*|yacc*)
167*062d2d48Smrg      echo "You should only need it if you modified a '.y' file."
168*062d2d48Smrg      echo "You may want to install the GNU Bison package:"
169*062d2d48Smrg      echo "<$gnu_software_URL/bison/>"
1708fa80f29Smrg      ;;
1718fa80f29Smrg    lex*|flex*)
172*062d2d48Smrg      echo "You should only need it if you modified a '.l' file."
173*062d2d48Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
174*062d2d48Smrg      echo "<$flex_URL>"
1758fa80f29Smrg      ;;
1768fa80f29Smrg    help2man*)
177*062d2d48Smrg      echo "You should only need it if you modified a dependency" \
178*062d2d48Smrg           "of a man page."
179*062d2d48Smrg      echo "You may want to install the GNU Help2man package:"
180*062d2d48Smrg      echo "<$gnu_software_URL/help2man/>"
1818fa80f29Smrg    ;;
1828fa80f29Smrg    makeinfo*)
183*062d2d48Smrg      echo "You should only need it if you modified a '.texi' file, or"
184*062d2d48Smrg      echo "any other file indirectly affecting the aspect of the manual."
185*062d2d48Smrg      echo "You might want to install the Texinfo package:"
186*062d2d48Smrg      echo "<$gnu_software_URL/texinfo/>"
187*062d2d48Smrg      echo "The spurious makeinfo call might also be the consequence of"
188*062d2d48Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189*062d2d48Smrg      echo "want to install GNU make:"
190*062d2d48Smrg      echo "<$gnu_software_URL/make/>"
1918fa80f29Smrg      ;;
1928fa80f29Smrg    *)
193*062d2d48Smrg      echo "You might have modified some files without having the proper"
194*062d2d48Smrg      echo "tools for further handling them.  Check the 'README' file, it"
195*062d2d48Smrg      echo "often tells you about the needed prerequisites for installing"
196*062d2d48Smrg      echo "this package.  You may also peek at any GNU archive site, in"
197*062d2d48Smrg      echo "case some other package contains this missing '$1' program."
1988fa80f29Smrg      ;;
1998fa80f29Smrg  esac
200*062d2d48Smrg}
2018fa80f29Smrg
202*062d2d48Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
203*062d2d48Smrg                       -e '2,$s/^/         /' >&2
204*062d2d48Smrg
205*062d2d48Smrg# Propagate the correct exit status (expected to be 127 for a program
206*062d2d48Smrg# not found, 63 for a program that failed due to version mismatch).
207*062d2d48Smrgexit $st
2088fa80f29Smrg
2098fa80f29Smrg# Local variables:
2108fa80f29Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
2118fa80f29Smrg# time-stamp-start: "scriptversion="
2128fa80f29Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
2138fa80f29Smrg# time-stamp-time-zone: "UTC"
2148fa80f29Smrg# time-stamp-end: "; # UTC"
2158fa80f29Smrg# End:
216