missing revision 2c393a42
12c393a42Smrg#! /bin/sh
22c393a42Smrg# Common stub for a few missing GNU programs while installing.
32c393a42Smrg
42c393a42Smrgscriptversion=2005-06-08.21
52c393a42Smrg
62c393a42Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
72c393a42Smrg#   Free Software Foundation, Inc.
82c393a42Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
92c393a42Smrg
102c393a42Smrg# This program is free software; you can redistribute it and/or modify
112c393a42Smrg# it under the terms of the GNU General Public License as published by
122c393a42Smrg# the Free Software Foundation; either version 2, or (at your option)
132c393a42Smrg# any later version.
142c393a42Smrg
152c393a42Smrg# This program is distributed in the hope that it will be useful,
162c393a42Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
172c393a42Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
182c393a42Smrg# GNU General Public License for more details.
192c393a42Smrg
202c393a42Smrg# You should have received a copy of the GNU General Public License
212c393a42Smrg# along with this program; if not, write to the Free Software
222c393a42Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
232c393a42Smrg# 02110-1301, USA.
242c393a42Smrg
252c393a42Smrg# As a special exception to the GNU General Public License, if you
262c393a42Smrg# distribute this file as part of a program that contains a
272c393a42Smrg# configuration script generated by Autoconf, you may include it under
282c393a42Smrg# the same distribution terms that you use for the rest of that program.
292c393a42Smrg
302c393a42Smrgif test $# -eq 0; then
312c393a42Smrg  echo 1>&2 "Try \`$0 --help' for more information"
322c393a42Smrg  exit 1
332c393a42Smrgfi
342c393a42Smrg
352c393a42Smrgrun=:
362c393a42Smrg
372c393a42Smrg# In the cases where this matters, `missing' is being run in the
382c393a42Smrg# srcdir already.
392c393a42Smrgif test -f configure.ac; then
402c393a42Smrg  configure_ac=configure.ac
412c393a42Smrgelse
422c393a42Smrg  configure_ac=configure.in
432c393a42Smrgfi
442c393a42Smrg
452c393a42Smrgmsg="missing on your system"
462c393a42Smrg
472c393a42Smrgcase "$1" in
482c393a42Smrg--run)
492c393a42Smrg  # Try to run requested program, and just exit if it succeeds.
502c393a42Smrg  run=
512c393a42Smrg  shift
522c393a42Smrg  "$@" && exit 0
532c393a42Smrg  # Exit code 63 means version mismatch.  This often happens
542c393a42Smrg  # when the user try to use an ancient version of a tool on
552c393a42Smrg  # a file that requires a minimum version.  In this case we
562c393a42Smrg  # we should proceed has if the program had been absent, or
572c393a42Smrg  # if --run hadn't been passed.
582c393a42Smrg  if test $? = 63; then
592c393a42Smrg    run=:
602c393a42Smrg    msg="probably too old"
612c393a42Smrg  fi
622c393a42Smrg  ;;
632c393a42Smrg
642c393a42Smrg  -h|--h|--he|--hel|--help)
652c393a42Smrg    echo "\
662c393a42Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
672c393a42Smrg
682c393a42SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
692c393a42Smrgerror status if there is no known handling for PROGRAM.
702c393a42Smrg
712c393a42SmrgOptions:
722c393a42Smrg  -h, --help      display this help and exit
732c393a42Smrg  -v, --version   output version information and exit
742c393a42Smrg  --run           try to run the given command, and emulate it if it fails
752c393a42Smrg
762c393a42SmrgSupported PROGRAM values:
772c393a42Smrg  aclocal      touch file \`aclocal.m4'
782c393a42Smrg  autoconf     touch file \`configure'
792c393a42Smrg  autoheader   touch file \`config.h.in'
802c393a42Smrg  automake     touch all \`Makefile.in' files
812c393a42Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
822c393a42Smrg  flex         create \`lex.yy.c', if possible, from existing .c
832c393a42Smrg  help2man     touch the output file
842c393a42Smrg  lex          create \`lex.yy.c', if possible, from existing .c
852c393a42Smrg  makeinfo     touch the output file
862c393a42Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
872c393a42Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
882c393a42Smrg
892c393a42SmrgSend bug reports to <bug-automake@gnu.org>."
902c393a42Smrg    exit $?
912c393a42Smrg    ;;
922c393a42Smrg
932c393a42Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
942c393a42Smrg    echo "missing $scriptversion (GNU Automake)"
952c393a42Smrg    exit $?
962c393a42Smrg    ;;
972c393a42Smrg
982c393a42Smrg  -*)
992c393a42Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1002c393a42Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1012c393a42Smrg    exit 1
1022c393a42Smrg    ;;
1032c393a42Smrg
1042c393a42Smrgesac
1052c393a42Smrg
1062c393a42Smrg# Now exit if we have it, but it failed.  Also exit now if we
1072c393a42Smrg# don't have it and --version was passed (most likely to detect
1082c393a42Smrg# the program).
1092c393a42Smrgcase "$1" in
1102c393a42Smrg  lex|yacc)
1112c393a42Smrg    # Not GNU programs, they don't have --version.
1122c393a42Smrg    ;;
1132c393a42Smrg
1142c393a42Smrg  tar)
1152c393a42Smrg    if test -n "$run"; then
1162c393a42Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1172c393a42Smrg       exit 1
1182c393a42Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1192c393a42Smrg       exit 1
1202c393a42Smrg    fi
1212c393a42Smrg    ;;
1222c393a42Smrg
1232c393a42Smrg  *)
1242c393a42Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1252c393a42Smrg       # We have it, but it failed.
1262c393a42Smrg       exit 1
1272c393a42Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1282c393a42Smrg       # Could not run --version or --help.  This is probably someone
1292c393a42Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1302c393a42Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1312c393a42Smrg       exit 1
1322c393a42Smrg    fi
1332c393a42Smrg    ;;
1342c393a42Smrgesac
1352c393a42Smrg
1362c393a42Smrg# If it does not exist, or fails to run (possibly an outdated version),
1372c393a42Smrg# try to emulate it.
1382c393a42Smrgcase "$1" in
1392c393a42Smrg  aclocal*)
1402c393a42Smrg    echo 1>&2 "\
1412c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
1422c393a42Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1432c393a42Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1442c393a42Smrg         any GNU archive site."
1452c393a42Smrg    touch aclocal.m4
1462c393a42Smrg    ;;
1472c393a42Smrg
1482c393a42Smrg  autoconf)
1492c393a42Smrg    echo 1>&2 "\
1502c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
1512c393a42Smrg         you modified \`${configure_ac}'.  You might want to install the
1522c393a42Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1532c393a42Smrg         archive site."
1542c393a42Smrg    touch configure
1552c393a42Smrg    ;;
1562c393a42Smrg
1572c393a42Smrg  autoheader)
1582c393a42Smrg    echo 1>&2 "\
1592c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
1602c393a42Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1612c393a42Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1622c393a42Smrg         from any GNU archive site."
1632c393a42Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1642c393a42Smrg    test -z "$files" && files="config.h"
1652c393a42Smrg    touch_files=
1662c393a42Smrg    for f in $files; do
1672c393a42Smrg      case "$f" in
1682c393a42Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1692c393a42Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1702c393a42Smrg      *) touch_files="$touch_files $f.in";;
1712c393a42Smrg      esac
1722c393a42Smrg    done
1732c393a42Smrg    touch $touch_files
1742c393a42Smrg    ;;
1752c393a42Smrg
1762c393a42Smrg  automake*)
1772c393a42Smrg    echo 1>&2 "\
1782c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
1792c393a42Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1802c393a42Smrg         You might want to install the \`Automake' and \`Perl' packages.
1812c393a42Smrg         Grab them from any GNU archive site."
1822c393a42Smrg    find . -type f -name Makefile.am -print |
1832c393a42Smrg	   sed 's/\.am$/.in/' |
1842c393a42Smrg	   while read f; do touch "$f"; done
1852c393a42Smrg    ;;
1862c393a42Smrg
1872c393a42Smrg  autom4te)
1882c393a42Smrg    echo 1>&2 "\
1892c393a42SmrgWARNING: \`$1' is needed, but is $msg.
1902c393a42Smrg         You might have modified some files without having the
1912c393a42Smrg         proper tools for further handling them.
1922c393a42Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1932c393a42Smrg         archive site."
1942c393a42Smrg
1952c393a42Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
1962c393a42Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
1972c393a42Smrg    if test -f "$file"; then
1982c393a42Smrg	touch $file
1992c393a42Smrg    else
2002c393a42Smrg	test -z "$file" || exec >$file
2012c393a42Smrg	echo "#! /bin/sh"
2022c393a42Smrg	echo "# Created by GNU Automake missing as a replacement of"
2032c393a42Smrg	echo "#  $ $@"
2042c393a42Smrg	echo "exit 0"
2052c393a42Smrg	chmod +x $file
2062c393a42Smrg	exit 1
2072c393a42Smrg    fi
2082c393a42Smrg    ;;
2092c393a42Smrg
2102c393a42Smrg  bison|yacc)
2112c393a42Smrg    echo 1>&2 "\
2122c393a42SmrgWARNING: \`$1' $msg.  You should only need it if
2132c393a42Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2142c393a42Smrg         in order for those modifications to take effect.  You can get
2152c393a42Smrg         \`Bison' from any GNU archive site."
2162c393a42Smrg    rm -f y.tab.c y.tab.h
2172c393a42Smrg    if [ $# -ne 1 ]; then
2182c393a42Smrg        eval LASTARG="\${$#}"
2192c393a42Smrg	case "$LASTARG" in
2202c393a42Smrg	*.y)
2212c393a42Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2222c393a42Smrg	    if [ -f "$SRCFILE" ]; then
2232c393a42Smrg	         cp "$SRCFILE" y.tab.c
2242c393a42Smrg	    fi
2252c393a42Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2262c393a42Smrg	    if [ -f "$SRCFILE" ]; then
2272c393a42Smrg	         cp "$SRCFILE" y.tab.h
2282c393a42Smrg	    fi
2292c393a42Smrg	  ;;
2302c393a42Smrg	esac
2312c393a42Smrg    fi
2322c393a42Smrg    if [ ! -f y.tab.h ]; then
2332c393a42Smrg	echo >y.tab.h
2342c393a42Smrg    fi
2352c393a42Smrg    if [ ! -f y.tab.c ]; then
2362c393a42Smrg	echo 'main() { return 0; }' >y.tab.c
2372c393a42Smrg    fi
2382c393a42Smrg    ;;
2392c393a42Smrg
2402c393a42Smrg  lex|flex)
2412c393a42Smrg    echo 1>&2 "\
2422c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
2432c393a42Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2442c393a42Smrg         in order for those modifications to take effect.  You can get
2452c393a42Smrg         \`Flex' from any GNU archive site."
2462c393a42Smrg    rm -f lex.yy.c
2472c393a42Smrg    if [ $# -ne 1 ]; then
2482c393a42Smrg        eval LASTARG="\${$#}"
2492c393a42Smrg	case "$LASTARG" in
2502c393a42Smrg	*.l)
2512c393a42Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2522c393a42Smrg	    if [ -f "$SRCFILE" ]; then
2532c393a42Smrg	         cp "$SRCFILE" lex.yy.c
2542c393a42Smrg	    fi
2552c393a42Smrg	  ;;
2562c393a42Smrg	esac
2572c393a42Smrg    fi
2582c393a42Smrg    if [ ! -f lex.yy.c ]; then
2592c393a42Smrg	echo 'main() { return 0; }' >lex.yy.c
2602c393a42Smrg    fi
2612c393a42Smrg    ;;
2622c393a42Smrg
2632c393a42Smrg  help2man)
2642c393a42Smrg    echo 1>&2 "\
2652c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
2662c393a42Smrg	 you modified a dependency of a manual page.  You may need the
2672c393a42Smrg	 \`Help2man' package in order for those modifications to take
2682c393a42Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2692c393a42Smrg
2702c393a42Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2712c393a42Smrg    if test -z "$file"; then
2722c393a42Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2732c393a42Smrg    fi
2742c393a42Smrg    if [ -f "$file" ]; then
2752c393a42Smrg	touch $file
2762c393a42Smrg    else
2772c393a42Smrg	test -z "$file" || exec >$file
2782c393a42Smrg	echo ".ab help2man is required to generate this page"
2792c393a42Smrg	exit 1
2802c393a42Smrg    fi
2812c393a42Smrg    ;;
2822c393a42Smrg
2832c393a42Smrg  makeinfo)
2842c393a42Smrg    echo 1>&2 "\
2852c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
2862c393a42Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2872c393a42Smrg         indirectly affecting the aspect of the manual.  The spurious
2882c393a42Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2892c393a42Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2902c393a42Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2912c393a42Smrg    # The file to touch is that specified with -o ...
2922c393a42Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2932c393a42Smrg    if test -z "$file"; then
2942c393a42Smrg      # ... or it is the one specified with @setfilename ...
2952c393a42Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2962c393a42Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
2972c393a42Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
2982c393a42Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
2992c393a42Smrg    fi
3002c393a42Smrg    # If the file does not exist, the user really needs makeinfo;
3012c393a42Smrg    # let's fail without touching anything.
3022c393a42Smrg    test -f $file || exit 1
3032c393a42Smrg    touch $file
3042c393a42Smrg    ;;
3052c393a42Smrg
3062c393a42Smrg  tar)
3072c393a42Smrg    shift
3082c393a42Smrg
3092c393a42Smrg    # We have already tried tar in the generic part.
3102c393a42Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3112c393a42Smrg    # messages.
3122c393a42Smrg    if (gnutar --version > /dev/null 2>&1); then
3132c393a42Smrg       gnutar "$@" && exit 0
3142c393a42Smrg    fi
3152c393a42Smrg    if (gtar --version > /dev/null 2>&1); then
3162c393a42Smrg       gtar "$@" && exit 0
3172c393a42Smrg    fi
3182c393a42Smrg    firstarg="$1"
3192c393a42Smrg    if shift; then
3202c393a42Smrg	case "$firstarg" in
3212c393a42Smrg	*o*)
3222c393a42Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3232c393a42Smrg	    tar "$firstarg" "$@" && exit 0
3242c393a42Smrg	    ;;
3252c393a42Smrg	esac
3262c393a42Smrg	case "$firstarg" in
3272c393a42Smrg	*h*)
3282c393a42Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3292c393a42Smrg	    tar "$firstarg" "$@" && exit 0
3302c393a42Smrg	    ;;
3312c393a42Smrg	esac
3322c393a42Smrg    fi
3332c393a42Smrg
3342c393a42Smrg    echo 1>&2 "\
3352c393a42SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3362c393a42Smrg         You may want to install GNU tar or Free paxutils, or check the
3372c393a42Smrg         command line arguments."
3382c393a42Smrg    exit 1
3392c393a42Smrg    ;;
3402c393a42Smrg
3412c393a42Smrg  *)
3422c393a42Smrg    echo 1>&2 "\
3432c393a42SmrgWARNING: \`$1' is needed, and is $msg.
3442c393a42Smrg         You might have modified some files without having the
3452c393a42Smrg         proper tools for further handling them.  Check the \`README' file,
3462c393a42Smrg         it often tells you about the needed prerequisites for installing
3472c393a42Smrg         this package.  You may also peek at any GNU archive site, in case
3482c393a42Smrg         some other package would contain this missing \`$1' program."
3492c393a42Smrg    exit 1
3502c393a42Smrg    ;;
3512c393a42Smrgesac
3522c393a42Smrg
3532c393a42Smrgexit 0
3542c393a42Smrg
3552c393a42Smrg# Local variables:
3562c393a42Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3572c393a42Smrg# time-stamp-start: "scriptversion="
3582c393a42Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3592c393a42Smrg# time-stamp-end: "$"
3602c393a42Smrg# End:
361