xref: /potrace-1.14/missing (revision 275def9c)
1189777a2SCristian Pallares#! /bin/sh
21f13f311SSkyrpex# Common wrapper for a few potentially missing GNU programs.
3189777a2SCristian Pallares
41f13f311SSkyrpexscriptversion=2013-10-28.13; # UTC
5189777a2SCristian Pallares
6*275def9cSCristian Pallarés# Copyright (C) 1996-2014 Free Software Foundation, Inc.
71f13f311SSkyrpex# Originally written by Fran,cois Pinard <[email protected]>, 1996.
8189777a2SCristian Pallares
9189777a2SCristian Pallares# This program is free software; you can redistribute it and/or modify
10189777a2SCristian Pallares# it under the terms of the GNU General Public License as published by
11189777a2SCristian Pallares# the Free Software Foundation; either version 2, or (at your option)
12189777a2SCristian Pallares# any later version.
13189777a2SCristian Pallares
14189777a2SCristian Pallares# This program is distributed in the hope that it will be useful,
15189777a2SCristian Pallares# but WITHOUT ANY WARRANTY; without even the implied warranty of
16189777a2SCristian Pallares# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17189777a2SCristian Pallares# GNU General Public License for more details.
18189777a2SCristian Pallares
19189777a2SCristian Pallares# You should have received a copy of the GNU General Public License
20189777a2SCristian Pallares# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21189777a2SCristian Pallares
22189777a2SCristian Pallares# As a special exception to the GNU General Public License, if you
23189777a2SCristian Pallares# distribute this file as part of a program that contains a
24189777a2SCristian Pallares# configuration script generated by Autoconf, you may include it under
25189777a2SCristian Pallares# the same distribution terms that you use for the rest of that program.
26189777a2SCristian Pallares
27189777a2SCristian Pallaresif test $# -eq 0; then
281f13f311SSkyrpex  echo 1>&2 "Try '$0 --help' for more information"
29189777a2SCristian Pallares  exit 1
30189777a2SCristian Pallaresfi
31189777a2SCristian Pallares
32189777a2SCristian Pallarescase $1 in
331f13f311SSkyrpex
341f13f311SSkyrpex  --is-lightweight)
351f13f311SSkyrpex    # Used by our autoconf macros to check whether the available missing
361f13f311SSkyrpex    # script is modern enough.
371f13f311SSkyrpex    exit 0
381f13f311SSkyrpex    ;;
391f13f311SSkyrpex
40189777a2SCristian Pallares  --run)
411f13f311SSkyrpex    # Back-compat with the calling convention used by older automake.
42189777a2SCristian Pallares    shift
43189777a2SCristian Pallares    ;;
44189777a2SCristian Pallares
45189777a2SCristian Pallares  -h|--h|--he|--hel|--help)
46189777a2SCristian Pallares    echo "\
47189777a2SCristian Pallares$0 [OPTION]... PROGRAM [ARGUMENT]...
48189777a2SCristian Pallares
491f13f311SSkyrpexRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
501f13f311SSkyrpexto PROGRAM being missing or too old.
51189777a2SCristian Pallares
52189777a2SCristian PallaresOptions:
53189777a2SCristian Pallares  -h, --help      display this help and exit
54189777a2SCristian Pallares  -v, --version   output version information and exit
55189777a2SCristian Pallares
56189777a2SCristian PallaresSupported PROGRAM values:
571f13f311SSkyrpex  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
581f13f311SSkyrpex  bison     yacc      flex         lex       help2man
59189777a2SCristian Pallares
601f13f311SSkyrpexVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
611f13f311SSkyrpex'g' are ignored when checking the name.
62189777a2SCristian Pallares
63189777a2SCristian PallaresSend bug reports to <[email protected]>."
64189777a2SCristian Pallares    exit $?
65189777a2SCristian Pallares    ;;
66189777a2SCristian Pallares
67189777a2SCristian Pallares  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68189777a2SCristian Pallares    echo "missing $scriptversion (GNU Automake)"
69189777a2SCristian Pallares    exit $?
70189777a2SCristian Pallares    ;;
71189777a2SCristian Pallares
72189777a2SCristian Pallares  -*)
731f13f311SSkyrpex    echo 1>&2 "$0: unknown '$1' option"
741f13f311SSkyrpex    echo 1>&2 "Try '$0 --help' for more information"
75189777a2SCristian Pallares    exit 1
76189777a2SCristian Pallares    ;;
77189777a2SCristian Pallares
78189777a2SCristian Pallaresesac
79189777a2SCristian Pallares
801f13f311SSkyrpex# Run the given program, remember its exit status.
811f13f311SSkyrpex"$@"; st=$?
821f13f311SSkyrpex
831f13f311SSkyrpex# If it succeeded, we are done.
841f13f311SSkyrpextest $st -eq 0 && exit 0
851f13f311SSkyrpex
861f13f311SSkyrpex# Also exit now if we it failed (or wasn't found), and '--version' was
871f13f311SSkyrpex# passed; such an option is passed most likely to detect whether the
881f13f311SSkyrpex# program is present and works.
891f13f311SSkyrpexcase $2 in --version|--help) exit $st;; esac
901f13f311SSkyrpex
911f13f311SSkyrpex# Exit code 63 means version mismatch.  This often happens when the user
921f13f311SSkyrpex# tries to use an ancient version of a tool on a file that requires a
931f13f311SSkyrpex# minimum version.
941f13f311SSkyrpexif test $st -eq 63; then
951f13f311SSkyrpex  msg="probably too old"
961f13f311SSkyrpexelif test $st -eq 127; then
971f13f311SSkyrpex  # Program was missing.
981f13f311SSkyrpex  msg="missing on your system"
991f13f311SSkyrpexelse
1001f13f311SSkyrpex  # Program was found and executed, but failed.  Give up.
1011f13f311SSkyrpex  exit $st
1021f13f311SSkyrpexfi
1031f13f311SSkyrpex
1041f13f311SSkyrpexperl_URL=http://www.perl.org/
1051f13f311SSkyrpexflex_URL=http://flex.sourceforge.net/
1061f13f311SSkyrpexgnu_software_URL=http://www.gnu.org/software
1071f13f311SSkyrpex
1081f13f311SSkyrpexprogram_details ()
1091f13f311SSkyrpex{
1101f13f311SSkyrpex  case $1 in
1111f13f311SSkyrpex    aclocal|automake)
1121f13f311SSkyrpex      echo "The '$1' program is part of the GNU Automake package:"
1131f13f311SSkyrpex      echo "<$gnu_software_URL/automake>"
1141f13f311SSkyrpex      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1151f13f311SSkyrpex      echo "<$gnu_software_URL/autoconf>"
1161f13f311SSkyrpex      echo "<$gnu_software_URL/m4/>"
1171f13f311SSkyrpex      echo "<$perl_URL>"
1181f13f311SSkyrpex      ;;
1191f13f311SSkyrpex    autoconf|autom4te|autoheader)
1201f13f311SSkyrpex      echo "The '$1' program is part of the GNU Autoconf package:"
1211f13f311SSkyrpex      echo "<$gnu_software_URL/autoconf/>"
1221f13f311SSkyrpex      echo "It also requires GNU m4 and Perl in order to run:"
1231f13f311SSkyrpex      echo "<$gnu_software_URL/m4/>"
1241f13f311SSkyrpex      echo "<$perl_URL>"
1251f13f311SSkyrpex      ;;
1261f13f311SSkyrpex  esac
1271f13f311SSkyrpex}
1281f13f311SSkyrpex
1291f13f311SSkyrpexgive_advice ()
1301f13f311SSkyrpex{
1311f13f311SSkyrpex  # Normalize program name to check for.
1321f13f311SSkyrpex  normalized_program=`echo "$1" | sed '
133189777a2SCristian Pallares    s/^gnu-//; t
134189777a2SCristian Pallares    s/^gnu//; t
135189777a2SCristian Pallares    s/^g//; t'`
136189777a2SCristian Pallares
1371f13f311SSkyrpex  printf '%s\n' "'$1' is $msg."
138189777a2SCristian Pallares
1391f13f311SSkyrpex  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1401f13f311SSkyrpex  case $normalized_program in
141189777a2SCristian Pallares    autoconf*)
1421f13f311SSkyrpex      echo "You should only need it if you modified 'configure.ac',"
1431f13f311SSkyrpex      echo "or m4 files included by it."
1441f13f311SSkyrpex      program_details 'autoconf'
145189777a2SCristian Pallares      ;;
146189777a2SCristian Pallares    autoheader*)
1471f13f311SSkyrpex      echo "You should only need it if you modified 'acconfig.h' or"
1481f13f311SSkyrpex      echo "$configure_deps."
1491f13f311SSkyrpex      program_details 'autoheader'
150189777a2SCristian Pallares      ;;
151189777a2SCristian Pallares    automake*)
1521f13f311SSkyrpex      echo "You should only need it if you modified 'Makefile.am' or"
1531f13f311SSkyrpex      echo "$configure_deps."
1541f13f311SSkyrpex      program_details 'automake'
155189777a2SCristian Pallares      ;;
1561f13f311SSkyrpex    aclocal*)
1571f13f311SSkyrpex      echo "You should only need it if you modified 'acinclude.m4' or"
1581f13f311SSkyrpex      echo "$configure_deps."
1591f13f311SSkyrpex      program_details 'aclocal'
1601f13f311SSkyrpex      ;;
161189777a2SCristian Pallares   autom4te*)
1621f13f311SSkyrpex      echo "You might have modified some maintainer files that require"
1631f13f311SSkyrpex      echo "the 'autom4te' program to be rebuilt."
1641f13f311SSkyrpex      program_details 'autom4te'
165189777a2SCristian Pallares      ;;
166189777a2SCristian Pallares    bison*|yacc*)
1671f13f311SSkyrpex      echo "You should only need it if you modified a '.y' file."
1681f13f311SSkyrpex      echo "You may want to install the GNU Bison package:"
1691f13f311SSkyrpex      echo "<$gnu_software_URL/bison/>"
170189777a2SCristian Pallares      ;;
171189777a2SCristian Pallares    lex*|flex*)
1721f13f311SSkyrpex      echo "You should only need it if you modified a '.l' file."
1731f13f311SSkyrpex      echo "You may want to install the Fast Lexical Analyzer package:"
1741f13f311SSkyrpex      echo "<$flex_URL>"
175189777a2SCristian Pallares      ;;
176189777a2SCristian Pallares    help2man*)
1771f13f311SSkyrpex      echo "You should only need it if you modified a dependency" \
1781f13f311SSkyrpex           "of a man page."
1791f13f311SSkyrpex      echo "You may want to install the GNU Help2man package:"
1801f13f311SSkyrpex      echo "<$gnu_software_URL/help2man/>"
181189777a2SCristian Pallares    ;;
182189777a2SCristian Pallares    makeinfo*)
1831f13f311SSkyrpex      echo "You should only need it if you modified a '.texi' file, or"
1841f13f311SSkyrpex      echo "any other file indirectly affecting the aspect of the manual."
1851f13f311SSkyrpex      echo "You might want to install the Texinfo package:"
1861f13f311SSkyrpex      echo "<$gnu_software_URL/texinfo/>"
1871f13f311SSkyrpex      echo "The spurious makeinfo call might also be the consequence of"
1881f13f311SSkyrpex      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1891f13f311SSkyrpex      echo "want to install GNU make:"
1901f13f311SSkyrpex      echo "<$gnu_software_URL/make/>"
191189777a2SCristian Pallares      ;;
192189777a2SCristian Pallares    *)
1931f13f311SSkyrpex      echo "You might have modified some files without having the proper"
1941f13f311SSkyrpex      echo "tools for further handling them.  Check the 'README' file, it"
1951f13f311SSkyrpex      echo "often tells you about the needed prerequisites for installing"
1961f13f311SSkyrpex      echo "this package.  You may also peek at any GNU archive site, in"
1971f13f311SSkyrpex      echo "case some other package contains this missing '$1' program."
198189777a2SCristian Pallares      ;;
199189777a2SCristian Pallares  esac
2001f13f311SSkyrpex}
201189777a2SCristian Pallares
2021f13f311SSkyrpexgive_advice "$1" | sed -e '1s/^/WARNING: /' \
2031f13f311SSkyrpex                       -e '2,$s/^/         /' >&2
2041f13f311SSkyrpex
2051f13f311SSkyrpex# Propagate the correct exit status (expected to be 127 for a program
2061f13f311SSkyrpex# not found, 63 for a program that failed due to version mismatch).
2071f13f311SSkyrpexexit $st
208189777a2SCristian Pallares
209189777a2SCristian Pallares# Local variables:
210189777a2SCristian Pallares# eval: (add-hook 'write-file-hooks 'time-stamp)
211189777a2SCristian Pallares# time-stamp-start: "scriptversion="
212189777a2SCristian Pallares# time-stamp-format: "%:y-%02m-%02d.%02H"
213189777a2SCristian Pallares# time-stamp-time-zone: "UTC"
214189777a2SCristian Pallares# time-stamp-end: "; # UTC"
215189777a2SCristian Pallares# End:
216