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