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