missing revision f1ee322d
1c43cc173Smrg#! /bin/sh
2c43cc173Smrg# Common stub for a few missing GNU programs while installing.
3c43cc173Smrg
4f1ee322dSmrgscriptversion=2012-01-06.18; # UTC
5c43cc173Smrg
6f1ee322dSmrg# Copyright (C) 1996-2012 Free Software Foundation, Inc.
7c43cc173Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8c43cc173Smrg
9c43cc173Smrg# This program is free software; you can redistribute it and/or modify
10c43cc173Smrg# it under the terms of the GNU General Public License as published by
11c43cc173Smrg# the Free Software Foundation; either version 2, or (at your option)
12c43cc173Smrg# any later version.
13c43cc173Smrg
14c43cc173Smrg# This program is distributed in the hope that it will be useful,
15c43cc173Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16c43cc173Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17c43cc173Smrg# GNU General Public License for more details.
18c43cc173Smrg
19c43cc173Smrg# You should have received a copy of the GNU General Public License
20c27c18e8Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21c43cc173Smrg
22c43cc173Smrg# As a special exception to the GNU General Public License, if you
23c43cc173Smrg# distribute this file as part of a program that contains a
24c43cc173Smrg# configuration script generated by Autoconf, you may include it under
25c43cc173Smrg# the same distribution terms that you use for the rest of that program.
26c43cc173Smrg
27c43cc173Smrgif test $# -eq 0; then
28f1ee322dSmrg  echo 1>&2 "Try '$0 --help' for more information"
29c43cc173Smrg  exit 1
30c43cc173Smrgfi
31c43cc173Smrg
32c43cc173Smrgrun=:
33c43cc173Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
34c43cc173Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
35c43cc173Smrg
36f1ee322dSmrg# In the cases where this matters, 'missing' is being run in the
37c43cc173Smrg# srcdir already.
38c43cc173Smrgif test -f configure.ac; then
39c43cc173Smrg  configure_ac=configure.ac
40c43cc173Smrgelse
41c43cc173Smrg  configure_ac=configure.in
42c43cc173Smrgfi
43c43cc173Smrg
44c43cc173Smrgmsg="missing on your system"
45c43cc173Smrg
46c43cc173Smrgcase $1 in
47c43cc173Smrg--run)
48c43cc173Smrg  # Try to run requested program, and just exit if it succeeds.
49c43cc173Smrg  run=
50c43cc173Smrg  shift
51c43cc173Smrg  "$@" && exit 0
52c43cc173Smrg  # Exit code 63 means version mismatch.  This often happens
53c43cc173Smrg  # when the user try to use an ancient version of a tool on
54c43cc173Smrg  # a file that requires a minimum version.  In this case we
55c43cc173Smrg  # we should proceed has if the program had been absent, or
56c43cc173Smrg  # if --run hadn't been passed.
57c43cc173Smrg  if test $? = 63; then
58c43cc173Smrg    run=:
59c43cc173Smrg    msg="probably too old"
60c43cc173Smrg  fi
61c43cc173Smrg  ;;
62c43cc173Smrg
63c43cc173Smrg  -h|--h|--he|--hel|--help)
64c43cc173Smrg    echo "\
65c43cc173Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
66c43cc173Smrg
67f1ee322dSmrgHandle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
68c43cc173Smrgerror status if there is no known handling for PROGRAM.
69c43cc173Smrg
70c43cc173SmrgOptions:
71c43cc173Smrg  -h, --help      display this help and exit
72c43cc173Smrg  -v, --version   output version information and exit
73c43cc173Smrg  --run           try to run the given command, and emulate it if it fails
74c43cc173Smrg
75c43cc173SmrgSupported PROGRAM values:
76f1ee322dSmrg  aclocal      touch file 'aclocal.m4'
77f1ee322dSmrg  autoconf     touch file 'configure'
78f1ee322dSmrg  autoheader   touch file 'config.h.in'
79c43cc173Smrg  autom4te     touch the output file, or create a stub one
80f1ee322dSmrg  automake     touch all 'Makefile.in' files
81f1ee322dSmrg  bison        create 'y.tab.[ch]', if possible, from existing .[ch]
82f1ee322dSmrg  flex         create 'lex.yy.c', if possible, from existing .c
83c43cc173Smrg  help2man     touch the output file
84f1ee322dSmrg  lex          create 'lex.yy.c', if possible, from existing .c
85c43cc173Smrg  makeinfo     touch the output file
86f1ee322dSmrg  yacc         create 'y.tab.[ch]', if possible, from existing .[ch]
87c43cc173Smrg
88f1ee322dSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
89f1ee322dSmrg'g' are ignored when checking the name.
90c27c18e8Smrg
91c43cc173SmrgSend bug reports to <bug-automake@gnu.org>."
92c43cc173Smrg    exit $?
93c43cc173Smrg    ;;
94c43cc173Smrg
95c43cc173Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
96c43cc173Smrg    echo "missing $scriptversion (GNU Automake)"
97c43cc173Smrg    exit $?
98c43cc173Smrg    ;;
99c43cc173Smrg
100c43cc173Smrg  -*)
101f1ee322dSmrg    echo 1>&2 "$0: Unknown '$1' option"
102f1ee322dSmrg    echo 1>&2 "Try '$0 --help' for more information"
103c43cc173Smrg    exit 1
104c43cc173Smrg    ;;
105c43cc173Smrg
106c43cc173Smrgesac
107c43cc173Smrg
108c27c18e8Smrg# normalize program name to check for.
109c27c18e8Smrgprogram=`echo "$1" | sed '
110c27c18e8Smrg  s/^gnu-//; t
111c27c18e8Smrg  s/^gnu//; t
112c27c18e8Smrg  s/^g//; t'`
113c27c18e8Smrg
114c43cc173Smrg# Now exit if we have it, but it failed.  Also exit now if we
115c43cc173Smrg# don't have it and --version was passed (most likely to detect
116c27c18e8Smrg# the program).  This is about non-GNU programs, so use $1 not
117c27c18e8Smrg# $program.
118c43cc173Smrgcase $1 in
119c27c18e8Smrg  lex*|yacc*)
120c43cc173Smrg    # Not GNU programs, they don't have --version.
121c43cc173Smrg    ;;
122c43cc173Smrg
123c43cc173Smrg  *)
124c43cc173Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125c43cc173Smrg       # We have it, but it failed.
126c43cc173Smrg       exit 1
127c43cc173Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128c43cc173Smrg       # Could not run --version or --help.  This is probably someone
129f1ee322dSmrg       # running '$TOOL --version' or '$TOOL --help' to check whether
130c43cc173Smrg       # $TOOL exists and not knowing $TOOL uses missing.
131c43cc173Smrg       exit 1
132c43cc173Smrg    fi
133c43cc173Smrg    ;;
134c43cc173Smrgesac
135c43cc173Smrg
136c43cc173Smrg# If it does not exist, or fails to run (possibly an outdated version),
137c43cc173Smrg# try to emulate it.
138c27c18e8Smrgcase $program in
139c43cc173Smrg  aclocal*)
140c43cc173Smrg    echo 1>&2 "\
141f1ee322dSmrgWARNING: '$1' is $msg.  You should only need it if
142f1ee322dSmrg         you modified 'acinclude.m4' or '${configure_ac}'.  You might want
143f1ee322dSmrg         to install the Automake and Perl packages.  Grab them from
144c43cc173Smrg         any GNU archive site."
145c43cc173Smrg    touch aclocal.m4
146c43cc173Smrg    ;;
147c43cc173Smrg
148c27c18e8Smrg  autoconf*)
149c43cc173Smrg    echo 1>&2 "\
150f1ee322dSmrgWARNING: '$1' is $msg.  You should only need it if
151f1ee322dSmrg         you modified '${configure_ac}'.  You might want to install the
152f1ee322dSmrg         Autoconf and GNU m4 packages.  Grab them from any GNU
153c43cc173Smrg         archive site."
154c43cc173Smrg    touch configure
155c43cc173Smrg    ;;
156c43cc173Smrg
157c27c18e8Smrg  autoheader*)
158c43cc173Smrg    echo 1>&2 "\
159f1ee322dSmrgWARNING: '$1' is $msg.  You should only need it if
160f1ee322dSmrg         you modified 'acconfig.h' or '${configure_ac}'.  You might want
161f1ee322dSmrg         to install the Autoconf and GNU m4 packages.  Grab them
162c43cc173Smrg         from any GNU archive site."
163c43cc173Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
164c43cc173Smrg    test -z "$files" && files="config.h"
165c43cc173Smrg    touch_files=
166c43cc173Smrg    for f in $files; do
167c43cc173Smrg      case $f in
168c43cc173Smrg      *:*) touch_files="$touch_files "`echo "$f" |
169c43cc173Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
170c43cc173Smrg      *) touch_files="$touch_files $f.in";;
171c43cc173Smrg      esac
172c43cc173Smrg    done
173c43cc173Smrg    touch $touch_files
174c43cc173Smrg    ;;
175c43cc173Smrg
176c43cc173Smrg  automake*)
177c43cc173Smrg    echo 1>&2 "\
178f1ee322dSmrgWARNING: '$1' is $msg.  You should only need it if
179f1ee322dSmrg         you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'.
180f1ee322dSmrg         You might want to install the Automake and Perl packages.
181c43cc173Smrg         Grab them from any GNU archive site."
182c43cc173Smrg    find . -type f -name Makefile.am -print |
183c43cc173Smrg	   sed 's/\.am$/.in/' |
184c43cc173Smrg	   while read f; do touch "$f"; done
185c43cc173Smrg    ;;
186c43cc173Smrg
187c27c18e8Smrg  autom4te*)
188c43cc173Smrg    echo 1>&2 "\
189f1ee322dSmrgWARNING: '$1' is needed, but is $msg.
190c43cc173Smrg         You might have modified some files without having the
191c43cc173Smrg         proper tools for further handling them.
192f1ee322dSmrg         You can get '$1' as part of Autoconf from any GNU
193c43cc173Smrg         archive site."
194c43cc173Smrg
195c43cc173Smrg    file=`echo "$*" | sed -n "$sed_output"`
196c43cc173Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
197c43cc173Smrg    if test -f "$file"; then
198c43cc173Smrg	touch $file
199c43cc173Smrg    else
200c43cc173Smrg	test -z "$file" || exec >$file
201c43cc173Smrg	echo "#! /bin/sh"
202c43cc173Smrg	echo "# Created by GNU Automake missing as a replacement of"
203c43cc173Smrg	echo "#  $ $@"
204c43cc173Smrg	echo "exit 0"
205c43cc173Smrg	chmod +x $file
206c43cc173Smrg	exit 1
207c43cc173Smrg    fi
208c43cc173Smrg    ;;
209c43cc173Smrg
210c27c18e8Smrg  bison*|yacc*)
211c43cc173Smrg    echo 1>&2 "\
212f1ee322dSmrgWARNING: '$1' $msg.  You should only need it if
213f1ee322dSmrg         you modified a '.y' file.  You may need the Bison package
214c43cc173Smrg         in order for those modifications to take effect.  You can get
215f1ee322dSmrg         Bison from any GNU archive site."
216c43cc173Smrg    rm -f y.tab.c y.tab.h
217c43cc173Smrg    if test $# -ne 1; then
218f1ee322dSmrg        eval LASTARG=\${$#}
219c43cc173Smrg	case $LASTARG in
220c43cc173Smrg	*.y)
221c43cc173Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222c43cc173Smrg	    if test -f "$SRCFILE"; then
223c43cc173Smrg	         cp "$SRCFILE" y.tab.c
224c43cc173Smrg	    fi
225c43cc173Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226c43cc173Smrg	    if test -f "$SRCFILE"; then
227c43cc173Smrg	         cp "$SRCFILE" y.tab.h
228c43cc173Smrg	    fi
229c43cc173Smrg	  ;;
230c43cc173Smrg	esac
231c43cc173Smrg    fi
232c43cc173Smrg    if test ! -f y.tab.h; then
233c43cc173Smrg	echo >y.tab.h
234c43cc173Smrg    fi
235c43cc173Smrg    if test ! -f y.tab.c; then
236c43cc173Smrg	echo 'main() { return 0; }' >y.tab.c
237c43cc173Smrg    fi
238c43cc173Smrg    ;;
239c43cc173Smrg
240c27c18e8Smrg  lex*|flex*)
241c43cc173Smrg    echo 1>&2 "\
242f1ee322dSmrgWARNING: '$1' is $msg.  You should only need it if
243f1ee322dSmrg         you modified a '.l' file.  You may need the Flex package
244c43cc173Smrg         in order for those modifications to take effect.  You can get
245f1ee322dSmrg         Flex from any GNU archive site."
246c43cc173Smrg    rm -f lex.yy.c
247c43cc173Smrg    if test $# -ne 1; then
248f1ee322dSmrg        eval LASTARG=\${$#}
249c43cc173Smrg	case $LASTARG in
250c43cc173Smrg	*.l)
251c43cc173Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252c43cc173Smrg	    if test -f "$SRCFILE"; then
253c43cc173Smrg	         cp "$SRCFILE" lex.yy.c
254c43cc173Smrg	    fi
255c43cc173Smrg	  ;;
256c43cc173Smrg	esac
257c43cc173Smrg    fi
258c43cc173Smrg    if test ! -f lex.yy.c; then
259c43cc173Smrg	echo 'main() { return 0; }' >lex.yy.c
260c43cc173Smrg    fi
261c43cc173Smrg    ;;
262c43cc173Smrg
263c27c18e8Smrg  help2man*)
264c43cc173Smrg    echo 1>&2 "\
265f1ee322dSmrgWARNING: '$1' is $msg.  You should only need it if
266c43cc173Smrg	 you modified a dependency of a manual page.  You may need the
267f1ee322dSmrg	 Help2man package in order for those modifications to take
268f1ee322dSmrg	 effect.  You can get Help2man from any GNU archive site."
269c43cc173Smrg
270c43cc173Smrg    file=`echo "$*" | sed -n "$sed_output"`
271c43cc173Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
272c43cc173Smrg    if test -f "$file"; then
273c43cc173Smrg	touch $file
274c43cc173Smrg    else
275c43cc173Smrg	test -z "$file" || exec >$file
276c43cc173Smrg	echo ".ab help2man is required to generate this page"
277c27c18e8Smrg	exit $?
278c43cc173Smrg    fi
279c43cc173Smrg    ;;
280c43cc173Smrg
281c27c18e8Smrg  makeinfo*)
282c43cc173Smrg    echo 1>&2 "\
283f1ee322dSmrgWARNING: '$1' is $msg.  You should only need it if
284f1ee322dSmrg         you modified a '.texi' or '.texinfo' file, or any other file
285c43cc173Smrg         indirectly affecting the aspect of the manual.  The spurious
286f1ee322dSmrg         call might also be the consequence of using a buggy 'make' (AIX,
287f1ee322dSmrg         DU, IRIX).  You might want to install the Texinfo package or
288f1ee322dSmrg         the GNU make package.  Grab either from any GNU archive site."
289c43cc173Smrg    # The file to touch is that specified with -o ...
290c43cc173Smrg    file=`echo "$*" | sed -n "$sed_output"`
291c43cc173Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
292c43cc173Smrg    if test -z "$file"; then
293c43cc173Smrg      # ... or it is the one specified with @setfilename ...
294c43cc173Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
295c43cc173Smrg      file=`sed -n '
296c43cc173Smrg	/^@setfilename/{
297c43cc173Smrg	  s/.* \([^ ]*\) *$/\1/
298c43cc173Smrg	  p
299c43cc173Smrg	  q
300c43cc173Smrg	}' $infile`
301c43cc173Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
302c43cc173Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
303c43cc173Smrg    fi
304c43cc173Smrg    # If the file does not exist, the user really needs makeinfo;
305c43cc173Smrg    # let's fail without touching anything.
306c43cc173Smrg    test -f $file || exit 1
307c43cc173Smrg    touch $file
308c43cc173Smrg    ;;
309c43cc173Smrg
310c43cc173Smrg  *)
311c43cc173Smrg    echo 1>&2 "\
312f1ee322dSmrgWARNING: '$1' is needed, and is $msg.
313c43cc173Smrg         You might have modified some files without having the
314f1ee322dSmrg         proper tools for further handling them.  Check the 'README' file,
315c43cc173Smrg         it often tells you about the needed prerequisites for installing
316c43cc173Smrg         this package.  You may also peek at any GNU archive site, in case
317f1ee322dSmrg         some other package would contain this missing '$1' program."
318c43cc173Smrg    exit 1
319c43cc173Smrg    ;;
320c43cc173Smrgesac
321c43cc173Smrg
322c43cc173Smrgexit 0
323c43cc173Smrg
324c43cc173Smrg# Local variables:
325c43cc173Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
326c43cc173Smrg# time-stamp-start: "scriptversion="
327c43cc173Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
328c27c18e8Smrg# time-stamp-time-zone: "UTC"
329c27c18e8Smrg# time-stamp-end: "; # UTC"
330c43cc173Smrg# End:
331