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