missing revision 142403
155682Smarkm#! /bin/sh
272445Sassar# Common stub for a few missing GNU programs while installing.
3142403Snectar
4142403Snectarscriptversion=2003-09-02.23
5142403Snectar
6142403Snectar# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 
7142403Snectar#   Free Software Foundation, Inc.
872445Sassar# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
972445Sassar
1072445Sassar# This program is free software; you can redistribute it and/or modify
1172445Sassar# it under the terms of the GNU General Public License as published by
1272445Sassar# the Free Software Foundation; either version 2, or (at your option)
1372445Sassar# any later version.
1472445Sassar
1572445Sassar# This program is distributed in the hope that it will be useful,
1672445Sassar# but WITHOUT ANY WARRANTY; without even the implied warranty of
1772445Sassar# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1872445Sassar# GNU General Public License for more details.
1972445Sassar
2072445Sassar# You should have received a copy of the GNU General Public License
2172445Sassar# along with this program; if not, write to the Free Software
2272445Sassar# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2372445Sassar# 02111-1307, USA.
2472445Sassar
25102644Snectar# As a special exception to the GNU General Public License, if you
26102644Snectar# distribute this file as part of a program that contains a
27102644Snectar# configuration script generated by Autoconf, you may include it under
28102644Snectar# the same distribution terms that you use for the rest of that program.
29102644Snectar
3072445Sassarif test $# -eq 0; then
3172445Sassar  echo 1>&2 "Try \`$0 --help' for more information"
3272445Sassar  exit 1
3372445Sassarfi
3472445Sassar
3572445Sassarrun=:
3672445Sassar
37102644Snectar# In the cases where this matters, `missing' is being run in the
38102644Snectar# srcdir already.
39102644Snectarif test -f configure.ac; then
40102644Snectar  configure_ac=configure.ac
41102644Snectarelse
42102644Snectar  configure_ac=configure.in
43102644Snectarfi
44102644Snectar
45142403Snectarmsg="missing on your system"
46142403Snectar
4772445Sassarcase "$1" in
4872445Sassar--run)
4972445Sassar  # Try to run requested program, and just exit if it succeeds.
5072445Sassar  run=
5172445Sassar  shift
5272445Sassar  "$@" && exit 0
53142403Snectar  # Exit code 63 means version mismatch.  This often happens
54142403Snectar  # when the user try to use an ancient version of a tool on
55142403Snectar  # a file that requires a minimum version.  In this case we
56142403Snectar  # we should proceed has if the program had been absent, or
57142403Snectar  # if --run hadn't been passed.
58142403Snectar  if test $? = 63; then
59142403Snectar    run=:
60142403Snectar    msg="probably too old"
61142403Snectar  fi
6272445Sassar  ;;
6372445Sassaresac
6472445Sassar
6572445Sassar# If it does not exist, or fails to run (possibly an outdated version),
6672445Sassar# try to emulate it.
6772445Sassarcase "$1" in
6872445Sassar
6972445Sassar  -h|--h|--he|--hel|--help)
7072445Sassar    echo "\
7172445Sassar$0 [OPTION]... PROGRAM [ARGUMENT]...
7272445Sassar
7372445SassarHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7472445Sassarerror status if there is no known handling for PROGRAM.
7572445Sassar
7672445SassarOptions:
7772445Sassar  -h, --help      display this help and exit
7872445Sassar  -v, --version   output version information and exit
7972445Sassar  --run           try to run the given command, and emulate it if it fails
8072445Sassar
8172445SassarSupported PROGRAM values:
8272445Sassar  aclocal      touch file \`aclocal.m4'
8372445Sassar  autoconf     touch file \`configure'
8472445Sassar  autoheader   touch file \`config.h.in'
8572445Sassar  automake     touch all \`Makefile.in' files
8672445Sassar  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8772445Sassar  flex         create \`lex.yy.c', if possible, from existing .c
8872445Sassar  help2man     touch the output file
8972445Sassar  lex          create \`lex.yy.c', if possible, from existing .c
9072445Sassar  makeinfo     touch the output file
9172445Sassar  tar          try tar, gnutar, gtar, then tar without non-portable flags
92142403Snectar  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
93142403Snectar
94142403SnectarSend bug reports to <bug-automake@gnu.org>."
9572445Sassar    ;;
9672445Sassar
9772445Sassar  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
98142403Snectar    echo "missing $scriptversion (GNU Automake)"
9972445Sassar    ;;
10072445Sassar
10172445Sassar  -*)
10272445Sassar    echo 1>&2 "$0: Unknown \`$1' option"
10372445Sassar    echo 1>&2 "Try \`$0 --help' for more information"
10472445Sassar    exit 1
10572445Sassar    ;;
10672445Sassar
107102644Snectar  aclocal*)
108102644Snectar    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
109102644Snectar       # We have it, but it failed.
110102644Snectar       exit 1
111102644Snectar    fi
112102644Snectar
11372445Sassar    echo 1>&2 "\
114142403SnectarWARNING: \`$1' is $msg.  You should only need it if
115102644Snectar         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
11672445Sassar         to install the \`Automake' and \`Perl' packages.  Grab them from
11772445Sassar         any GNU archive site."
11872445Sassar    touch aclocal.m4
11972445Sassar    ;;
12072445Sassar
12172445Sassar  autoconf)
122102644Snectar    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
123102644Snectar       # We have it, but it failed.
124102644Snectar       exit 1
125102644Snectar    fi
126102644Snectar
12772445Sassar    echo 1>&2 "\
128142403SnectarWARNING: \`$1' is $msg.  You should only need it if
129102644Snectar         you modified \`${configure_ac}'.  You might want to install the
13072445Sassar         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
13172445Sassar         archive site."
13272445Sassar    touch configure
13372445Sassar    ;;
13472445Sassar
13572445Sassar  autoheader)
136102644Snectar    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
137102644Snectar       # We have it, but it failed.
138102644Snectar       exit 1
139102644Snectar    fi
140102644Snectar
14172445Sassar    echo 1>&2 "\
142142403SnectarWARNING: \`$1' is $msg.  You should only need it if
143102644Snectar         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
14472445Sassar         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
14572445Sassar         from any GNU archive site."
146102644Snectar    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
14772445Sassar    test -z "$files" && files="config.h"
14872445Sassar    touch_files=
14972445Sassar    for f in $files; do
15072445Sassar      case "$f" in
15172445Sassar      *:*) touch_files="$touch_files "`echo "$f" |
15272445Sassar				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
15372445Sassar      *) touch_files="$touch_files $f.in";;
15472445Sassar      esac
15572445Sassar    done
15672445Sassar    touch $touch_files
15772445Sassar    ;;
15872445Sassar
159102644Snectar  automake*)
160102644Snectar    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
161102644Snectar       # We have it, but it failed.
162102644Snectar       exit 1
163102644Snectar    fi
164102644Snectar
16572445Sassar    echo 1>&2 "\
166142403SnectarWARNING: \`$1' is $msg.  You should only need it if
167102644Snectar         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
16872445Sassar         You might want to install the \`Automake' and \`Perl' packages.
16972445Sassar         Grab them from any GNU archive site."
17072445Sassar    find . -type f -name Makefile.am -print |
17172445Sassar	   sed 's/\.am$/.in/' |
17272445Sassar	   while read f; do touch "$f"; done
17372445Sassar    ;;
17472445Sassar
175102644Snectar  autom4te)
176102644Snectar    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
177102644Snectar       # We have it, but it failed.
178102644Snectar       exit 1
179102644Snectar    fi
180102644Snectar
181102644Snectar    echo 1>&2 "\
182142403SnectarWARNING: \`$1' is needed, but is $msg.
183142403Snectar         You might have modified some files without having the
184102644Snectar         proper tools for further handling them.
185127808Snectar         You can get \`$1' as part of \`Autoconf' from any GNU
186102644Snectar         archive site."
187102644Snectar
188102644Snectar    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
189102644Snectar    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
190102644Snectar    if test -f "$file"; then
191102644Snectar	touch $file
192102644Snectar    else
193102644Snectar	test -z "$file" || exec >$file
194102644Snectar	echo "#! /bin/sh"
195102644Snectar	echo "# Created by GNU Automake missing as a replacement of"
196102644Snectar	echo "#  $ $@"
197102644Snectar	echo "exit 0"
198102644Snectar	chmod +x $file
199102644Snectar	exit 1
200102644Snectar    fi
201102644Snectar    ;;
202102644Snectar
20372445Sassar  bison|yacc)
20472445Sassar    echo 1>&2 "\
205142403SnectarWARNING: \`$1' $msg.  You should only need it if
20672445Sassar         you modified a \`.y' file.  You may need the \`Bison' package
20772445Sassar         in order for those modifications to take effect.  You can get
20872445Sassar         \`Bison' from any GNU archive site."
20972445Sassar    rm -f y.tab.c y.tab.h
21072445Sassar    if [ $# -ne 1 ]; then
21172445Sassar        eval LASTARG="\${$#}"
21272445Sassar	case "$LASTARG" in
21372445Sassar	*.y)
21472445Sassar	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
21572445Sassar	    if [ -f "$SRCFILE" ]; then
21672445Sassar	         cp "$SRCFILE" y.tab.c
21772445Sassar	    fi
21872445Sassar	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
21972445Sassar	    if [ -f "$SRCFILE" ]; then
22072445Sassar	         cp "$SRCFILE" y.tab.h
22172445Sassar	    fi
22272445Sassar	  ;;
22372445Sassar	esac
22472445Sassar    fi
22572445Sassar    if [ ! -f y.tab.h ]; then
22672445Sassar	echo >y.tab.h
22772445Sassar    fi
22872445Sassar    if [ ! -f y.tab.c ]; then
22972445Sassar	echo 'main() { return 0; }' >y.tab.c
23072445Sassar    fi
23172445Sassar    ;;
23272445Sassar
23372445Sassar  lex|flex)
23472445Sassar    echo 1>&2 "\
235142403SnectarWARNING: \`$1' is $msg.  You should only need it if
23672445Sassar         you modified a \`.l' file.  You may need the \`Flex' package
23772445Sassar         in order for those modifications to take effect.  You can get
23872445Sassar         \`Flex' from any GNU archive site."
23972445Sassar    rm -f lex.yy.c
24072445Sassar    if [ $# -ne 1 ]; then
24172445Sassar        eval LASTARG="\${$#}"
24272445Sassar	case "$LASTARG" in
24372445Sassar	*.l)
24472445Sassar	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
24572445Sassar	    if [ -f "$SRCFILE" ]; then
24672445Sassar	         cp "$SRCFILE" lex.yy.c
24772445Sassar	    fi
24872445Sassar	  ;;
24972445Sassar	esac
25072445Sassar    fi
25172445Sassar    if [ ! -f lex.yy.c ]; then
25272445Sassar	echo 'main() { return 0; }' >lex.yy.c
25372445Sassar    fi
25472445Sassar    ;;
25572445Sassar
25672445Sassar  help2man)
257102644Snectar    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
258102644Snectar       # We have it, but it failed.
259102644Snectar       exit 1
260102644Snectar    fi
261102644Snectar
26272445Sassar    echo 1>&2 "\
263142403SnectarWARNING: \`$1' is $msg.  You should only need it if
26472445Sassar	 you modified a dependency of a manual page.  You may need the
26572445Sassar	 \`Help2man' package in order for those modifications to take
26672445Sassar	 effect.  You can get \`Help2man' from any GNU archive site."
26772445Sassar
26872445Sassar    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
26972445Sassar    if test -z "$file"; then
27072445Sassar	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
27172445Sassar    fi
27272445Sassar    if [ -f "$file" ]; then
27372445Sassar	touch $file
27472445Sassar    else
27572445Sassar	test -z "$file" || exec >$file
27672445Sassar	echo ".ab help2man is required to generate this page"
27772445Sassar	exit 1
27872445Sassar    fi
27972445Sassar    ;;
28072445Sassar
28172445Sassar  makeinfo)
282102644Snectar    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
283102644Snectar       # We have makeinfo, but it failed.
284102644Snectar       exit 1
285102644Snectar    fi
286102644Snectar
28772445Sassar    echo 1>&2 "\
288142403SnectarWARNING: \`$1' is $msg.  You should only need it if
28972445Sassar         you modified a \`.texi' or \`.texinfo' file, or any other file
29072445Sassar         indirectly affecting the aspect of the manual.  The spurious
29172445Sassar         call might also be the consequence of using a buggy \`make' (AIX,
29272445Sassar         DU, IRIX).  You might want to install the \`Texinfo' package or
29372445Sassar         the \`GNU make' package.  Grab either from any GNU archive site."
29472445Sassar    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
29572445Sassar    if test -z "$file"; then
29672445Sassar      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29772445Sassar      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
29872445Sassar    fi
29972445Sassar    touch $file
30072445Sassar    ;;
30172445Sassar
30272445Sassar  tar)
30372445Sassar    shift
30472445Sassar    if test -n "$run"; then
30572445Sassar      echo 1>&2 "ERROR: \`tar' requires --run"
30672445Sassar      exit 1
30772445Sassar    fi
30872445Sassar
30972445Sassar    # We have already tried tar in the generic part.
31072445Sassar    # Look for gnutar/gtar before invocation to avoid ugly error
31172445Sassar    # messages.
31272445Sassar    if (gnutar --version > /dev/null 2>&1); then
313127808Snectar       gnutar "$@" && exit 0
31472445Sassar    fi
31572445Sassar    if (gtar --version > /dev/null 2>&1); then
316127808Snectar       gtar "$@" && exit 0
31772445Sassar    fi
31872445Sassar    firstarg="$1"
31972445Sassar    if shift; then
32072445Sassar	case "$firstarg" in
32172445Sassar	*o*)
32272445Sassar	    firstarg=`echo "$firstarg" | sed s/o//`
323127808Snectar	    tar "$firstarg" "$@" && exit 0
32472445Sassar	    ;;
32572445Sassar	esac
32672445Sassar	case "$firstarg" in
32772445Sassar	*h*)
32872445Sassar	    firstarg=`echo "$firstarg" | sed s/h//`
329127808Snectar	    tar "$firstarg" "$@" && exit 0
33072445Sassar	    ;;
33172445Sassar	esac
33272445Sassar    fi
33372445Sassar
33472445Sassar    echo 1>&2 "\
33572445SassarWARNING: I can't seem to be able to run \`tar' with the given arguments.
33672445Sassar         You may want to install GNU tar or Free paxutils, or check the
33772445Sassar         command line arguments."
33872445Sassar    exit 1
33972445Sassar    ;;
34072445Sassar
34172445Sassar  *)
34272445Sassar    echo 1>&2 "\
343142403SnectarWARNING: \`$1' is needed, and is $msg.
344142403Snectar         You might have modified some files without having the
34572445Sassar         proper tools for further handling them.  Check the \`README' file,
346127808Snectar         it often tells you about the needed prerequisites for installing
34772445Sassar         this package.  You may also peek at any GNU archive site, in case
34872445Sassar         some other package would contain this missing \`$1' program."
34972445Sassar    exit 1
35072445Sassar    ;;
35172445Sassaresac
35272445Sassar
35372445Sassarexit 0
354142403Snectar
355142403Snectar# Local variables:
356142403Snectar# eval: (add-hook 'write-file-hooks 'time-stamp)
357142403Snectar# time-stamp-start: "scriptversion="
358142403Snectar# time-stamp-format: "%:y-%02m-%02d.%02H"
359142403Snectar# time-stamp-end: "$"
360142403Snectar# End:
361