138889Sjdp#! /bin/sh
238889Sjdp# Common stub for a few missing GNU programs while installing.
3218822Sdim
4218822Sdimscriptversion=2005-06-08.21
5218822Sdim
6218822Sdim# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
7218822Sdim#   Free Software Foundation, Inc.
8130561Sobrien# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
938889Sjdp
1038889Sjdp# This program is free software; you can redistribute it and/or modify
1138889Sjdp# it under the terms of the GNU General Public License as published by
1238889Sjdp# the Free Software Foundation; either version 2, or (at your option)
1338889Sjdp# any later version.
1438889Sjdp
1538889Sjdp# This program is distributed in the hope that it will be useful,
1638889Sjdp# but WITHOUT ANY WARRANTY; without even the implied warranty of
1738889Sjdp# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1838889Sjdp# GNU General Public License for more details.
1938889Sjdp
2038889Sjdp# You should have received a copy of the GNU General Public License
2138889Sjdp# along with this program; if not, write to the Free Software
22218822Sdim# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23218822Sdim# 02110-1301, USA.
2438889Sjdp
25130561Sobrien# As a special exception to the GNU General Public License, if you
26130561Sobrien# distribute this file as part of a program that contains a
27130561Sobrien# configuration script generated by Autoconf, you may include it under
28130561Sobrien# the same distribution terms that you use for the rest of that program.
29130561Sobrien
3038889Sjdpif test $# -eq 0; then
3138889Sjdp  echo 1>&2 "Try \`$0 --help' for more information"
3238889Sjdp  exit 1
3338889Sjdpfi
3438889Sjdp
35130561Sobrienrun=:
36130561Sobrien
37130561Sobrien# In the cases where this matters, `missing' is being run in the
38130561Sobrien# srcdir already.
39130561Sobrienif test -f configure.ac; then
40130561Sobrien  configure_ac=configure.ac
41130561Sobrienelse
42130561Sobrien  configure_ac=configure.in
43130561Sobrienfi
44130561Sobrien
45218822Sdimmsg="missing on your system"
46218822Sdim
4738889Sjdpcase "$1" in
48130561Sobrien--run)
49130561Sobrien  # Try to run requested program, and just exit if it succeeds.
50130561Sobrien  run=
51130561Sobrien  shift
52130561Sobrien  "$@" && exit 0
53218822Sdim  # Exit code 63 means version mismatch.  This often happens
54218822Sdim  # when the user try to use an ancient version of a tool on
55218822Sdim  # a file that requires a minimum version.  In this case we
56218822Sdim  # we should proceed has if the program had been absent, or
57218822Sdim  # if --run hadn't been passed.
58218822Sdim  if test $? = 63; then
59218822Sdim    run=:
60218822Sdim    msg="probably too old"
61218822Sdim  fi
62130561Sobrien  ;;
6338889Sjdp
6438889Sjdp  -h|--h|--he|--hel|--help)
6538889Sjdp    echo "\
6638889Sjdp$0 [OPTION]... PROGRAM [ARGUMENT]...
6738889Sjdp
6838889SjdpHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6938889Sjdperror status if there is no known handling for PROGRAM.
7038889Sjdp
7138889SjdpOptions:
7238889Sjdp  -h, --help      display this help and exit
7338889Sjdp  -v, --version   output version information and exit
74130561Sobrien  --run           try to run the given command, and emulate it if it fails
7538889Sjdp
7638889SjdpSupported PROGRAM values:
7738889Sjdp  aclocal      touch file \`aclocal.m4'
7838889Sjdp  autoconf     touch file \`configure'
7938889Sjdp  autoheader   touch file \`config.h.in'
8038889Sjdp  automake     touch all \`Makefile.in' files
8160484Sobrien  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8260484Sobrien  flex         create \`lex.yy.c', if possible, from existing .c
83130561Sobrien  help2man     touch the output file
8460484Sobrien  lex          create \`lex.yy.c', if possible, from existing .c
8538889Sjdp  makeinfo     touch the output file
86130561Sobrien  tar          try tar, gnutar, gtar, then tar without non-portable flags
87218822Sdim  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
88218822Sdim
89218822SdimSend bug reports to <bug-automake@gnu.org>."
90218822Sdim    exit $?
9138889Sjdp    ;;
9238889Sjdp
9338889Sjdp  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
94218822Sdim    echo "missing $scriptversion (GNU Automake)"
95218822Sdim    exit $?
9638889Sjdp    ;;
9738889Sjdp
9838889Sjdp  -*)
9938889Sjdp    echo 1>&2 "$0: Unknown \`$1' option"
10038889Sjdp    echo 1>&2 "Try \`$0 --help' for more information"
10138889Sjdp    exit 1
10238889Sjdp    ;;
10338889Sjdp
104218822Sdimesac
105218822Sdim
106218822Sdim# Now exit if we have it, but it failed.  Also exit now if we
107218822Sdim# don't have it and --version was passed (most likely to detect
108218822Sdim# the program).
109218822Sdimcase "$1" in
110218822Sdim  lex|yacc)
111218822Sdim    # Not GNU programs, they don't have --version.
112218822Sdim    ;;
113218822Sdim
114218822Sdim  tar)
115218822Sdim    if test -n "$run"; then
116218822Sdim       echo 1>&2 "ERROR: \`tar' requires --run"
117218822Sdim       exit 1
118218822Sdim    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
119218822Sdim       exit 1
120218822Sdim    fi
121218822Sdim    ;;
122218822Sdim
123218822Sdim  *)
124130561Sobrien    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125130561Sobrien       # We have it, but it failed.
126130561Sobrien       exit 1
127218822Sdim    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128218822Sdim       # Could not run --version or --help.  This is probably someone
129218822Sdim       # running `$TOOL --version' or `$TOOL --help' to check whether
130218822Sdim       # $TOOL exists and not knowing $TOOL uses missing.
131218822Sdim       exit 1
132130561Sobrien    fi
133218822Sdim    ;;
134218822Sdimesac
135130561Sobrien
136218822Sdim# If it does not exist, or fails to run (possibly an outdated version),
137218822Sdim# try to emulate it.
138218822Sdimcase "$1" in
139218822Sdim  aclocal*)
14038889Sjdp    echo 1>&2 "\
141218822SdimWARNING: \`$1' is $msg.  You should only need it if
142130561Sobrien         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14338889Sjdp         to install the \`Automake' and \`Perl' packages.  Grab them from
14438889Sjdp         any GNU archive site."
14538889Sjdp    touch aclocal.m4
14638889Sjdp    ;;
14738889Sjdp
14838889Sjdp  autoconf)
14938889Sjdp    echo 1>&2 "\
150218822SdimWARNING: \`$1' is $msg.  You should only need it if
151130561Sobrien         you modified \`${configure_ac}'.  You might want to install the
15238889Sjdp         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15338889Sjdp         archive site."
15438889Sjdp    touch configure
15538889Sjdp    ;;
15638889Sjdp
15738889Sjdp  autoheader)
15838889Sjdp    echo 1>&2 "\
159218822SdimWARNING: \`$1' is $msg.  You should only need it if
160130561Sobrien         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16138889Sjdp         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16238889Sjdp         from any GNU archive site."
163130561Sobrien    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16460484Sobrien    test -z "$files" && files="config.h"
16560484Sobrien    touch_files=
16660484Sobrien    for f in $files; do
16760484Sobrien      case "$f" in
16860484Sobrien      *:*) touch_files="$touch_files "`echo "$f" |
16960484Sobrien				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17060484Sobrien      *) touch_files="$touch_files $f.in";;
17160484Sobrien      esac
17260484Sobrien    done
17360484Sobrien    touch $touch_files
17438889Sjdp    ;;
17538889Sjdp
176130561Sobrien  automake*)
17738889Sjdp    echo 1>&2 "\
178218822SdimWARNING: \`$1' is $msg.  You should only need it if
179130561Sobrien         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18038889Sjdp         You might want to install the \`Automake' and \`Perl' packages.
18138889Sjdp         Grab them from any GNU archive site."
18260484Sobrien    find . -type f -name Makefile.am -print |
18360484Sobrien	   sed 's/\.am$/.in/' |
18460484Sobrien	   while read f; do touch "$f"; done
18538889Sjdp    ;;
18638889Sjdp
187130561Sobrien  autom4te)
188130561Sobrien    echo 1>&2 "\
189218822SdimWARNING: \`$1' is needed, but is $msg.
190218822Sdim         You might have modified some files without having the
191130561Sobrien         proper tools for further handling them.
192130561Sobrien         You can get \`$1' as part of \`Autoconf' from any GNU
193130561Sobrien         archive site."
194130561Sobrien
195130561Sobrien    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
196130561Sobrien    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
197130561Sobrien    if test -f "$file"; then
198130561Sobrien	touch $file
199130561Sobrien    else
200130561Sobrien	test -z "$file" || exec >$file
201130561Sobrien	echo "#! /bin/sh"
202130561Sobrien	echo "# Created by GNU Automake missing as a replacement of"
203130561Sobrien	echo "#  $ $@"
204130561Sobrien	echo "exit 0"
205130561Sobrien	chmod +x $file
206130561Sobrien	exit 1
207130561Sobrien    fi
208130561Sobrien    ;;
209130561Sobrien
21038889Sjdp  bison|yacc)
21138889Sjdp    echo 1>&2 "\
212218822SdimWARNING: \`$1' $msg.  You should only need it if
21338889Sjdp         you modified a \`.y' file.  You may need the \`Bison' package
21438889Sjdp         in order for those modifications to take effect.  You can get
21538889Sjdp         \`Bison' from any GNU archive site."
21660484Sobrien    rm -f y.tab.c y.tab.h
21760484Sobrien    if [ $# -ne 1 ]; then
21860484Sobrien        eval LASTARG="\${$#}"
21960484Sobrien	case "$LASTARG" in
22060484Sobrien	*.y)
22160484Sobrien	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22260484Sobrien	    if [ -f "$SRCFILE" ]; then
22360484Sobrien	         cp "$SRCFILE" y.tab.c
22460484Sobrien	    fi
22560484Sobrien	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22660484Sobrien	    if [ -f "$SRCFILE" ]; then
22760484Sobrien	         cp "$SRCFILE" y.tab.h
22860484Sobrien	    fi
22960484Sobrien	  ;;
23060484Sobrien	esac
23160484Sobrien    fi
23260484Sobrien    if [ ! -f y.tab.h ]; then
23360484Sobrien	echo >y.tab.h
23460484Sobrien    fi
23560484Sobrien    if [ ! -f y.tab.c ]; then
23660484Sobrien	echo 'main() { return 0; }' >y.tab.c
23760484Sobrien    fi
23838889Sjdp    ;;
23938889Sjdp
24060484Sobrien  lex|flex)
24160484Sobrien    echo 1>&2 "\
242218822SdimWARNING: \`$1' is $msg.  You should only need it if
24360484Sobrien         you modified a \`.l' file.  You may need the \`Flex' package
24460484Sobrien         in order for those modifications to take effect.  You can get
24560484Sobrien         \`Flex' from any GNU archive site."
24660484Sobrien    rm -f lex.yy.c
24760484Sobrien    if [ $# -ne 1 ]; then
24860484Sobrien        eval LASTARG="\${$#}"
24960484Sobrien	case "$LASTARG" in
25060484Sobrien	*.l)
25160484Sobrien	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25260484Sobrien	    if [ -f "$SRCFILE" ]; then
25360484Sobrien	         cp "$SRCFILE" lex.yy.c
25460484Sobrien	    fi
25560484Sobrien	  ;;
25660484Sobrien	esac
25760484Sobrien    fi
25860484Sobrien    if [ ! -f lex.yy.c ]; then
25960484Sobrien	echo 'main() { return 0; }' >lex.yy.c
26060484Sobrien    fi
26160484Sobrien    ;;
26260484Sobrien
263130561Sobrien  help2man)
264130561Sobrien    echo 1>&2 "\
265218822SdimWARNING: \`$1' is $msg.  You should only need it if
266130561Sobrien	 you modified a dependency of a manual page.  You may need the
267130561Sobrien	 \`Help2man' package in order for those modifications to take
268130561Sobrien	 effect.  You can get \`Help2man' from any GNU archive site."
269130561Sobrien
270130561Sobrien    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
271130561Sobrien    if test -z "$file"; then
272130561Sobrien	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
273130561Sobrien    fi
274130561Sobrien    if [ -f "$file" ]; then
275130561Sobrien	touch $file
276130561Sobrien    else
277130561Sobrien	test -z "$file" || exec >$file
278130561Sobrien	echo ".ab help2man is required to generate this page"
279130561Sobrien	exit 1
280130561Sobrien    fi
281130561Sobrien    ;;
282130561Sobrien
28338889Sjdp  makeinfo)
28438889Sjdp    echo 1>&2 "\
285218822SdimWARNING: \`$1' is $msg.  You should only need it if
28638889Sjdp         you modified a \`.texi' or \`.texinfo' file, or any other file
28738889Sjdp         indirectly affecting the aspect of the manual.  The spurious
28838889Sjdp         call might also be the consequence of using a buggy \`make' (AIX,
28938889Sjdp         DU, IRIX).  You might want to install the \`Texinfo' package or
29038889Sjdp         the \`GNU make' package.  Grab either from any GNU archive site."
291218822Sdim    # The file to touch is that specified with -o ...
29238889Sjdp    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
29338889Sjdp    if test -z "$file"; then
294218822Sdim      # ... or it is the one specified with @setfilename ...
295218822Sdim      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296218822Sdim      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
297218822Sdim      # ... or it is derived from the source name (dir/f.texi becomes f.info)
298218822Sdim      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
29938889Sjdp    fi
300218822Sdim    # If the file does not exist, the user really needs makeinfo;
301218822Sdim    # let's fail without touching anything.
302218822Sdim    test -f $file || exit 1
30338889Sjdp    touch $file
30438889Sjdp    ;;
30538889Sjdp
306130561Sobrien  tar)
307130561Sobrien    shift
308130561Sobrien
309130561Sobrien    # We have already tried tar in the generic part.
310130561Sobrien    # Look for gnutar/gtar before invocation to avoid ugly error
311130561Sobrien    # messages.
312130561Sobrien    if (gnutar --version > /dev/null 2>&1); then
313130561Sobrien       gnutar "$@" && exit 0
314130561Sobrien    fi
315130561Sobrien    if (gtar --version > /dev/null 2>&1); then
316130561Sobrien       gtar "$@" && exit 0
317130561Sobrien    fi
318130561Sobrien    firstarg="$1"
319130561Sobrien    if shift; then
320130561Sobrien	case "$firstarg" in
321130561Sobrien	*o*)
322130561Sobrien	    firstarg=`echo "$firstarg" | sed s/o//`
323130561Sobrien	    tar "$firstarg" "$@" && exit 0
324130561Sobrien	    ;;
325130561Sobrien	esac
326130561Sobrien	case "$firstarg" in
327130561Sobrien	*h*)
328130561Sobrien	    firstarg=`echo "$firstarg" | sed s/h//`
329130561Sobrien	    tar "$firstarg" "$@" && exit 0
330130561Sobrien	    ;;
331130561Sobrien	esac
332130561Sobrien    fi
333130561Sobrien
334130561Sobrien    echo 1>&2 "\
335130561SobrienWARNING: I can't seem to be able to run \`tar' with the given arguments.
336130561Sobrien         You may want to install GNU tar or Free paxutils, or check the
337130561Sobrien         command line arguments."
338130561Sobrien    exit 1
339130561Sobrien    ;;
340130561Sobrien
34138889Sjdp  *)
34238889Sjdp    echo 1>&2 "\
343218822SdimWARNING: \`$1' is needed, and is $msg.
344218822Sdim         You might have modified some files without having the
34538889Sjdp         proper tools for further handling them.  Check the \`README' file,
346218822Sdim         it often tells you about the needed prerequisites for installing
34738889Sjdp         this package.  You may also peek at any GNU archive site, in case
34838889Sjdp         some other package would contain this missing \`$1' program."
34938889Sjdp    exit 1
35038889Sjdp    ;;
35138889Sjdpesac
35238889Sjdp
35338889Sjdpexit 0
354218822Sdim
355218822Sdim# Local variables:
356218822Sdim# eval: (add-hook 'write-file-hooks 'time-stamp)
357218822Sdim# time-stamp-start: "scriptversion="
358218822Sdim# time-stamp-format: "%:y-%02m-%02d.%02H"
359218822Sdim# time-stamp-end: "$"
360218822Sdim# End:
361