missing revision ba064abe
1191cded7Smrg#! /bin/sh
2191cded7Smrg# Common stub for a few missing GNU programs while installing.
3191cded7Smrg
4ba064abeSmrgscriptversion=2009-04-28.21; # UTC
5191cded7Smrg
6ba064abeSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7ba064abeSmrg# 2008, 2009 Free Software Foundation, Inc.
8191cded7Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9191cded7Smrg
10191cded7Smrg# This program is free software; you can redistribute it and/or modify
11191cded7Smrg# it under the terms of the GNU General Public License as published by
12191cded7Smrg# the Free Software Foundation; either version 2, or (at your option)
13191cded7Smrg# any later version.
14191cded7Smrg
15191cded7Smrg# This program is distributed in the hope that it will be useful,
16191cded7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17191cded7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18191cded7Smrg# GNU General Public License for more details.
19191cded7Smrg
20191cded7Smrg# You should have received a copy of the GNU General Public License
21ba064abeSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22191cded7Smrg
23191cded7Smrg# As a special exception to the GNU General Public License, if you
24191cded7Smrg# distribute this file as part of a program that contains a
25191cded7Smrg# configuration script generated by Autoconf, you may include it under
26191cded7Smrg# the same distribution terms that you use for the rest of that program.
27191cded7Smrg
28191cded7Smrgif test $# -eq 0; then
29191cded7Smrg  echo 1>&2 "Try \`$0 --help' for more information"
30191cded7Smrg  exit 1
31191cded7Smrgfi
32191cded7Smrg
33191cded7Smrgrun=:
34b290cf36Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35b290cf36Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36191cded7Smrg
37191cded7Smrg# In the cases where this matters, `missing' is being run in the
38191cded7Smrg# srcdir already.
39191cded7Smrgif test -f configure.ac; then
40191cded7Smrg  configure_ac=configure.ac
41191cded7Smrgelse
42191cded7Smrg  configure_ac=configure.in
43191cded7Smrgfi
44191cded7Smrg
45191cded7Smrgmsg="missing on your system"
46191cded7Smrg
47b290cf36Smrgcase $1 in
48191cded7Smrg--run)
49191cded7Smrg  # Try to run requested program, and just exit if it succeeds.
50191cded7Smrg  run=
51191cded7Smrg  shift
52191cded7Smrg  "$@" && exit 0
53191cded7Smrg  # Exit code 63 means version mismatch.  This often happens
54191cded7Smrg  # when the user try to use an ancient version of a tool on
55191cded7Smrg  # a file that requires a minimum version.  In this case we
56191cded7Smrg  # we should proceed has if the program had been absent, or
57191cded7Smrg  # if --run hadn't been passed.
58191cded7Smrg  if test $? = 63; then
59191cded7Smrg    run=:
60191cded7Smrg    msg="probably too old"
61191cded7Smrg  fi
62191cded7Smrg  ;;
63191cded7Smrg
64191cded7Smrg  -h|--h|--he|--hel|--help)
65191cded7Smrg    echo "\
66191cded7Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67191cded7Smrg
68191cded7SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69191cded7Smrgerror status if there is no known handling for PROGRAM.
70191cded7Smrg
71191cded7SmrgOptions:
72191cded7Smrg  -h, --help      display this help and exit
73191cded7Smrg  -v, --version   output version information and exit
74191cded7Smrg  --run           try to run the given command, and emulate it if it fails
75191cded7Smrg
76191cded7SmrgSupported PROGRAM values:
77191cded7Smrg  aclocal      touch file \`aclocal.m4'
78191cded7Smrg  autoconf     touch file \`configure'
79191cded7Smrg  autoheader   touch file \`config.h.in'
80b290cf36Smrg  autom4te     touch the output file, or create a stub one
81191cded7Smrg  automake     touch all \`Makefile.in' files
82191cded7Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83191cded7Smrg  flex         create \`lex.yy.c', if possible, from existing .c
84191cded7Smrg  help2man     touch the output file
85191cded7Smrg  lex          create \`lex.yy.c', if possible, from existing .c
86191cded7Smrg  makeinfo     touch the output file
87191cded7Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
88191cded7Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
89191cded7Smrg
90ba064abeSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91ba064abeSmrg\`g' are ignored when checking the name.
92ba064abeSmrg
93191cded7SmrgSend bug reports to <bug-automake@gnu.org>."
94191cded7Smrg    exit $?
95191cded7Smrg    ;;
96191cded7Smrg
97191cded7Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
98191cded7Smrg    echo "missing $scriptversion (GNU Automake)"
99191cded7Smrg    exit $?
100191cded7Smrg    ;;
101191cded7Smrg
102191cded7Smrg  -*)
103191cded7Smrg    echo 1>&2 "$0: Unknown \`$1' option"
104191cded7Smrg    echo 1>&2 "Try \`$0 --help' for more information"
105191cded7Smrg    exit 1
106191cded7Smrg    ;;
107191cded7Smrg
108191cded7Smrgesac
109191cded7Smrg
110ba064abeSmrg# normalize program name to check for.
111ba064abeSmrgprogram=`echo "$1" | sed '
112ba064abeSmrg  s/^gnu-//; t
113ba064abeSmrg  s/^gnu//; t
114ba064abeSmrg  s/^g//; t'`
115ba064abeSmrg
116191cded7Smrg# Now exit if we have it, but it failed.  Also exit now if we
117191cded7Smrg# don't have it and --version was passed (most likely to detect
118ba064abeSmrg# the program).  This is about non-GNU programs, so use $1 not
119ba064abeSmrg# $program.
120b290cf36Smrgcase $1 in
121ba064abeSmrg  lex*|yacc*)
122191cded7Smrg    # Not GNU programs, they don't have --version.
123191cded7Smrg    ;;
124191cded7Smrg
125ba064abeSmrg  tar*)
126191cded7Smrg    if test -n "$run"; then
127191cded7Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
128191cded7Smrg       exit 1
129191cded7Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
130191cded7Smrg       exit 1
131191cded7Smrg    fi
132191cded7Smrg    ;;
133191cded7Smrg
134191cded7Smrg  *)
135191cded7Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
136191cded7Smrg       # We have it, but it failed.
137191cded7Smrg       exit 1
138191cded7Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
139191cded7Smrg       # Could not run --version or --help.  This is probably someone
140191cded7Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
141191cded7Smrg       # $TOOL exists and not knowing $TOOL uses missing.
142191cded7Smrg       exit 1
143191cded7Smrg    fi
144191cded7Smrg    ;;
145191cded7Smrgesac
146191cded7Smrg
147191cded7Smrg# If it does not exist, or fails to run (possibly an outdated version),
148191cded7Smrg# try to emulate it.
149ba064abeSmrgcase $program in
150191cded7Smrg  aclocal*)
151191cded7Smrg    echo 1>&2 "\
152191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
153191cded7Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
154191cded7Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
155191cded7Smrg         any GNU archive site."
156191cded7Smrg    touch aclocal.m4
157191cded7Smrg    ;;
158191cded7Smrg
159ba064abeSmrg  autoconf*)
160191cded7Smrg    echo 1>&2 "\
161191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
162191cded7Smrg         you modified \`${configure_ac}'.  You might want to install the
163191cded7Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
164191cded7Smrg         archive site."
165191cded7Smrg    touch configure
166191cded7Smrg    ;;
167191cded7Smrg
168ba064abeSmrg  autoheader*)
169191cded7Smrg    echo 1>&2 "\
170191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
171191cded7Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
172191cded7Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
173191cded7Smrg         from any GNU archive site."
174191cded7Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
175191cded7Smrg    test -z "$files" && files="config.h"
176191cded7Smrg    touch_files=
177191cded7Smrg    for f in $files; do
178b290cf36Smrg      case $f in
179191cded7Smrg      *:*) touch_files="$touch_files "`echo "$f" |
180191cded7Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
181191cded7Smrg      *) touch_files="$touch_files $f.in";;
182191cded7Smrg      esac
183191cded7Smrg    done
184191cded7Smrg    touch $touch_files
185191cded7Smrg    ;;
186191cded7Smrg
187191cded7Smrg  automake*)
188191cded7Smrg    echo 1>&2 "\
189191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
190191cded7Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
191191cded7Smrg         You might want to install the \`Automake' and \`Perl' packages.
192191cded7Smrg         Grab them from any GNU archive site."
193191cded7Smrg    find . -type f -name Makefile.am -print |
194191cded7Smrg	   sed 's/\.am$/.in/' |
195191cded7Smrg	   while read f; do touch "$f"; done
196191cded7Smrg    ;;
197191cded7Smrg
198ba064abeSmrg  autom4te*)
199191cded7Smrg    echo 1>&2 "\
200191cded7SmrgWARNING: \`$1' is needed, but is $msg.
201191cded7Smrg         You might have modified some files without having the
202191cded7Smrg         proper tools for further handling them.
203191cded7Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
204191cded7Smrg         archive site."
205191cded7Smrg
206b290cf36Smrg    file=`echo "$*" | sed -n "$sed_output"`
207b290cf36Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
208191cded7Smrg    if test -f "$file"; then
209191cded7Smrg	touch $file
210191cded7Smrg    else
211191cded7Smrg	test -z "$file" || exec >$file
212191cded7Smrg	echo "#! /bin/sh"
213191cded7Smrg	echo "# Created by GNU Automake missing as a replacement of"
214191cded7Smrg	echo "#  $ $@"
215191cded7Smrg	echo "exit 0"
216191cded7Smrg	chmod +x $file
217191cded7Smrg	exit 1
218191cded7Smrg    fi
219191cded7Smrg    ;;
220191cded7Smrg
221ba064abeSmrg  bison*|yacc*)
222191cded7Smrg    echo 1>&2 "\
223191cded7SmrgWARNING: \`$1' $msg.  You should only need it if
224191cded7Smrg         you modified a \`.y' file.  You may need the \`Bison' package
225191cded7Smrg         in order for those modifications to take effect.  You can get
226191cded7Smrg         \`Bison' from any GNU archive site."
227191cded7Smrg    rm -f y.tab.c y.tab.h
228b290cf36Smrg    if test $# -ne 1; then
229191cded7Smrg        eval LASTARG="\${$#}"
230b290cf36Smrg	case $LASTARG in
231191cded7Smrg	*.y)
232191cded7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
233b290cf36Smrg	    if test -f "$SRCFILE"; then
234191cded7Smrg	         cp "$SRCFILE" y.tab.c
235191cded7Smrg	    fi
236191cded7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
237b290cf36Smrg	    if test -f "$SRCFILE"; then
238191cded7Smrg	         cp "$SRCFILE" y.tab.h
239191cded7Smrg	    fi
240191cded7Smrg	  ;;
241191cded7Smrg	esac
242191cded7Smrg    fi
243b290cf36Smrg    if test ! -f y.tab.h; then
244191cded7Smrg	echo >y.tab.h
245191cded7Smrg    fi
246b290cf36Smrg    if test ! -f y.tab.c; then
247191cded7Smrg	echo 'main() { return 0; }' >y.tab.c
248191cded7Smrg    fi
249191cded7Smrg    ;;
250191cded7Smrg
251ba064abeSmrg  lex*|flex*)
252191cded7Smrg    echo 1>&2 "\
253191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
254191cded7Smrg         you modified a \`.l' file.  You may need the \`Flex' package
255191cded7Smrg         in order for those modifications to take effect.  You can get
256191cded7Smrg         \`Flex' from any GNU archive site."
257191cded7Smrg    rm -f lex.yy.c
258b290cf36Smrg    if test $# -ne 1; then
259191cded7Smrg        eval LASTARG="\${$#}"
260b290cf36Smrg	case $LASTARG in
261191cded7Smrg	*.l)
262191cded7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
263b290cf36Smrg	    if test -f "$SRCFILE"; then
264191cded7Smrg	         cp "$SRCFILE" lex.yy.c
265191cded7Smrg	    fi
266191cded7Smrg	  ;;
267191cded7Smrg	esac
268191cded7Smrg    fi
269b290cf36Smrg    if test ! -f lex.yy.c; then
270191cded7Smrg	echo 'main() { return 0; }' >lex.yy.c
271191cded7Smrg    fi
272191cded7Smrg    ;;
273191cded7Smrg
274ba064abeSmrg  help2man*)
275191cded7Smrg    echo 1>&2 "\
276191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
277191cded7Smrg	 you modified a dependency of a manual page.  You may need the
278191cded7Smrg	 \`Help2man' package in order for those modifications to take
279191cded7Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
280191cded7Smrg
281b290cf36Smrg    file=`echo "$*" | sed -n "$sed_output"`
282b290cf36Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
283b290cf36Smrg    if test -f "$file"; then
284191cded7Smrg	touch $file
285191cded7Smrg    else
286191cded7Smrg	test -z "$file" || exec >$file
287191cded7Smrg	echo ".ab help2man is required to generate this page"
288ba064abeSmrg	exit $?
289191cded7Smrg    fi
290191cded7Smrg    ;;
291191cded7Smrg
292ba064abeSmrg  makeinfo*)
293191cded7Smrg    echo 1>&2 "\
294191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
295191cded7Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
296191cded7Smrg         indirectly affecting the aspect of the manual.  The spurious
297191cded7Smrg         call might also be the consequence of using a buggy \`make' (AIX,
298191cded7Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
299191cded7Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
300191cded7Smrg    # The file to touch is that specified with -o ...
301b290cf36Smrg    file=`echo "$*" | sed -n "$sed_output"`
302b290cf36Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
303191cded7Smrg    if test -z "$file"; then
304191cded7Smrg      # ... or it is the one specified with @setfilename ...
305191cded7Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
306b290cf36Smrg      file=`sed -n '
307b290cf36Smrg	/^@setfilename/{
308b290cf36Smrg	  s/.* \([^ ]*\) *$/\1/
309b290cf36Smrg	  p
310b290cf36Smrg	  q
311b290cf36Smrg	}' $infile`
312191cded7Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
313191cded7Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
314191cded7Smrg    fi
315191cded7Smrg    # If the file does not exist, the user really needs makeinfo;
316191cded7Smrg    # let's fail without touching anything.
317191cded7Smrg    test -f $file || exit 1
318191cded7Smrg    touch $file
319191cded7Smrg    ;;
320191cded7Smrg
321ba064abeSmrg  tar*)
322191cded7Smrg    shift
323191cded7Smrg
324191cded7Smrg    # We have already tried tar in the generic part.
325191cded7Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
326191cded7Smrg    # messages.
327191cded7Smrg    if (gnutar --version > /dev/null 2>&1); then
328191cded7Smrg       gnutar "$@" && exit 0
329191cded7Smrg    fi
330191cded7Smrg    if (gtar --version > /dev/null 2>&1); then
331191cded7Smrg       gtar "$@" && exit 0
332191cded7Smrg    fi
333191cded7Smrg    firstarg="$1"
334191cded7Smrg    if shift; then
335b290cf36Smrg	case $firstarg in
336191cded7Smrg	*o*)
337191cded7Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
338191cded7Smrg	    tar "$firstarg" "$@" && exit 0
339191cded7Smrg	    ;;
340191cded7Smrg	esac
341b290cf36Smrg	case $firstarg in
342191cded7Smrg	*h*)
343191cded7Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
344191cded7Smrg	    tar "$firstarg" "$@" && exit 0
345191cded7Smrg	    ;;
346191cded7Smrg	esac
347191cded7Smrg    fi
348191cded7Smrg
349191cded7Smrg    echo 1>&2 "\
350191cded7SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
351191cded7Smrg         You may want to install GNU tar or Free paxutils, or check the
352191cded7Smrg         command line arguments."
353191cded7Smrg    exit 1
354191cded7Smrg    ;;
355191cded7Smrg
356191cded7Smrg  *)
357191cded7Smrg    echo 1>&2 "\
358191cded7SmrgWARNING: \`$1' is needed, and is $msg.
359191cded7Smrg         You might have modified some files without having the
360191cded7Smrg         proper tools for further handling them.  Check the \`README' file,
361191cded7Smrg         it often tells you about the needed prerequisites for installing
362191cded7Smrg         this package.  You may also peek at any GNU archive site, in case
363191cded7Smrg         some other package would contain this missing \`$1' program."
364191cded7Smrg    exit 1
365191cded7Smrg    ;;
366191cded7Smrgesac
367191cded7Smrg
368191cded7Smrgexit 0
369191cded7Smrg
370191cded7Smrg# Local variables:
371191cded7Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
372191cded7Smrg# time-stamp-start: "scriptversion="
373191cded7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374ba064abeSmrg# time-stamp-time-zone: "UTC"
375ba064abeSmrg# time-stamp-end: "; # UTC"
376191cded7Smrg# End:
377