missing revision 2ddb6cf1
1a1d141d5Smrg#! /bin/sh
2a1d141d5Smrg# Common stub for a few missing GNU programs while installing.
32ddb6cf1Smrg
42ddb6cf1Smrgscriptversion=2009-04-28.21; # UTC
52ddb6cf1Smrg
62ddb6cf1Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
72ddb6cf1Smrg# 2008, 2009 Free Software Foundation, Inc.
8a1d141d5Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9a1d141d5Smrg
10a1d141d5Smrg# This program is free software; you can redistribute it and/or modify
11a1d141d5Smrg# it under the terms of the GNU General Public License as published by
12a1d141d5Smrg# the Free Software Foundation; either version 2, or (at your option)
13a1d141d5Smrg# any later version.
14a1d141d5Smrg
15a1d141d5Smrg# This program is distributed in the hope that it will be useful,
16a1d141d5Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17a1d141d5Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18a1d141d5Smrg# GNU General Public License for more details.
19a1d141d5Smrg
20a1d141d5Smrg# You should have received a copy of the GNU General Public License
212ddb6cf1Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22a1d141d5Smrg
23a1d141d5Smrg# As a special exception to the GNU General Public License, if you
24a1d141d5Smrg# distribute this file as part of a program that contains a
25a1d141d5Smrg# configuration script generated by Autoconf, you may include it under
26a1d141d5Smrg# the same distribution terms that you use for the rest of that program.
27a1d141d5Smrg
28a1d141d5Smrgif test $# -eq 0; then
29a1d141d5Smrg  echo 1>&2 "Try \`$0 --help' for more information"
30a1d141d5Smrg  exit 1
31a1d141d5Smrgfi
32a1d141d5Smrg
33a1d141d5Smrgrun=:
342ddb6cf1Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
352ddb6cf1Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36a1d141d5Smrg
37a1d141d5Smrg# In the cases where this matters, `missing' is being run in the
38a1d141d5Smrg# srcdir already.
39a1d141d5Smrgif test -f configure.ac; then
40a1d141d5Smrg  configure_ac=configure.ac
41a1d141d5Smrgelse
42a1d141d5Smrg  configure_ac=configure.in
43a1d141d5Smrgfi
44a1d141d5Smrg
452ddb6cf1Smrgmsg="missing on your system"
462ddb6cf1Smrg
472ddb6cf1Smrgcase $1 in
48a1d141d5Smrg--run)
49a1d141d5Smrg  # Try to run requested program, and just exit if it succeeds.
50a1d141d5Smrg  run=
51a1d141d5Smrg  shift
52a1d141d5Smrg  "$@" && exit 0
532ddb6cf1Smrg  # Exit code 63 means version mismatch.  This often happens
542ddb6cf1Smrg  # when the user try to use an ancient version of a tool on
552ddb6cf1Smrg  # a file that requires a minimum version.  In this case we
562ddb6cf1Smrg  # we should proceed has if the program had been absent, or
572ddb6cf1Smrg  # if --run hadn't been passed.
582ddb6cf1Smrg  if test $? = 63; then
592ddb6cf1Smrg    run=:
602ddb6cf1Smrg    msg="probably too old"
612ddb6cf1Smrg  fi
62a1d141d5Smrg  ;;
63a1d141d5Smrg
64a1d141d5Smrg  -h|--h|--he|--hel|--help)
65a1d141d5Smrg    echo "\
66a1d141d5Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67a1d141d5Smrg
68a1d141d5SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69a1d141d5Smrgerror status if there is no known handling for PROGRAM.
70a1d141d5Smrg
71a1d141d5SmrgOptions:
72a1d141d5Smrg  -h, --help      display this help and exit
73a1d141d5Smrg  -v, --version   output version information and exit
74a1d141d5Smrg  --run           try to run the given command, and emulate it if it fails
75a1d141d5Smrg
76a1d141d5SmrgSupported PROGRAM values:
77a1d141d5Smrg  aclocal      touch file \`aclocal.m4'
78a1d141d5Smrg  autoconf     touch file \`configure'
79a1d141d5Smrg  autoheader   touch file \`config.h.in'
802ddb6cf1Smrg  autom4te     touch the output file, or create a stub one
81a1d141d5Smrg  automake     touch all \`Makefile.in' files
82a1d141d5Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83a1d141d5Smrg  flex         create \`lex.yy.c', if possible, from existing .c
84a1d141d5Smrg  help2man     touch the output file
85a1d141d5Smrg  lex          create \`lex.yy.c', if possible, from existing .c
86a1d141d5Smrg  makeinfo     touch the output file
87a1d141d5Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
882ddb6cf1Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
892ddb6cf1Smrg
902ddb6cf1SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
912ddb6cf1Smrg\`g' are ignored when checking the name.
922ddb6cf1Smrg
932ddb6cf1SmrgSend bug reports to <bug-automake@gnu.org>."
942ddb6cf1Smrg    exit $?
95a1d141d5Smrg    ;;
96a1d141d5Smrg
97a1d141d5Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
982ddb6cf1Smrg    echo "missing $scriptversion (GNU Automake)"
992ddb6cf1Smrg    exit $?
100a1d141d5Smrg    ;;
101a1d141d5Smrg
102a1d141d5Smrg  -*)
103a1d141d5Smrg    echo 1>&2 "$0: Unknown \`$1' option"
104a1d141d5Smrg    echo 1>&2 "Try \`$0 --help' for more information"
105a1d141d5Smrg    exit 1
106a1d141d5Smrg    ;;
107a1d141d5Smrg
1082ddb6cf1Smrgesac
1092ddb6cf1Smrg
1102ddb6cf1Smrg# normalize program name to check for.
1112ddb6cf1Smrgprogram=`echo "$1" | sed '
1122ddb6cf1Smrg  s/^gnu-//; t
1132ddb6cf1Smrg  s/^gnu//; t
1142ddb6cf1Smrg  s/^g//; t'`
1152ddb6cf1Smrg
1162ddb6cf1Smrg# Now exit if we have it, but it failed.  Also exit now if we
1172ddb6cf1Smrg# don't have it and --version was passed (most likely to detect
1182ddb6cf1Smrg# the program).  This is about non-GNU programs, so use $1 not
1192ddb6cf1Smrg# $program.
1202ddb6cf1Smrgcase $1 in
1212ddb6cf1Smrg  lex*|yacc*)
1222ddb6cf1Smrg    # Not GNU programs, they don't have --version.
1232ddb6cf1Smrg    ;;
1242ddb6cf1Smrg
1252ddb6cf1Smrg  tar*)
1262ddb6cf1Smrg    if test -n "$run"; then
1272ddb6cf1Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1282ddb6cf1Smrg       exit 1
1292ddb6cf1Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1302ddb6cf1Smrg       exit 1
1312ddb6cf1Smrg    fi
1322ddb6cf1Smrg    ;;
1332ddb6cf1Smrg
1342ddb6cf1Smrg  *)
135a1d141d5Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
136a1d141d5Smrg       # We have it, but it failed.
137a1d141d5Smrg       exit 1
1382ddb6cf1Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1392ddb6cf1Smrg       # Could not run --version or --help.  This is probably someone
1402ddb6cf1Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1412ddb6cf1Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1422ddb6cf1Smrg       exit 1
143a1d141d5Smrg    fi
1442ddb6cf1Smrg    ;;
1452ddb6cf1Smrgesac
146a1d141d5Smrg
1472ddb6cf1Smrg# If it does not exist, or fails to run (possibly an outdated version),
1482ddb6cf1Smrg# try to emulate it.
1492ddb6cf1Smrgcase $program in
1502ddb6cf1Smrg  aclocal*)
151a1d141d5Smrg    echo 1>&2 "\
1522ddb6cf1SmrgWARNING: \`$1' is $msg.  You should only need it if
153a1d141d5Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
154a1d141d5Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
155a1d141d5Smrg         any GNU archive site."
156a1d141d5Smrg    touch aclocal.m4
157a1d141d5Smrg    ;;
158a1d141d5Smrg
1592ddb6cf1Smrg  autoconf*)
160a1d141d5Smrg    echo 1>&2 "\
1612ddb6cf1SmrgWARNING: \`$1' is $msg.  You should only need it if
162a1d141d5Smrg         you modified \`${configure_ac}'.  You might want to install the
163a1d141d5Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
164a1d141d5Smrg         archive site."
165a1d141d5Smrg    touch configure
166a1d141d5Smrg    ;;
167a1d141d5Smrg
1682ddb6cf1Smrg  autoheader*)
169a1d141d5Smrg    echo 1>&2 "\
1702ddb6cf1SmrgWARNING: \`$1' is $msg.  You should only need it if
171a1d141d5Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
172a1d141d5Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
173a1d141d5Smrg         from any GNU archive site."
174a1d141d5Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
175a1d141d5Smrg    test -z "$files" && files="config.h"
176a1d141d5Smrg    touch_files=
177a1d141d5Smrg    for f in $files; do
1782ddb6cf1Smrg      case $f in
179a1d141d5Smrg      *:*) touch_files="$touch_files "`echo "$f" |
180a1d141d5Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
181a1d141d5Smrg      *) touch_files="$touch_files $f.in";;
182a1d141d5Smrg      esac
183a1d141d5Smrg    done
184a1d141d5Smrg    touch $touch_files
185a1d141d5Smrg    ;;
186a1d141d5Smrg
187a1d141d5Smrg  automake*)
188a1d141d5Smrg    echo 1>&2 "\
1892ddb6cf1SmrgWARNING: \`$1' is $msg.  You should only need it if
190a1d141d5Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
191a1d141d5Smrg         You might want to install the \`Automake' and \`Perl' packages.
192a1d141d5Smrg         Grab them from any GNU archive site."
193a1d141d5Smrg    find . -type f -name Makefile.am -print |
194a1d141d5Smrg	   sed 's/\.am$/.in/' |
195a1d141d5Smrg	   while read f; do touch "$f"; done
196a1d141d5Smrg    ;;
197a1d141d5Smrg
1982ddb6cf1Smrg  autom4te*)
199a1d141d5Smrg    echo 1>&2 "\
2002ddb6cf1SmrgWARNING: \`$1' is needed, but is $msg.
2012ddb6cf1Smrg         You might have modified some files without having the
202a1d141d5Smrg         proper tools for further handling them.
203a1d141d5Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
204a1d141d5Smrg         archive site."
205a1d141d5Smrg
2062ddb6cf1Smrg    file=`echo "$*" | sed -n "$sed_output"`
2072ddb6cf1Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
208a1d141d5Smrg    if test -f "$file"; then
209a1d141d5Smrg	touch $file
210a1d141d5Smrg    else
211a1d141d5Smrg	test -z "$file" || exec >$file
212a1d141d5Smrg	echo "#! /bin/sh"
213a1d141d5Smrg	echo "# Created by GNU Automake missing as a replacement of"
214a1d141d5Smrg	echo "#  $ $@"
215a1d141d5Smrg	echo "exit 0"
216a1d141d5Smrg	chmod +x $file
217a1d141d5Smrg	exit 1
218a1d141d5Smrg    fi
219a1d141d5Smrg    ;;
220a1d141d5Smrg
2212ddb6cf1Smrg  bison*|yacc*)
222a1d141d5Smrg    echo 1>&2 "\
2232ddb6cf1SmrgWARNING: \`$1' $msg.  You should only need it if
224a1d141d5Smrg         you modified a \`.y' file.  You may need the \`Bison' package
225a1d141d5Smrg         in order for those modifications to take effect.  You can get
226a1d141d5Smrg         \`Bison' from any GNU archive site."
227a1d141d5Smrg    rm -f y.tab.c y.tab.h
2282ddb6cf1Smrg    if test $# -ne 1; then
229a1d141d5Smrg        eval LASTARG="\${$#}"
2302ddb6cf1Smrg	case $LASTARG in
231a1d141d5Smrg	*.y)
232a1d141d5Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2332ddb6cf1Smrg	    if test -f "$SRCFILE"; then
234a1d141d5Smrg	         cp "$SRCFILE" y.tab.c
235a1d141d5Smrg	    fi
236a1d141d5Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2372ddb6cf1Smrg	    if test -f "$SRCFILE"; then
238a1d141d5Smrg	         cp "$SRCFILE" y.tab.h
239a1d141d5Smrg	    fi
240a1d141d5Smrg	  ;;
241a1d141d5Smrg	esac
242a1d141d5Smrg    fi
2432ddb6cf1Smrg    if test ! -f y.tab.h; then
244a1d141d5Smrg	echo >y.tab.h
245a1d141d5Smrg    fi
2462ddb6cf1Smrg    if test ! -f y.tab.c; then
247a1d141d5Smrg	echo 'main() { return 0; }' >y.tab.c
248a1d141d5Smrg    fi
249a1d141d5Smrg    ;;
250a1d141d5Smrg
2512ddb6cf1Smrg  lex*|flex*)
252a1d141d5Smrg    echo 1>&2 "\
2532ddb6cf1SmrgWARNING: \`$1' is $msg.  You should only need it if
254a1d141d5Smrg         you modified a \`.l' file.  You may need the \`Flex' package
255a1d141d5Smrg         in order for those modifications to take effect.  You can get
256a1d141d5Smrg         \`Flex' from any GNU archive site."
257a1d141d5Smrg    rm -f lex.yy.c
2582ddb6cf1Smrg    if test $# -ne 1; then
259a1d141d5Smrg        eval LASTARG="\${$#}"
2602ddb6cf1Smrg	case $LASTARG in
261a1d141d5Smrg	*.l)
262a1d141d5Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2632ddb6cf1Smrg	    if test -f "$SRCFILE"; then
264a1d141d5Smrg	         cp "$SRCFILE" lex.yy.c
265a1d141d5Smrg	    fi
266a1d141d5Smrg	  ;;
267a1d141d5Smrg	esac
268a1d141d5Smrg    fi
2692ddb6cf1Smrg    if test ! -f lex.yy.c; then
270a1d141d5Smrg	echo 'main() { return 0; }' >lex.yy.c
271a1d141d5Smrg    fi
272a1d141d5Smrg    ;;
273a1d141d5Smrg
2742ddb6cf1Smrg  help2man*)
275a1d141d5Smrg    echo 1>&2 "\
2762ddb6cf1SmrgWARNING: \`$1' is $msg.  You should only need it if
277a1d141d5Smrg	 you modified a dependency of a manual page.  You may need the
278a1d141d5Smrg	 \`Help2man' package in order for those modifications to take
279a1d141d5Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
280a1d141d5Smrg
2812ddb6cf1Smrg    file=`echo "$*" | sed -n "$sed_output"`
2822ddb6cf1Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2832ddb6cf1Smrg    if test -f "$file"; then
284a1d141d5Smrg	touch $file
285a1d141d5Smrg    else
286a1d141d5Smrg	test -z "$file" || exec >$file
287a1d141d5Smrg	echo ".ab help2man is required to generate this page"
2882ddb6cf1Smrg	exit $?
289a1d141d5Smrg    fi
290a1d141d5Smrg    ;;
291a1d141d5Smrg
2922ddb6cf1Smrg  makeinfo*)
293a1d141d5Smrg    echo 1>&2 "\
2942ddb6cf1SmrgWARNING: \`$1' is $msg.  You should only need it if
295a1d141d5Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
296a1d141d5Smrg         indirectly affecting the aspect of the manual.  The spurious
297a1d141d5Smrg         call might also be the consequence of using a buggy \`make' (AIX,
298a1d141d5Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
299a1d141d5Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
3002ddb6cf1Smrg    # The file to touch is that specified with -o ...
3012ddb6cf1Smrg    file=`echo "$*" | sed -n "$sed_output"`
3022ddb6cf1Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
303a1d141d5Smrg    if test -z "$file"; then
3042ddb6cf1Smrg      # ... or it is the one specified with @setfilename ...
3052ddb6cf1Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3062ddb6cf1Smrg      file=`sed -n '
3072ddb6cf1Smrg	/^@setfilename/{
3082ddb6cf1Smrg	  s/.* \([^ ]*\) *$/\1/
3092ddb6cf1Smrg	  p
3102ddb6cf1Smrg	  q
3112ddb6cf1Smrg	}' $infile`
3122ddb6cf1Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3132ddb6cf1Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
314a1d141d5Smrg    fi
3152ddb6cf1Smrg    # If the file does not exist, the user really needs makeinfo;
3162ddb6cf1Smrg    # let's fail without touching anything.
3172ddb6cf1Smrg    test -f $file || exit 1
318a1d141d5Smrg    touch $file
319a1d141d5Smrg    ;;
320a1d141d5Smrg
3212ddb6cf1Smrg  tar*)
322a1d141d5Smrg    shift
323a1d141d5Smrg
324a1d141d5Smrg    # We have already tried tar in the generic part.
325a1d141d5Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
326a1d141d5Smrg    # messages.
327a1d141d5Smrg    if (gnutar --version > /dev/null 2>&1); then
328a1d141d5Smrg       gnutar "$@" && exit 0
329a1d141d5Smrg    fi
330a1d141d5Smrg    if (gtar --version > /dev/null 2>&1); then
331a1d141d5Smrg       gtar "$@" && exit 0
332a1d141d5Smrg    fi
333a1d141d5Smrg    firstarg="$1"
334a1d141d5Smrg    if shift; then
3352ddb6cf1Smrg	case $firstarg in
336a1d141d5Smrg	*o*)
337a1d141d5Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
338a1d141d5Smrg	    tar "$firstarg" "$@" && exit 0
339a1d141d5Smrg	    ;;
340a1d141d5Smrg	esac
3412ddb6cf1Smrg	case $firstarg in
342a1d141d5Smrg	*h*)
343a1d141d5Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
344a1d141d5Smrg	    tar "$firstarg" "$@" && exit 0
345a1d141d5Smrg	    ;;
346a1d141d5Smrg	esac
347a1d141d5Smrg    fi
348a1d141d5Smrg
349a1d141d5Smrg    echo 1>&2 "\
350a1d141d5SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
351a1d141d5Smrg         You may want to install GNU tar or Free paxutils, or check the
352a1d141d5Smrg         command line arguments."
353a1d141d5Smrg    exit 1
354a1d141d5Smrg    ;;
355a1d141d5Smrg
356a1d141d5Smrg  *)
357a1d141d5Smrg    echo 1>&2 "\
3582ddb6cf1SmrgWARNING: \`$1' is needed, and is $msg.
3592ddb6cf1Smrg         You might have modified some files without having the
360a1d141d5Smrg         proper tools for further handling them.  Check the \`README' file,
361a1d141d5Smrg         it often tells you about the needed prerequisites for installing
362a1d141d5Smrg         this package.  You may also peek at any GNU archive site, in case
363a1d141d5Smrg         some other package would contain this missing \`$1' program."
364a1d141d5Smrg    exit 1
365a1d141d5Smrg    ;;
366a1d141d5Smrgesac
367a1d141d5Smrg
368a1d141d5Smrgexit 0
3692ddb6cf1Smrg
3702ddb6cf1Smrg# Local variables:
3712ddb6cf1Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3722ddb6cf1Smrg# time-stamp-start: "scriptversion="
3732ddb6cf1Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3742ddb6cf1Smrg# time-stamp-time-zone: "UTC"
3752ddb6cf1Smrg# time-stamp-end: "; # UTC"
3762ddb6cf1Smrg# End:
377