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