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