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