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