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