missing revision c37a63b8
1264fa531Smrg#! /bin/sh
2264fa531Smrg# Common stub for a few missing GNU programs while installing.
3c37a63b8Smrg
4c37a63b8Smrgscriptversion=2009-04-28.21; # UTC
5c37a63b8Smrg
6c37a63b8Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7c37a63b8Smrg# 2008, 2009 Free Software Foundation, Inc.
8264fa531Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9264fa531Smrg
10264fa531Smrg# This program is free software; you can redistribute it and/or modify
11264fa531Smrg# it under the terms of the GNU General Public License as published by
12264fa531Smrg# the Free Software Foundation; either version 2, or (at your option)
13264fa531Smrg# any later version.
14264fa531Smrg
15264fa531Smrg# This program is distributed in the hope that it will be useful,
16264fa531Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17264fa531Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18264fa531Smrg# GNU General Public License for more details.
19264fa531Smrg
20264fa531Smrg# You should have received a copy of the GNU General Public License
21c37a63b8Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22264fa531Smrg
23264fa531Smrg# As a special exception to the GNU General Public License, if you
24264fa531Smrg# distribute this file as part of a program that contains a
25264fa531Smrg# configuration script generated by Autoconf, you may include it under
26264fa531Smrg# the same distribution terms that you use for the rest of that program.
27264fa531Smrg
28264fa531Smrgif test $# -eq 0; then
29264fa531Smrg  echo 1>&2 "Try \`$0 --help' for more information"
30264fa531Smrg  exit 1
31264fa531Smrgfi
32264fa531Smrg
33264fa531Smrgrun=:
34c37a63b8Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35c37a63b8Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36264fa531Smrg
37264fa531Smrg# In the cases where this matters, `missing' is being run in the
38264fa531Smrg# srcdir already.
39264fa531Smrgif test -f configure.ac; then
40264fa531Smrg  configure_ac=configure.ac
41264fa531Smrgelse
42264fa531Smrg  configure_ac=configure.in
43264fa531Smrgfi
44264fa531Smrg
45c37a63b8Smrgmsg="missing on your system"
46c37a63b8Smrg
47c37a63b8Smrgcase $1 in
48264fa531Smrg--run)
49264fa531Smrg  # Try to run requested program, and just exit if it succeeds.
50264fa531Smrg  run=
51264fa531Smrg  shift
52264fa531Smrg  "$@" && exit 0
53c37a63b8Smrg  # Exit code 63 means version mismatch.  This often happens
54c37a63b8Smrg  # when the user try to use an ancient version of a tool on
55c37a63b8Smrg  # a file that requires a minimum version.  In this case we
56c37a63b8Smrg  # we should proceed has if the program had been absent, or
57c37a63b8Smrg  # if --run hadn't been passed.
58c37a63b8Smrg  if test $? = 63; then
59c37a63b8Smrg    run=:
60c37a63b8Smrg    msg="probably too old"
61c37a63b8Smrg  fi
62264fa531Smrg  ;;
63264fa531Smrg
64264fa531Smrg  -h|--h|--he|--hel|--help)
65264fa531Smrg    echo "\
66264fa531Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67264fa531Smrg
68264fa531SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69264fa531Smrgerror status if there is no known handling for PROGRAM.
70264fa531Smrg
71264fa531SmrgOptions:
72264fa531Smrg  -h, --help      display this help and exit
73264fa531Smrg  -v, --version   output version information and exit
74264fa531Smrg  --run           try to run the given command, and emulate it if it fails
75264fa531Smrg
76264fa531SmrgSupported PROGRAM values:
77264fa531Smrg  aclocal      touch file \`aclocal.m4'
78264fa531Smrg  autoconf     touch file \`configure'
79264fa531Smrg  autoheader   touch file \`config.h.in'
80c37a63b8Smrg  autom4te     touch the output file, or create a stub one
81264fa531Smrg  automake     touch all \`Makefile.in' files
82264fa531Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83264fa531Smrg  flex         create \`lex.yy.c', if possible, from existing .c
84264fa531Smrg  help2man     touch the output file
85264fa531Smrg  lex          create \`lex.yy.c', if possible, from existing .c
86264fa531Smrg  makeinfo     touch the output file
87264fa531Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
88c37a63b8Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
89c37a63b8Smrg
90c37a63b8SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91c37a63b8Smrg\`g' are ignored when checking the name.
92c37a63b8Smrg
93c37a63b8SmrgSend bug reports to <bug-automake@gnu.org>."
94c37a63b8Smrg    exit $?
95264fa531Smrg    ;;
96264fa531Smrg
97264fa531Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
98c37a63b8Smrg    echo "missing $scriptversion (GNU Automake)"
99c37a63b8Smrg    exit $?
100264fa531Smrg    ;;
101264fa531Smrg
102264fa531Smrg  -*)
103264fa531Smrg    echo 1>&2 "$0: Unknown \`$1' option"
104264fa531Smrg    echo 1>&2 "Try \`$0 --help' for more information"
105264fa531Smrg    exit 1
106264fa531Smrg    ;;
107264fa531Smrg
108c37a63b8Smrgesac
109c37a63b8Smrg
110c37a63b8Smrg# normalize program name to check for.
111c37a63b8Smrgprogram=`echo "$1" | sed '
112c37a63b8Smrg  s/^gnu-//; t
113c37a63b8Smrg  s/^gnu//; t
114c37a63b8Smrg  s/^g//; t'`
115c37a63b8Smrg
116c37a63b8Smrg# Now exit if we have it, but it failed.  Also exit now if we
117c37a63b8Smrg# don't have it and --version was passed (most likely to detect
118c37a63b8Smrg# the program).  This is about non-GNU programs, so use $1 not
119c37a63b8Smrg# $program.
120c37a63b8Smrgcase $1 in
121c37a63b8Smrg  lex*|yacc*)
122c37a63b8Smrg    # Not GNU programs, they don't have --version.
123c37a63b8Smrg    ;;
124c37a63b8Smrg
125c37a63b8Smrg  tar*)
126c37a63b8Smrg    if test -n "$run"; then
127c37a63b8Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
128c37a63b8Smrg       exit 1
129c37a63b8Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
130c37a63b8Smrg       exit 1
131c37a63b8Smrg    fi
132c37a63b8Smrg    ;;
133c37a63b8Smrg
134c37a63b8Smrg  *)
135264fa531Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
136264fa531Smrg       # We have it, but it failed.
137264fa531Smrg       exit 1
138c37a63b8Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
139c37a63b8Smrg       # Could not run --version or --help.  This is probably someone
140c37a63b8Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
141c37a63b8Smrg       # $TOOL exists and not knowing $TOOL uses missing.
142c37a63b8Smrg       exit 1
143264fa531Smrg    fi
144c37a63b8Smrg    ;;
145c37a63b8Smrgesac
146264fa531Smrg
147c37a63b8Smrg# If it does not exist, or fails to run (possibly an outdated version),
148c37a63b8Smrg# try to emulate it.
149c37a63b8Smrgcase $program in
150c37a63b8Smrg  aclocal*)
151264fa531Smrg    echo 1>&2 "\
152c37a63b8SmrgWARNING: \`$1' is $msg.  You should only need it if
153264fa531Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
154264fa531Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
155264fa531Smrg         any GNU archive site."
156264fa531Smrg    touch aclocal.m4
157264fa531Smrg    ;;
158264fa531Smrg
159c37a63b8Smrg  autoconf*)
160264fa531Smrg    echo 1>&2 "\
161c37a63b8SmrgWARNING: \`$1' is $msg.  You should only need it if
162264fa531Smrg         you modified \`${configure_ac}'.  You might want to install the
163264fa531Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
164264fa531Smrg         archive site."
165264fa531Smrg    touch configure
166264fa531Smrg    ;;
167264fa531Smrg
168c37a63b8Smrg  autoheader*)
169264fa531Smrg    echo 1>&2 "\
170c37a63b8SmrgWARNING: \`$1' is $msg.  You should only need it if
171264fa531Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
172264fa531Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
173264fa531Smrg         from any GNU archive site."
174264fa531Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
175264fa531Smrg    test -z "$files" && files="config.h"
176264fa531Smrg    touch_files=
177264fa531Smrg    for f in $files; do
178c37a63b8Smrg      case $f in
179264fa531Smrg      *:*) touch_files="$touch_files "`echo "$f" |
180264fa531Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
181264fa531Smrg      *) touch_files="$touch_files $f.in";;
182264fa531Smrg      esac
183264fa531Smrg    done
184264fa531Smrg    touch $touch_files
185264fa531Smrg    ;;
186264fa531Smrg
187264fa531Smrg  automake*)
188264fa531Smrg    echo 1>&2 "\
189c37a63b8SmrgWARNING: \`$1' is $msg.  You should only need it if
190264fa531Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
191264fa531Smrg         You might want to install the \`Automake' and \`Perl' packages.
192264fa531Smrg         Grab them from any GNU archive site."
193264fa531Smrg    find . -type f -name Makefile.am -print |
194264fa531Smrg	   sed 's/\.am$/.in/' |
195264fa531Smrg	   while read f; do touch "$f"; done
196264fa531Smrg    ;;
197264fa531Smrg
198c37a63b8Smrg  autom4te*)
199264fa531Smrg    echo 1>&2 "\
200c37a63b8SmrgWARNING: \`$1' is needed, but is $msg.
201c37a63b8Smrg         You might have modified some files without having the
202264fa531Smrg         proper tools for further handling them.
203264fa531Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
204264fa531Smrg         archive site."
205264fa531Smrg
206c37a63b8Smrg    file=`echo "$*" | sed -n "$sed_output"`
207c37a63b8Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
208264fa531Smrg    if test -f "$file"; then
209264fa531Smrg	touch $file
210264fa531Smrg    else
211264fa531Smrg	test -z "$file" || exec >$file
212264fa531Smrg	echo "#! /bin/sh"
213264fa531Smrg	echo "# Created by GNU Automake missing as a replacement of"
214264fa531Smrg	echo "#  $ $@"
215264fa531Smrg	echo "exit 0"
216264fa531Smrg	chmod +x $file
217264fa531Smrg	exit 1
218264fa531Smrg    fi
219264fa531Smrg    ;;
220264fa531Smrg
221c37a63b8Smrg  bison*|yacc*)
222264fa531Smrg    echo 1>&2 "\
223c37a63b8SmrgWARNING: \`$1' $msg.  You should only need it if
224264fa531Smrg         you modified a \`.y' file.  You may need the \`Bison' package
225264fa531Smrg         in order for those modifications to take effect.  You can get
226264fa531Smrg         \`Bison' from any GNU archive site."
227264fa531Smrg    rm -f y.tab.c y.tab.h
228c37a63b8Smrg    if test $# -ne 1; then
229264fa531Smrg        eval LASTARG="\${$#}"
230c37a63b8Smrg	case $LASTARG in
231264fa531Smrg	*.y)
232264fa531Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
233c37a63b8Smrg	    if test -f "$SRCFILE"; then
234264fa531Smrg	         cp "$SRCFILE" y.tab.c
235264fa531Smrg	    fi
236264fa531Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
237c37a63b8Smrg	    if test -f "$SRCFILE"; then
238264fa531Smrg	         cp "$SRCFILE" y.tab.h
239264fa531Smrg	    fi
240264fa531Smrg	  ;;
241264fa531Smrg	esac
242264fa531Smrg    fi
243c37a63b8Smrg    if test ! -f y.tab.h; then
244264fa531Smrg	echo >y.tab.h
245264fa531Smrg    fi
246c37a63b8Smrg    if test ! -f y.tab.c; then
247264fa531Smrg	echo 'main() { return 0; }' >y.tab.c
248264fa531Smrg    fi
249264fa531Smrg    ;;
250264fa531Smrg
251c37a63b8Smrg  lex*|flex*)
252264fa531Smrg    echo 1>&2 "\
253c37a63b8SmrgWARNING: \`$1' is $msg.  You should only need it if
254264fa531Smrg         you modified a \`.l' file.  You may need the \`Flex' package
255264fa531Smrg         in order for those modifications to take effect.  You can get
256264fa531Smrg         \`Flex' from any GNU archive site."
257264fa531Smrg    rm -f lex.yy.c
258c37a63b8Smrg    if test $# -ne 1; then
259264fa531Smrg        eval LASTARG="\${$#}"
260c37a63b8Smrg	case $LASTARG in
261264fa531Smrg	*.l)
262264fa531Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
263c37a63b8Smrg	    if test -f "$SRCFILE"; then
264264fa531Smrg	         cp "$SRCFILE" lex.yy.c
265264fa531Smrg	    fi
266264fa531Smrg	  ;;
267264fa531Smrg	esac
268264fa531Smrg    fi
269c37a63b8Smrg    if test ! -f lex.yy.c; then
270264fa531Smrg	echo 'main() { return 0; }' >lex.yy.c
271264fa531Smrg    fi
272264fa531Smrg    ;;
273264fa531Smrg
274c37a63b8Smrg  help2man*)
275264fa531Smrg    echo 1>&2 "\
276c37a63b8SmrgWARNING: \`$1' is $msg.  You should only need it if
277264fa531Smrg	 you modified a dependency of a manual page.  You may need the
278264fa531Smrg	 \`Help2man' package in order for those modifications to take
279264fa531Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
280264fa531Smrg
281c37a63b8Smrg    file=`echo "$*" | sed -n "$sed_output"`
282c37a63b8Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
283c37a63b8Smrg    if test -f "$file"; then
284264fa531Smrg	touch $file
285264fa531Smrg    else
286264fa531Smrg	test -z "$file" || exec >$file
287264fa531Smrg	echo ".ab help2man is required to generate this page"
288c37a63b8Smrg	exit $?
289264fa531Smrg    fi
290264fa531Smrg    ;;
291264fa531Smrg
292c37a63b8Smrg  makeinfo*)
293264fa531Smrg    echo 1>&2 "\
294c37a63b8SmrgWARNING: \`$1' is $msg.  You should only need it if
295264fa531Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
296264fa531Smrg         indirectly affecting the aspect of the manual.  The spurious
297264fa531Smrg         call might also be the consequence of using a buggy \`make' (AIX,
298264fa531Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
299264fa531Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
300c37a63b8Smrg    # The file to touch is that specified with -o ...
301c37a63b8Smrg    file=`echo "$*" | sed -n "$sed_output"`
302c37a63b8Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
303264fa531Smrg    if test -z "$file"; then
304c37a63b8Smrg      # ... or it is the one specified with @setfilename ...
305c37a63b8Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
306c37a63b8Smrg      file=`sed -n '
307c37a63b8Smrg	/^@setfilename/{
308c37a63b8Smrg	  s/.* \([^ ]*\) *$/\1/
309c37a63b8Smrg	  p
310c37a63b8Smrg	  q
311c37a63b8Smrg	}' $infile`
312c37a63b8Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
313c37a63b8Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
314264fa531Smrg    fi
315c37a63b8Smrg    # If the file does not exist, the user really needs makeinfo;
316c37a63b8Smrg    # let's fail without touching anything.
317c37a63b8Smrg    test -f $file || exit 1
318264fa531Smrg    touch $file
319264fa531Smrg    ;;
320264fa531Smrg
321c37a63b8Smrg  tar*)
322264fa531Smrg    shift
323264fa531Smrg
324264fa531Smrg    # We have already tried tar in the generic part.
325264fa531Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
326264fa531Smrg    # messages.
327264fa531Smrg    if (gnutar --version > /dev/null 2>&1); then
328264fa531Smrg       gnutar "$@" && exit 0
329264fa531Smrg    fi
330264fa531Smrg    if (gtar --version > /dev/null 2>&1); then
331264fa531Smrg       gtar "$@" && exit 0
332264fa531Smrg    fi
333264fa531Smrg    firstarg="$1"
334264fa531Smrg    if shift; then
335c37a63b8Smrg	case $firstarg in
336264fa531Smrg	*o*)
337264fa531Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
338264fa531Smrg	    tar "$firstarg" "$@" && exit 0
339264fa531Smrg	    ;;
340264fa531Smrg	esac
341c37a63b8Smrg	case $firstarg in
342264fa531Smrg	*h*)
343264fa531Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
344264fa531Smrg	    tar "$firstarg" "$@" && exit 0
345264fa531Smrg	    ;;
346264fa531Smrg	esac
347264fa531Smrg    fi
348264fa531Smrg
349264fa531Smrg    echo 1>&2 "\
350264fa531SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
351264fa531Smrg         You may want to install GNU tar or Free paxutils, or check the
352264fa531Smrg         command line arguments."
353264fa531Smrg    exit 1
354264fa531Smrg    ;;
355264fa531Smrg
356264fa531Smrg  *)
357264fa531Smrg    echo 1>&2 "\
358c37a63b8SmrgWARNING: \`$1' is needed, and is $msg.
359c37a63b8Smrg         You might have modified some files without having the
360264fa531Smrg         proper tools for further handling them.  Check the \`README' file,
361264fa531Smrg         it often tells you about the needed prerequisites for installing
362264fa531Smrg         this package.  You may also peek at any GNU archive site, in case
363264fa531Smrg         some other package would contain this missing \`$1' program."
364264fa531Smrg    exit 1
365264fa531Smrg    ;;
366264fa531Smrgesac
367264fa531Smrg
368264fa531Smrgexit 0
369c37a63b8Smrg
370c37a63b8Smrg# Local variables:
371c37a63b8Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
372c37a63b8Smrg# time-stamp-start: "scriptversion="
373c37a63b8Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374c37a63b8Smrg# time-stamp-time-zone: "UTC"
375c37a63b8Smrg# time-stamp-end: "; # UTC"
376c37a63b8Smrg# End:
377