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