missing revision 2f39173d
1209ff23fSmrg#! /bin/sh
2209ff23fSmrg# Common stub for a few missing GNU programs while installing.
3209ff23fSmrg
42f39173dSmrgscriptversion=2009-04-28.21; # UTC
5209ff23fSmrg
62f39173dSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
72f39173dSmrg# 2008, 2009 Free Software Foundation, Inc.
8209ff23fSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9209ff23fSmrg
10209ff23fSmrg# This program is free software; you can redistribute it and/or modify
11209ff23fSmrg# it under the terms of the GNU General Public License as published by
12209ff23fSmrg# the Free Software Foundation; either version 2, or (at your option)
13209ff23fSmrg# any later version.
14209ff23fSmrg
15209ff23fSmrg# This program is distributed in the hope that it will be useful,
16209ff23fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17209ff23fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18209ff23fSmrg# GNU General Public License for more details.
19209ff23fSmrg
20209ff23fSmrg# You should have received a copy of the GNU General Public License
212f39173dSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22209ff23fSmrg
23209ff23fSmrg# As a special exception to the GNU General Public License, if you
24209ff23fSmrg# distribute this file as part of a program that contains a
25209ff23fSmrg# configuration script generated by Autoconf, you may include it under
26209ff23fSmrg# the same distribution terms that you use for the rest of that program.
27209ff23fSmrg
28209ff23fSmrgif test $# -eq 0; then
29209ff23fSmrg  echo 1>&2 "Try \`$0 --help' for more information"
30209ff23fSmrg  exit 1
31209ff23fSmrgfi
32209ff23fSmrg
33209ff23fSmrgrun=:
34209ff23fSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35209ff23fSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36209ff23fSmrg
37209ff23fSmrg# In the cases where this matters, `missing' is being run in the
38209ff23fSmrg# srcdir already.
39209ff23fSmrgif test -f configure.ac; then
40209ff23fSmrg  configure_ac=configure.ac
41209ff23fSmrgelse
42209ff23fSmrg  configure_ac=configure.in
43209ff23fSmrgfi
44209ff23fSmrg
45209ff23fSmrgmsg="missing on your system"
46209ff23fSmrg
47209ff23fSmrgcase $1 in
48209ff23fSmrg--run)
49209ff23fSmrg  # Try to run requested program, and just exit if it succeeds.
50209ff23fSmrg  run=
51209ff23fSmrg  shift
52209ff23fSmrg  "$@" && exit 0
53209ff23fSmrg  # Exit code 63 means version mismatch.  This often happens
54209ff23fSmrg  # when the user try to use an ancient version of a tool on
55209ff23fSmrg  # a file that requires a minimum version.  In this case we
56209ff23fSmrg  # we should proceed has if the program had been absent, or
57209ff23fSmrg  # if --run hadn't been passed.
58209ff23fSmrg  if test $? = 63; then
59209ff23fSmrg    run=:
60209ff23fSmrg    msg="probably too old"
61209ff23fSmrg  fi
62209ff23fSmrg  ;;
63209ff23fSmrg
64209ff23fSmrg  -h|--h|--he|--hel|--help)
65209ff23fSmrg    echo "\
66209ff23fSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67209ff23fSmrg
68209ff23fSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69209ff23fSmrgerror status if there is no known handling for PROGRAM.
70209ff23fSmrg
71209ff23fSmrgOptions:
72209ff23fSmrg  -h, --help      display this help and exit
73209ff23fSmrg  -v, --version   output version information and exit
74209ff23fSmrg  --run           try to run the given command, and emulate it if it fails
75209ff23fSmrg
76209ff23fSmrgSupported PROGRAM values:
77209ff23fSmrg  aclocal      touch file \`aclocal.m4'
78209ff23fSmrg  autoconf     touch file \`configure'
79209ff23fSmrg  autoheader   touch file \`config.h.in'
80209ff23fSmrg  autom4te     touch the output file, or create a stub one
81209ff23fSmrg  automake     touch all \`Makefile.in' files
82209ff23fSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83209ff23fSmrg  flex         create \`lex.yy.c', if possible, from existing .c
84209ff23fSmrg  help2man     touch the output file
85209ff23fSmrg  lex          create \`lex.yy.c', if possible, from existing .c
86209ff23fSmrg  makeinfo     touch the output file
87209ff23fSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
88209ff23fSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
89209ff23fSmrg
902f39173dSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
912f39173dSmrg\`g' are ignored when checking the name.
922f39173dSmrg
93209ff23fSmrgSend bug reports to <bug-automake@gnu.org>."
94209ff23fSmrg    exit $?
95209ff23fSmrg    ;;
96209ff23fSmrg
97209ff23fSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
98209ff23fSmrg    echo "missing $scriptversion (GNU Automake)"
99209ff23fSmrg    exit $?
100209ff23fSmrg    ;;
101209ff23fSmrg
102209ff23fSmrg  -*)
103209ff23fSmrg    echo 1>&2 "$0: Unknown \`$1' option"
104209ff23fSmrg    echo 1>&2 "Try \`$0 --help' for more information"
105209ff23fSmrg    exit 1
106209ff23fSmrg    ;;
107209ff23fSmrg
108209ff23fSmrgesac
109209ff23fSmrg
1102f39173dSmrg# normalize program name to check for.
1112f39173dSmrgprogram=`echo "$1" | sed '
1122f39173dSmrg  s/^gnu-//; t
1132f39173dSmrg  s/^gnu//; t
1142f39173dSmrg  s/^g//; t'`
1152f39173dSmrg
116209ff23fSmrg# Now exit if we have it, but it failed.  Also exit now if we
117209ff23fSmrg# don't have it and --version was passed (most likely to detect
1182f39173dSmrg# the program).  This is about non-GNU programs, so use $1 not
1192f39173dSmrg# $program.
120209ff23fSmrgcase $1 in
1212f39173dSmrg  lex*|yacc*)
122209ff23fSmrg    # Not GNU programs, they don't have --version.
123209ff23fSmrg    ;;
124209ff23fSmrg
1252f39173dSmrg  tar*)
126209ff23fSmrg    if test -n "$run"; then
127209ff23fSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
128209ff23fSmrg       exit 1
129209ff23fSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
130209ff23fSmrg       exit 1
131209ff23fSmrg    fi
132209ff23fSmrg    ;;
133209ff23fSmrg
134209ff23fSmrg  *)
135209ff23fSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
136209ff23fSmrg       # We have it, but it failed.
137209ff23fSmrg       exit 1
138209ff23fSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
139209ff23fSmrg       # Could not run --version or --help.  This is probably someone
140209ff23fSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
141209ff23fSmrg       # $TOOL exists and not knowing $TOOL uses missing.
142209ff23fSmrg       exit 1
143209ff23fSmrg    fi
144209ff23fSmrg    ;;
145209ff23fSmrgesac
146209ff23fSmrg
147209ff23fSmrg# If it does not exist, or fails to run (possibly an outdated version),
148209ff23fSmrg# try to emulate it.
1492f39173dSmrgcase $program in
150209ff23fSmrg  aclocal*)
151209ff23fSmrg    echo 1>&2 "\
152209ff23fSmrgWARNING: \`$1' is $msg.  You should only need it if
153209ff23fSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
154209ff23fSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
155209ff23fSmrg         any GNU archive site."
156209ff23fSmrg    touch aclocal.m4
157209ff23fSmrg    ;;
158209ff23fSmrg
1592f39173dSmrg  autoconf*)
160209ff23fSmrg    echo 1>&2 "\
161209ff23fSmrgWARNING: \`$1' is $msg.  You should only need it if
162209ff23fSmrg         you modified \`${configure_ac}'.  You might want to install the
163209ff23fSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
164209ff23fSmrg         archive site."
165209ff23fSmrg    touch configure
166209ff23fSmrg    ;;
167209ff23fSmrg
1682f39173dSmrg  autoheader*)
169209ff23fSmrg    echo 1>&2 "\
170209ff23fSmrgWARNING: \`$1' is $msg.  You should only need it if
171209ff23fSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
172209ff23fSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
173209ff23fSmrg         from any GNU archive site."
174209ff23fSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
175209ff23fSmrg    test -z "$files" && files="config.h"
176209ff23fSmrg    touch_files=
177209ff23fSmrg    for f in $files; do
178209ff23fSmrg      case $f in
179209ff23fSmrg      *:*) touch_files="$touch_files "`echo "$f" |
180209ff23fSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
181209ff23fSmrg      *) touch_files="$touch_files $f.in";;
182209ff23fSmrg      esac
183209ff23fSmrg    done
184209ff23fSmrg    touch $touch_files
185209ff23fSmrg    ;;
186209ff23fSmrg
187209ff23fSmrg  automake*)
188209ff23fSmrg    echo 1>&2 "\
189209ff23fSmrgWARNING: \`$1' is $msg.  You should only need it if
190209ff23fSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
191209ff23fSmrg         You might want to install the \`Automake' and \`Perl' packages.
192209ff23fSmrg         Grab them from any GNU archive site."
193209ff23fSmrg    find . -type f -name Makefile.am -print |
194209ff23fSmrg	   sed 's/\.am$/.in/' |
195209ff23fSmrg	   while read f; do touch "$f"; done
196209ff23fSmrg    ;;
197209ff23fSmrg
1982f39173dSmrg  autom4te*)
199209ff23fSmrg    echo 1>&2 "\
200209ff23fSmrgWARNING: \`$1' is needed, but is $msg.
201209ff23fSmrg         You might have modified some files without having the
202209ff23fSmrg         proper tools for further handling them.
203209ff23fSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
204209ff23fSmrg         archive site."
205209ff23fSmrg
206209ff23fSmrg    file=`echo "$*" | sed -n "$sed_output"`
207209ff23fSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
208209ff23fSmrg    if test -f "$file"; then
209209ff23fSmrg	touch $file
210209ff23fSmrg    else
211209ff23fSmrg	test -z "$file" || exec >$file
212209ff23fSmrg	echo "#! /bin/sh"
213209ff23fSmrg	echo "# Created by GNU Automake missing as a replacement of"
214209ff23fSmrg	echo "#  $ $@"
215209ff23fSmrg	echo "exit 0"
216209ff23fSmrg	chmod +x $file
217209ff23fSmrg	exit 1
218209ff23fSmrg    fi
219209ff23fSmrg    ;;
220209ff23fSmrg
2212f39173dSmrg  bison*|yacc*)
222209ff23fSmrg    echo 1>&2 "\
223209ff23fSmrgWARNING: \`$1' $msg.  You should only need it if
224209ff23fSmrg         you modified a \`.y' file.  You may need the \`Bison' package
225209ff23fSmrg         in order for those modifications to take effect.  You can get
226209ff23fSmrg         \`Bison' from any GNU archive site."
227209ff23fSmrg    rm -f y.tab.c y.tab.h
228209ff23fSmrg    if test $# -ne 1; then
229209ff23fSmrg        eval LASTARG="\${$#}"
230209ff23fSmrg	case $LASTARG in
231209ff23fSmrg	*.y)
232209ff23fSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
233209ff23fSmrg	    if test -f "$SRCFILE"; then
234209ff23fSmrg	         cp "$SRCFILE" y.tab.c
235209ff23fSmrg	    fi
236209ff23fSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
237209ff23fSmrg	    if test -f "$SRCFILE"; then
238209ff23fSmrg	         cp "$SRCFILE" y.tab.h
239209ff23fSmrg	    fi
240209ff23fSmrg	  ;;
241209ff23fSmrg	esac
242209ff23fSmrg    fi
243209ff23fSmrg    if test ! -f y.tab.h; then
244209ff23fSmrg	echo >y.tab.h
245209ff23fSmrg    fi
246209ff23fSmrg    if test ! -f y.tab.c; then
247209ff23fSmrg	echo 'main() { return 0; }' >y.tab.c
248209ff23fSmrg    fi
249209ff23fSmrg    ;;
250209ff23fSmrg
2512f39173dSmrg  lex*|flex*)
252209ff23fSmrg    echo 1>&2 "\
253209ff23fSmrgWARNING: \`$1' is $msg.  You should only need it if
254209ff23fSmrg         you modified a \`.l' file.  You may need the \`Flex' package
255209ff23fSmrg         in order for those modifications to take effect.  You can get
256209ff23fSmrg         \`Flex' from any GNU archive site."
257209ff23fSmrg    rm -f lex.yy.c
258209ff23fSmrg    if test $# -ne 1; then
259209ff23fSmrg        eval LASTARG="\${$#}"
260209ff23fSmrg	case $LASTARG in
261209ff23fSmrg	*.l)
262209ff23fSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
263209ff23fSmrg	    if test -f "$SRCFILE"; then
264209ff23fSmrg	         cp "$SRCFILE" lex.yy.c
265209ff23fSmrg	    fi
266209ff23fSmrg	  ;;
267209ff23fSmrg	esac
268209ff23fSmrg    fi
269209ff23fSmrg    if test ! -f lex.yy.c; then
270209ff23fSmrg	echo 'main() { return 0; }' >lex.yy.c
271209ff23fSmrg    fi
272209ff23fSmrg    ;;
273209ff23fSmrg
2742f39173dSmrg  help2man*)
275209ff23fSmrg    echo 1>&2 "\
276209ff23fSmrgWARNING: \`$1' is $msg.  You should only need it if
277209ff23fSmrg	 you modified a dependency of a manual page.  You may need the
278209ff23fSmrg	 \`Help2man' package in order for those modifications to take
279209ff23fSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
280209ff23fSmrg
281209ff23fSmrg    file=`echo "$*" | sed -n "$sed_output"`
282209ff23fSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
283209ff23fSmrg    if test -f "$file"; then
284209ff23fSmrg	touch $file
285209ff23fSmrg    else
286209ff23fSmrg	test -z "$file" || exec >$file
287209ff23fSmrg	echo ".ab help2man is required to generate this page"
2882f39173dSmrg	exit $?
289209ff23fSmrg    fi
290209ff23fSmrg    ;;
291209ff23fSmrg
2922f39173dSmrg  makeinfo*)
293209ff23fSmrg    echo 1>&2 "\
294209ff23fSmrgWARNING: \`$1' is $msg.  You should only need it if
295209ff23fSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
296209ff23fSmrg         indirectly affecting the aspect of the manual.  The spurious
297209ff23fSmrg         call might also be the consequence of using a buggy \`make' (AIX,
298209ff23fSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
299209ff23fSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
300209ff23fSmrg    # The file to touch is that specified with -o ...
301209ff23fSmrg    file=`echo "$*" | sed -n "$sed_output"`
302209ff23fSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
303209ff23fSmrg    if test -z "$file"; then
304209ff23fSmrg      # ... or it is the one specified with @setfilename ...
305209ff23fSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
306209ff23fSmrg      file=`sed -n '
307209ff23fSmrg	/^@setfilename/{
308209ff23fSmrg	  s/.* \([^ ]*\) *$/\1/
309209ff23fSmrg	  p
310209ff23fSmrg	  q
311209ff23fSmrg	}' $infile`
312209ff23fSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
313209ff23fSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
314209ff23fSmrg    fi
315209ff23fSmrg    # If the file does not exist, the user really needs makeinfo;
316209ff23fSmrg    # let's fail without touching anything.
317209ff23fSmrg    test -f $file || exit 1
318209ff23fSmrg    touch $file
319209ff23fSmrg    ;;
320209ff23fSmrg
3212f39173dSmrg  tar*)
322209ff23fSmrg    shift
323209ff23fSmrg
324209ff23fSmrg    # We have already tried tar in the generic part.
325209ff23fSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
326209ff23fSmrg    # messages.
327209ff23fSmrg    if (gnutar --version > /dev/null 2>&1); then
328209ff23fSmrg       gnutar "$@" && exit 0
329209ff23fSmrg    fi
330209ff23fSmrg    if (gtar --version > /dev/null 2>&1); then
331209ff23fSmrg       gtar "$@" && exit 0
332209ff23fSmrg    fi
333209ff23fSmrg    firstarg="$1"
334209ff23fSmrg    if shift; then
335209ff23fSmrg	case $firstarg in
336209ff23fSmrg	*o*)
337209ff23fSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
338209ff23fSmrg	    tar "$firstarg" "$@" && exit 0
339209ff23fSmrg	    ;;
340209ff23fSmrg	esac
341209ff23fSmrg	case $firstarg in
342209ff23fSmrg	*h*)
343209ff23fSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
344209ff23fSmrg	    tar "$firstarg" "$@" && exit 0
345209ff23fSmrg	    ;;
346209ff23fSmrg	esac
347209ff23fSmrg    fi
348209ff23fSmrg
349209ff23fSmrg    echo 1>&2 "\
350209ff23fSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
351209ff23fSmrg         You may want to install GNU tar or Free paxutils, or check the
352209ff23fSmrg         command line arguments."
353209ff23fSmrg    exit 1
354209ff23fSmrg    ;;
355209ff23fSmrg
356209ff23fSmrg  *)
357209ff23fSmrg    echo 1>&2 "\
358209ff23fSmrgWARNING: \`$1' is needed, and is $msg.
359209ff23fSmrg         You might have modified some files without having the
360209ff23fSmrg         proper tools for further handling them.  Check the \`README' file,
361209ff23fSmrg         it often tells you about the needed prerequisites for installing
362209ff23fSmrg         this package.  You may also peek at any GNU archive site, in case
363209ff23fSmrg         some other package would contain this missing \`$1' program."
364209ff23fSmrg    exit 1
365209ff23fSmrg    ;;
366209ff23fSmrgesac
367209ff23fSmrg
368209ff23fSmrgexit 0
369209ff23fSmrg
370209ff23fSmrg# Local variables:
371209ff23fSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
372209ff23fSmrg# time-stamp-start: "scriptversion="
373209ff23fSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3742f39173dSmrg# time-stamp-time-zone: "UTC"
3752f39173dSmrg# time-stamp-end: "; # UTC"
376209ff23fSmrg# End:
377