missing revision ba85709e
11d54945dSmrg#! /bin/sh
21d54945dSmrg# Common stub for a few missing GNU programs while installing.
31d54945dSmrg
4ba85709eSmrgscriptversion=2006-05-10.23
51d54945dSmrg
6ba85709eSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
71d54945dSmrg#   Free Software Foundation, Inc.
81d54945dSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
91d54945dSmrg
101d54945dSmrg# This program is free software; you can redistribute it and/or modify
111d54945dSmrg# it under the terms of the GNU General Public License as published by
121d54945dSmrg# the Free Software Foundation; either version 2, or (at your option)
131d54945dSmrg# any later version.
141d54945dSmrg
151d54945dSmrg# This program is distributed in the hope that it will be useful,
161d54945dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
171d54945dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
181d54945dSmrg# GNU General Public License for more details.
191d54945dSmrg
201d54945dSmrg# You should have received a copy of the GNU General Public License
211d54945dSmrg# along with this program; if not, write to the Free Software
221d54945dSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
231d54945dSmrg# 02110-1301, USA.
241d54945dSmrg
251d54945dSmrg# As a special exception to the GNU General Public License, if you
261d54945dSmrg# distribute this file as part of a program that contains a
271d54945dSmrg# configuration script generated by Autoconf, you may include it under
281d54945dSmrg# the same distribution terms that you use for the rest of that program.
291d54945dSmrg
301d54945dSmrgif test $# -eq 0; then
311d54945dSmrg  echo 1>&2 "Try \`$0 --help' for more information"
321d54945dSmrg  exit 1
331d54945dSmrgfi
341d54945dSmrg
351d54945dSmrgrun=:
36ba85709eSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
37ba85709eSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
381d54945dSmrg
391d54945dSmrg# In the cases where this matters, `missing' is being run in the
401d54945dSmrg# srcdir already.
411d54945dSmrgif test -f configure.ac; then
421d54945dSmrg  configure_ac=configure.ac
431d54945dSmrgelse
441d54945dSmrg  configure_ac=configure.in
451d54945dSmrgfi
461d54945dSmrg
471d54945dSmrgmsg="missing on your system"
481d54945dSmrg
49ba85709eSmrgcase $1 in
501d54945dSmrg--run)
511d54945dSmrg  # Try to run requested program, and just exit if it succeeds.
521d54945dSmrg  run=
531d54945dSmrg  shift
541d54945dSmrg  "$@" && exit 0
551d54945dSmrg  # Exit code 63 means version mismatch.  This often happens
561d54945dSmrg  # when the user try to use an ancient version of a tool on
571d54945dSmrg  # a file that requires a minimum version.  In this case we
581d54945dSmrg  # we should proceed has if the program had been absent, or
591d54945dSmrg  # if --run hadn't been passed.
601d54945dSmrg  if test $? = 63; then
611d54945dSmrg    run=:
621d54945dSmrg    msg="probably too old"
631d54945dSmrg  fi
641d54945dSmrg  ;;
651d54945dSmrg
661d54945dSmrg  -h|--h|--he|--hel|--help)
671d54945dSmrg    echo "\
681d54945dSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
691d54945dSmrg
701d54945dSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
711d54945dSmrgerror status if there is no known handling for PROGRAM.
721d54945dSmrg
731d54945dSmrgOptions:
741d54945dSmrg  -h, --help      display this help and exit
751d54945dSmrg  -v, --version   output version information and exit
761d54945dSmrg  --run           try to run the given command, and emulate it if it fails
771d54945dSmrg
781d54945dSmrgSupported PROGRAM values:
791d54945dSmrg  aclocal      touch file \`aclocal.m4'
801d54945dSmrg  autoconf     touch file \`configure'
811d54945dSmrg  autoheader   touch file \`config.h.in'
82ba85709eSmrg  autom4te     touch the output file, or create a stub one
831d54945dSmrg  automake     touch all \`Makefile.in' files
841d54945dSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
851d54945dSmrg  flex         create \`lex.yy.c', if possible, from existing .c
861d54945dSmrg  help2man     touch the output file
871d54945dSmrg  lex          create \`lex.yy.c', if possible, from existing .c
881d54945dSmrg  makeinfo     touch the output file
891d54945dSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
901d54945dSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
911d54945dSmrg
921d54945dSmrgSend bug reports to <bug-automake@gnu.org>."
931d54945dSmrg    exit $?
941d54945dSmrg    ;;
951d54945dSmrg
961d54945dSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
971d54945dSmrg    echo "missing $scriptversion (GNU Automake)"
981d54945dSmrg    exit $?
991d54945dSmrg    ;;
1001d54945dSmrg
1011d54945dSmrg  -*)
1021d54945dSmrg    echo 1>&2 "$0: Unknown \`$1' option"
1031d54945dSmrg    echo 1>&2 "Try \`$0 --help' for more information"
1041d54945dSmrg    exit 1
1051d54945dSmrg    ;;
1061d54945dSmrg
1071d54945dSmrgesac
1081d54945dSmrg
1091d54945dSmrg# Now exit if we have it, but it failed.  Also exit now if we
1101d54945dSmrg# don't have it and --version was passed (most likely to detect
1111d54945dSmrg# the program).
112ba85709eSmrgcase $1 in
1131d54945dSmrg  lex|yacc)
1141d54945dSmrg    # Not GNU programs, they don't have --version.
1151d54945dSmrg    ;;
1161d54945dSmrg
1171d54945dSmrg  tar)
1181d54945dSmrg    if test -n "$run"; then
1191d54945dSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
1201d54945dSmrg       exit 1
1211d54945dSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1221d54945dSmrg       exit 1
1231d54945dSmrg    fi
1241d54945dSmrg    ;;
1251d54945dSmrg
1261d54945dSmrg  *)
1271d54945dSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1281d54945dSmrg       # We have it, but it failed.
1291d54945dSmrg       exit 1
1301d54945dSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1311d54945dSmrg       # Could not run --version or --help.  This is probably someone
1321d54945dSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1331d54945dSmrg       # $TOOL exists and not knowing $TOOL uses missing.
1341d54945dSmrg       exit 1
1351d54945dSmrg    fi
1361d54945dSmrg    ;;
1371d54945dSmrgesac
1381d54945dSmrg
1391d54945dSmrg# If it does not exist, or fails to run (possibly an outdated version),
1401d54945dSmrg# try to emulate it.
141ba85709eSmrgcase $1 in
1421d54945dSmrg  aclocal*)
1431d54945dSmrg    echo 1>&2 "\
1441d54945dSmrgWARNING: \`$1' is $msg.  You should only need it if
1451d54945dSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1461d54945dSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1471d54945dSmrg         any GNU archive site."
1481d54945dSmrg    touch aclocal.m4
1491d54945dSmrg    ;;
1501d54945dSmrg
1511d54945dSmrg  autoconf)
1521d54945dSmrg    echo 1>&2 "\
1531d54945dSmrgWARNING: \`$1' is $msg.  You should only need it if
1541d54945dSmrg         you modified \`${configure_ac}'.  You might want to install the
1551d54945dSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1561d54945dSmrg         archive site."
1571d54945dSmrg    touch configure
1581d54945dSmrg    ;;
1591d54945dSmrg
1601d54945dSmrg  autoheader)
1611d54945dSmrg    echo 1>&2 "\
1621d54945dSmrgWARNING: \`$1' is $msg.  You should only need it if
1631d54945dSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1641d54945dSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1651d54945dSmrg         from any GNU archive site."
1661d54945dSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1671d54945dSmrg    test -z "$files" && files="config.h"
1681d54945dSmrg    touch_files=
1691d54945dSmrg    for f in $files; do
170ba85709eSmrg      case $f in
1711d54945dSmrg      *:*) touch_files="$touch_files "`echo "$f" |
1721d54945dSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1731d54945dSmrg      *) touch_files="$touch_files $f.in";;
1741d54945dSmrg      esac
1751d54945dSmrg    done
1761d54945dSmrg    touch $touch_files
1771d54945dSmrg    ;;
1781d54945dSmrg
1791d54945dSmrg  automake*)
1801d54945dSmrg    echo 1>&2 "\
1811d54945dSmrgWARNING: \`$1' is $msg.  You should only need it if
1821d54945dSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1831d54945dSmrg         You might want to install the \`Automake' and \`Perl' packages.
1841d54945dSmrg         Grab them from any GNU archive site."
1851d54945dSmrg    find . -type f -name Makefile.am -print |
1861d54945dSmrg	   sed 's/\.am$/.in/' |
1871d54945dSmrg	   while read f; do touch "$f"; done
1881d54945dSmrg    ;;
1891d54945dSmrg
1901d54945dSmrg  autom4te)
1911d54945dSmrg    echo 1>&2 "\
1921d54945dSmrgWARNING: \`$1' is needed, but is $msg.
1931d54945dSmrg         You might have modified some files without having the
1941d54945dSmrg         proper tools for further handling them.
1951d54945dSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
1961d54945dSmrg         archive site."
1971d54945dSmrg
198ba85709eSmrg    file=`echo "$*" | sed -n "$sed_output"`
199ba85709eSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2001d54945dSmrg    if test -f "$file"; then
2011d54945dSmrg	touch $file
2021d54945dSmrg    else
2031d54945dSmrg	test -z "$file" || exec >$file
2041d54945dSmrg	echo "#! /bin/sh"
2051d54945dSmrg	echo "# Created by GNU Automake missing as a replacement of"
2061d54945dSmrg	echo "#  $ $@"
2071d54945dSmrg	echo "exit 0"
2081d54945dSmrg	chmod +x $file
2091d54945dSmrg	exit 1
2101d54945dSmrg    fi
2111d54945dSmrg    ;;
2121d54945dSmrg
2131d54945dSmrg  bison|yacc)
2141d54945dSmrg    echo 1>&2 "\
2151d54945dSmrgWARNING: \`$1' $msg.  You should only need it if
2161d54945dSmrg         you modified a \`.y' file.  You may need the \`Bison' package
2171d54945dSmrg         in order for those modifications to take effect.  You can get
2181d54945dSmrg         \`Bison' from any GNU archive site."
2191d54945dSmrg    rm -f y.tab.c y.tab.h
220ba85709eSmrg    if test $# -ne 1; then
2211d54945dSmrg        eval LASTARG="\${$#}"
222ba85709eSmrg	case $LASTARG in
2231d54945dSmrg	*.y)
2241d54945dSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
225ba85709eSmrg	    if test -f "$SRCFILE"; then
2261d54945dSmrg	         cp "$SRCFILE" y.tab.c
2271d54945dSmrg	    fi
2281d54945dSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
229ba85709eSmrg	    if test -f "$SRCFILE"; then
2301d54945dSmrg	         cp "$SRCFILE" y.tab.h
2311d54945dSmrg	    fi
2321d54945dSmrg	  ;;
2331d54945dSmrg	esac
2341d54945dSmrg    fi
235ba85709eSmrg    if test ! -f y.tab.h; then
2361d54945dSmrg	echo >y.tab.h
2371d54945dSmrg    fi
238ba85709eSmrg    if test ! -f y.tab.c; then
2391d54945dSmrg	echo 'main() { return 0; }' >y.tab.c
2401d54945dSmrg    fi
2411d54945dSmrg    ;;
2421d54945dSmrg
2431d54945dSmrg  lex|flex)
2441d54945dSmrg    echo 1>&2 "\
2451d54945dSmrgWARNING: \`$1' is $msg.  You should only need it if
2461d54945dSmrg         you modified a \`.l' file.  You may need the \`Flex' package
2471d54945dSmrg         in order for those modifications to take effect.  You can get
2481d54945dSmrg         \`Flex' from any GNU archive site."
2491d54945dSmrg    rm -f lex.yy.c
250ba85709eSmrg    if test $# -ne 1; then
2511d54945dSmrg        eval LASTARG="\${$#}"
252ba85709eSmrg	case $LASTARG in
2531d54945dSmrg	*.l)
2541d54945dSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
255ba85709eSmrg	    if test -f "$SRCFILE"; then
2561d54945dSmrg	         cp "$SRCFILE" lex.yy.c
2571d54945dSmrg	    fi
2581d54945dSmrg	  ;;
2591d54945dSmrg	esac
2601d54945dSmrg    fi
261ba85709eSmrg    if test ! -f lex.yy.c; then
2621d54945dSmrg	echo 'main() { return 0; }' >lex.yy.c
2631d54945dSmrg    fi
2641d54945dSmrg    ;;
2651d54945dSmrg
2661d54945dSmrg  help2man)
2671d54945dSmrg    echo 1>&2 "\
2681d54945dSmrgWARNING: \`$1' is $msg.  You should only need it if
2691d54945dSmrg	 you modified a dependency of a manual page.  You may need the
2701d54945dSmrg	 \`Help2man' package in order for those modifications to take
2711d54945dSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
2721d54945dSmrg
273ba85709eSmrg    file=`echo "$*" | sed -n "$sed_output"`
274ba85709eSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
275ba85709eSmrg    if test -f "$file"; then
2761d54945dSmrg	touch $file
2771d54945dSmrg    else
2781d54945dSmrg	test -z "$file" || exec >$file
2791d54945dSmrg	echo ".ab help2man is required to generate this page"
2801d54945dSmrg	exit 1
2811d54945dSmrg    fi
2821d54945dSmrg    ;;
2831d54945dSmrg
2841d54945dSmrg  makeinfo)
2851d54945dSmrg    echo 1>&2 "\
2861d54945dSmrgWARNING: \`$1' is $msg.  You should only need it if
2871d54945dSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2881d54945dSmrg         indirectly affecting the aspect of the manual.  The spurious
2891d54945dSmrg         call might also be the consequence of using a buggy \`make' (AIX,
2901d54945dSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2911d54945dSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
2921d54945dSmrg    # The file to touch is that specified with -o ...
293ba85709eSmrg    file=`echo "$*" | sed -n "$sed_output"`
294ba85709eSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2951d54945dSmrg    if test -z "$file"; then
2961d54945dSmrg      # ... or it is the one specified with @setfilename ...
2971d54945dSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
298ba85709eSmrg      file=`sed -n '
299ba85709eSmrg	/^@setfilename/{
300ba85709eSmrg	  s/.* \([^ ]*\) *$/\1/
301ba85709eSmrg	  p
302ba85709eSmrg	  q
303ba85709eSmrg	}' $infile`
3041d54945dSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3051d54945dSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3061d54945dSmrg    fi
3071d54945dSmrg    # If the file does not exist, the user really needs makeinfo;
3081d54945dSmrg    # let's fail without touching anything.
3091d54945dSmrg    test -f $file || exit 1
3101d54945dSmrg    touch $file
3111d54945dSmrg    ;;
3121d54945dSmrg
3131d54945dSmrg  tar)
3141d54945dSmrg    shift
3151d54945dSmrg
3161d54945dSmrg    # We have already tried tar in the generic part.
3171d54945dSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
3181d54945dSmrg    # messages.
3191d54945dSmrg    if (gnutar --version > /dev/null 2>&1); then
3201d54945dSmrg       gnutar "$@" && exit 0
3211d54945dSmrg    fi
3221d54945dSmrg    if (gtar --version > /dev/null 2>&1); then
3231d54945dSmrg       gtar "$@" && exit 0
3241d54945dSmrg    fi
3251d54945dSmrg    firstarg="$1"
3261d54945dSmrg    if shift; then
327ba85709eSmrg	case $firstarg in
3281d54945dSmrg	*o*)
3291d54945dSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
3301d54945dSmrg	    tar "$firstarg" "$@" && exit 0
3311d54945dSmrg	    ;;
3321d54945dSmrg	esac
333ba85709eSmrg	case $firstarg in
3341d54945dSmrg	*h*)
3351d54945dSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
3361d54945dSmrg	    tar "$firstarg" "$@" && exit 0
3371d54945dSmrg	    ;;
3381d54945dSmrg	esac
3391d54945dSmrg    fi
3401d54945dSmrg
3411d54945dSmrg    echo 1>&2 "\
3421d54945dSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3431d54945dSmrg         You may want to install GNU tar or Free paxutils, or check the
3441d54945dSmrg         command line arguments."
3451d54945dSmrg    exit 1
3461d54945dSmrg    ;;
3471d54945dSmrg
3481d54945dSmrg  *)
3491d54945dSmrg    echo 1>&2 "\
3501d54945dSmrgWARNING: \`$1' is needed, and is $msg.
3511d54945dSmrg         You might have modified some files without having the
3521d54945dSmrg         proper tools for further handling them.  Check the \`README' file,
3531d54945dSmrg         it often tells you about the needed prerequisites for installing
3541d54945dSmrg         this package.  You may also peek at any GNU archive site, in case
3551d54945dSmrg         some other package would contain this missing \`$1' program."
3561d54945dSmrg    exit 1
3571d54945dSmrg    ;;
3581d54945dSmrgesac
3591d54945dSmrg
3601d54945dSmrgexit 0
3611d54945dSmrg
3621d54945dSmrg# Local variables:
3631d54945dSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3641d54945dSmrg# time-stamp-start: "scriptversion="
3651d54945dSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3661d54945dSmrg# time-stamp-end: "$"
3671d54945dSmrg# End:
368