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