missing revision 4b0ead49
14b0ead49Smrg#! /bin/sh
24b0ead49Smrg# Common stub for a few missing GNU programs while installing.
34b0ead49Smrg
44b0ead49Smrgscriptversion=2005-06-08.21
54b0ead49Smrg
64b0ead49Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
74b0ead49Smrg#   Free Software Foundation, Inc.
84b0ead49Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
94b0ead49Smrg
104b0ead49Smrg# This program is free software; you can redistribute it and/or modify
114b0ead49Smrg# it under the terms of the GNU General Public License as published by
124b0ead49Smrg# the Free Software Foundation; either version 2, or (at your option)
134b0ead49Smrg# any later version.
144b0ead49Smrg
154b0ead49Smrg# This program is distributed in the hope that it will be useful,
164b0ead49Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
174b0ead49Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
184b0ead49Smrg# GNU General Public License for more details.
194b0ead49Smrg
204b0ead49Smrg# You should have received a copy of the GNU General Public License
214b0ead49Smrg# along with this program; if not, write to the Free Software
224b0ead49Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
234b0ead49Smrg# 02110-1301, USA.
244b0ead49Smrg
254b0ead49Smrg# As a special exception to the GNU General Public License, if you
264b0ead49Smrg# distribute this file as part of a program that contains a
274b0ead49Smrg# configuration script generated by Autoconf, you may include it under
284b0ead49Smrg# the same distribution terms that you use for the rest of that program.
294b0ead49Smrg
304b0ead49Smrgif test $# -eq 0; then
314b0ead49Smrg  echo 1>&2 "Try \`$0 --help' for more information"
324b0ead49Smrg  exit 1
334b0ead49Smrgfi
344b0ead49Smrg
354b0ead49Smrgrun=:
364b0ead49Smrg
374b0ead49Smrg# In the cases where this matters, `missing' is being run in the
384b0ead49Smrg# srcdir already.
394b0ead49Smrgif test -f configure.ac; then
404b0ead49Smrg  configure_ac=configure.ac
414b0ead49Smrgelse
424b0ead49Smrg  configure_ac=configure.in
434b0ead49Smrgfi
444b0ead49Smrg
454b0ead49Smrgmsg="missing on your system"
464b0ead49Smrg
474b0ead49Smrgcase "$1" in
484b0ead49Smrg--run)
494b0ead49Smrg  # Try to run requested program, and just exit if it succeeds.
504b0ead49Smrg  run=
514b0ead49Smrg  shift
524b0ead49Smrg  "$@" && exit 0
534b0ead49Smrg  # Exit code 63 means version mismatch.  This often happens
544b0ead49Smrg  # when the user try to use an ancient version of a tool on
554b0ead49Smrg  # a file that requires a minimum version.  In this case we
564b0ead49Smrg  # we should proceed has if the program had been absent, or
574b0ead49Smrg  # if --run hadn't been passed.
584b0ead49Smrg  if test $? = 63; then
594b0ead49Smrg    run=:
604b0ead49Smrg    msg="probably too old"
614b0ead49Smrg  fi
624b0ead49Smrg  ;;
634b0ead49Smrg
644b0ead49Smrg  -h|--h|--he|--hel|--help)
654b0ead49Smrg    echo "\
664b0ead49Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
674b0ead49Smrg
684b0ead49SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
694b0ead49Smrgerror status if there is no known handling for PROGRAM.
704b0ead49Smrg
714b0ead49SmrgOptions:
724b0ead49Smrg  -h, --help      display this help and exit
734b0ead49Smrg  -v, --version   output version information and exit
744b0ead49Smrg  --run           try to run the given command, and emulate it if it fails
754b0ead49Smrg
764b0ead49SmrgSupported PROGRAM values:
774b0ead49Smrg  aclocal      touch file \`aclocal.m4'
784b0ead49Smrg  autoconf     touch file \`configure'
794b0ead49Smrg  autoheader   touch file \`config.h.in'
804b0ead49Smrg  automake     touch all \`Makefile.in' files
814b0ead49Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
824b0ead49Smrg  flex         create \`lex.yy.c', if possible, from existing .c
834b0ead49Smrg  help2man     touch the output file
844b0ead49Smrg  lex          create \`lex.yy.c', if possible, from existing .c
854b0ead49Smrg  makeinfo     touch the output file
864b0ead49Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
874b0ead49Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
884b0ead49Smrg
894b0ead49SmrgSend bug reports to <bug-automake@gnu.org>."
904b0ead49Smrg    exit $?
914b0ead49Smrg    ;;
924b0ead49Smrg
934b0ead49Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
944b0ead49Smrg    echo "missing $scriptversion (GNU Automake)"
954b0ead49Smrg    exit $?
964b0ead49Smrg    ;;
974b0ead49Smrg
984b0ead49Smrg  -*)
994b0ead49Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1004b0ead49Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1014b0ead49Smrg    exit 1
1024b0ead49Smrg    ;;
1034b0ead49Smrg
1044b0ead49Smrgesac
1054b0ead49Smrg
1064b0ead49Smrg# Now exit if we have it, but it failed.  Also exit now if we
1074b0ead49Smrg# don't have it and --version was passed (most likely to detect
1084b0ead49Smrg# the program).
1094b0ead49Smrgcase "$1" in
1104b0ead49Smrg  lex|yacc)
1114b0ead49Smrg    # Not GNU programs, they don't have --version.
1124b0ead49Smrg    ;;
1134b0ead49Smrg
1144b0ead49Smrg  tar)
1154b0ead49Smrg    if test -n "$run"; then
1164b0ead49Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1174b0ead49Smrg       exit 1
1184b0ead49Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1194b0ead49Smrg       exit 1
1204b0ead49Smrg    fi
1214b0ead49Smrg    ;;
1224b0ead49Smrg
1234b0ead49Smrg  *)
1244b0ead49Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1254b0ead49Smrg       # We have it, but it failed.
1264b0ead49Smrg       exit 1
1274b0ead49Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1284b0ead49Smrg       # Could not run --version or --help.  This is probably someone
1294b0ead49Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1304b0ead49Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1314b0ead49Smrg       exit 1
1324b0ead49Smrg    fi
1334b0ead49Smrg    ;;
1344b0ead49Smrgesac
1354b0ead49Smrg
1364b0ead49Smrg# If it does not exist, or fails to run (possibly an outdated version),
1374b0ead49Smrg# try to emulate it.
1384b0ead49Smrgcase "$1" in
1394b0ead49Smrg  aclocal*)
1404b0ead49Smrg    echo 1>&2 "\
1414b0ead49SmrgWARNING: \`$1' is $msg.  You should only need it if
1424b0ead49Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1434b0ead49Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1444b0ead49Smrg         any GNU archive site."
1454b0ead49Smrg    touch aclocal.m4
1464b0ead49Smrg    ;;
1474b0ead49Smrg
1484b0ead49Smrg  autoconf)
1494b0ead49Smrg    echo 1>&2 "\
1504b0ead49SmrgWARNING: \`$1' is $msg.  You should only need it if
1514b0ead49Smrg         you modified \`${configure_ac}'.  You might want to install the
1524b0ead49Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1534b0ead49Smrg         archive site."
1544b0ead49Smrg    touch configure
1554b0ead49Smrg    ;;
1564b0ead49Smrg
1574b0ead49Smrg  autoheader)
1584b0ead49Smrg    echo 1>&2 "\
1594b0ead49SmrgWARNING: \`$1' is $msg.  You should only need it if
1604b0ead49Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1614b0ead49Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1624b0ead49Smrg         from any GNU archive site."
1634b0ead49Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1644b0ead49Smrg    test -z "$files" && files="config.h"
1654b0ead49Smrg    touch_files=
1664b0ead49Smrg    for f in $files; do
1674b0ead49Smrg      case "$f" in
1684b0ead49Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1694b0ead49Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1704b0ead49Smrg      *) touch_files="$touch_files $f.in";;
1714b0ead49Smrg      esac
1724b0ead49Smrg    done
1734b0ead49Smrg    touch $touch_files
1744b0ead49Smrg    ;;
1754b0ead49Smrg
1764b0ead49Smrg  automake*)
1774b0ead49Smrg    echo 1>&2 "\
1784b0ead49SmrgWARNING: \`$1' is $msg.  You should only need it if
1794b0ead49Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1804b0ead49Smrg         You might want to install the \`Automake' and \`Perl' packages.
1814b0ead49Smrg         Grab them from any GNU archive site."
1824b0ead49Smrg    find . -type f -name Makefile.am -print |
1834b0ead49Smrg	   sed 's/\.am$/.in/' |
1844b0ead49Smrg	   while read f; do touch "$f"; done
1854b0ead49Smrg    ;;
1864b0ead49Smrg
1874b0ead49Smrg  autom4te)
1884b0ead49Smrg    echo 1>&2 "\
1894b0ead49SmrgWARNING: \`$1' is needed, but is $msg.
1904b0ead49Smrg         You might have modified some files without having the
1914b0ead49Smrg         proper tools for further handling them.
1924b0ead49Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1934b0ead49Smrg         archive site."
1944b0ead49Smrg
1954b0ead49Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
1964b0ead49Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
1974b0ead49Smrg    if test -f "$file"; then
1984b0ead49Smrg	touch $file
1994b0ead49Smrg    else
2004b0ead49Smrg	test -z "$file" || exec >$file
2014b0ead49Smrg	echo "#! /bin/sh"
2024b0ead49Smrg	echo "# Created by GNU Automake missing as a replacement of"
2034b0ead49Smrg	echo "#  $ $@"
2044b0ead49Smrg	echo "exit 0"
2054b0ead49Smrg	chmod +x $file
2064b0ead49Smrg	exit 1
2074b0ead49Smrg    fi
2084b0ead49Smrg    ;;
2094b0ead49Smrg
2104b0ead49Smrg  bison|yacc)
2114b0ead49Smrg    echo 1>&2 "\
2124b0ead49SmrgWARNING: \`$1' $msg.  You should only need it if
2134b0ead49Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2144b0ead49Smrg         in order for those modifications to take effect.  You can get
2154b0ead49Smrg         \`Bison' from any GNU archive site."
2164b0ead49Smrg    rm -f y.tab.c y.tab.h
2174b0ead49Smrg    if [ $# -ne 1 ]; then
2184b0ead49Smrg        eval LASTARG="\${$#}"
2194b0ead49Smrg	case "$LASTARG" in
2204b0ead49Smrg	*.y)
2214b0ead49Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2224b0ead49Smrg	    if [ -f "$SRCFILE" ]; then
2234b0ead49Smrg	         cp "$SRCFILE" y.tab.c
2244b0ead49Smrg	    fi
2254b0ead49Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2264b0ead49Smrg	    if [ -f "$SRCFILE" ]; then
2274b0ead49Smrg	         cp "$SRCFILE" y.tab.h
2284b0ead49Smrg	    fi
2294b0ead49Smrg	  ;;
2304b0ead49Smrg	esac
2314b0ead49Smrg    fi
2324b0ead49Smrg    if [ ! -f y.tab.h ]; then
2334b0ead49Smrg	echo >y.tab.h
2344b0ead49Smrg    fi
2354b0ead49Smrg    if [ ! -f y.tab.c ]; then
2364b0ead49Smrg	echo 'main() { return 0; }' >y.tab.c
2374b0ead49Smrg    fi
2384b0ead49Smrg    ;;
2394b0ead49Smrg
2404b0ead49Smrg  lex|flex)
2414b0ead49Smrg    echo 1>&2 "\
2424b0ead49SmrgWARNING: \`$1' is $msg.  You should only need it if
2434b0ead49Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2444b0ead49Smrg         in order for those modifications to take effect.  You can get
2454b0ead49Smrg         \`Flex' from any GNU archive site."
2464b0ead49Smrg    rm -f lex.yy.c
2474b0ead49Smrg    if [ $# -ne 1 ]; then
2484b0ead49Smrg        eval LASTARG="\${$#}"
2494b0ead49Smrg	case "$LASTARG" in
2504b0ead49Smrg	*.l)
2514b0ead49Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2524b0ead49Smrg	    if [ -f "$SRCFILE" ]; then
2534b0ead49Smrg	         cp "$SRCFILE" lex.yy.c
2544b0ead49Smrg	    fi
2554b0ead49Smrg	  ;;
2564b0ead49Smrg	esac
2574b0ead49Smrg    fi
2584b0ead49Smrg    if [ ! -f lex.yy.c ]; then
2594b0ead49Smrg	echo 'main() { return 0; }' >lex.yy.c
2604b0ead49Smrg    fi
2614b0ead49Smrg    ;;
2624b0ead49Smrg
2634b0ead49Smrg  help2man)
2644b0ead49Smrg    echo 1>&2 "\
2654b0ead49SmrgWARNING: \`$1' is $msg.  You should only need it if
2664b0ead49Smrg	 you modified a dependency of a manual page.  You may need the
2674b0ead49Smrg	 \`Help2man' package in order for those modifications to take
2684b0ead49Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2694b0ead49Smrg
2704b0ead49Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2714b0ead49Smrg    if test -z "$file"; then
2724b0ead49Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2734b0ead49Smrg    fi
2744b0ead49Smrg    if [ -f "$file" ]; then
2754b0ead49Smrg	touch $file
2764b0ead49Smrg    else
2774b0ead49Smrg	test -z "$file" || exec >$file
2784b0ead49Smrg	echo ".ab help2man is required to generate this page"
2794b0ead49Smrg	exit 1
2804b0ead49Smrg    fi
2814b0ead49Smrg    ;;
2824b0ead49Smrg
2834b0ead49Smrg  makeinfo)
2844b0ead49Smrg    echo 1>&2 "\
2854b0ead49SmrgWARNING: \`$1' is $msg.  You should only need it if
2864b0ead49Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2874b0ead49Smrg         indirectly affecting the aspect of the manual.  The spurious
2884b0ead49Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2894b0ead49Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2904b0ead49Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2914b0ead49Smrg    # The file to touch is that specified with -o ...
2924b0ead49Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2934b0ead49Smrg    if test -z "$file"; then
2944b0ead49Smrg      # ... or it is the one specified with @setfilename ...
2954b0ead49Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2964b0ead49Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
2974b0ead49Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
2984b0ead49Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
2994b0ead49Smrg    fi
3004b0ead49Smrg    # If the file does not exist, the user really needs makeinfo;
3014b0ead49Smrg    # let's fail without touching anything.
3024b0ead49Smrg    test -f $file || exit 1
3034b0ead49Smrg    touch $file
3044b0ead49Smrg    ;;
3054b0ead49Smrg
3064b0ead49Smrg  tar)
3074b0ead49Smrg    shift
3084b0ead49Smrg
3094b0ead49Smrg    # We have already tried tar in the generic part.
3104b0ead49Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3114b0ead49Smrg    # messages.
3124b0ead49Smrg    if (gnutar --version > /dev/null 2>&1); then
3134b0ead49Smrg       gnutar "$@" && exit 0
3144b0ead49Smrg    fi
3154b0ead49Smrg    if (gtar --version > /dev/null 2>&1); then
3164b0ead49Smrg       gtar "$@" && exit 0
3174b0ead49Smrg    fi
3184b0ead49Smrg    firstarg="$1"
3194b0ead49Smrg    if shift; then
3204b0ead49Smrg	case "$firstarg" in
3214b0ead49Smrg	*o*)
3224b0ead49Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3234b0ead49Smrg	    tar "$firstarg" "$@" && exit 0
3244b0ead49Smrg	    ;;
3254b0ead49Smrg	esac
3264b0ead49Smrg	case "$firstarg" in
3274b0ead49Smrg	*h*)
3284b0ead49Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3294b0ead49Smrg	    tar "$firstarg" "$@" && exit 0
3304b0ead49Smrg	    ;;
3314b0ead49Smrg	esac
3324b0ead49Smrg    fi
3334b0ead49Smrg
3344b0ead49Smrg    echo 1>&2 "\
3354b0ead49SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3364b0ead49Smrg         You may want to install GNU tar or Free paxutils, or check the
3374b0ead49Smrg         command line arguments."
3384b0ead49Smrg    exit 1
3394b0ead49Smrg    ;;
3404b0ead49Smrg
3414b0ead49Smrg  *)
3424b0ead49Smrg    echo 1>&2 "\
3434b0ead49SmrgWARNING: \`$1' is needed, and is $msg.
3444b0ead49Smrg         You might have modified some files without having the
3454b0ead49Smrg         proper tools for further handling them.  Check the \`README' file,
3464b0ead49Smrg         it often tells you about the needed prerequisites for installing
3474b0ead49Smrg         this package.  You may also peek at any GNU archive site, in case
3484b0ead49Smrg         some other package would contain this missing \`$1' program."
3494b0ead49Smrg    exit 1
3504b0ead49Smrg    ;;
3514b0ead49Smrgesac
3524b0ead49Smrg
3534b0ead49Smrgexit 0
3544b0ead49Smrg
3554b0ead49Smrg# Local variables:
3564b0ead49Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3574b0ead49Smrg# time-stamp-start: "scriptversion="
3584b0ead49Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3594b0ead49Smrg# time-stamp-end: "$"
3604b0ead49Smrg# End:
361