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