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