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