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