missing revision 7706df26
17706df26Smrg#! /bin/sh
27706df26Smrg# Common stub for a few missing GNU programs while installing.
37706df26Smrg
47706df26Smrgscriptversion=2005-06-08.21
57706df26Smrg
67706df26Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
77706df26Smrg#   Free Software Foundation, Inc.
87706df26Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
97706df26Smrg
107706df26Smrg# This program is free software; you can redistribute it and/or modify
117706df26Smrg# it under the terms of the GNU General Public License as published by
127706df26Smrg# the Free Software Foundation; either version 2, or (at your option)
137706df26Smrg# any later version.
147706df26Smrg
157706df26Smrg# This program is distributed in the hope that it will be useful,
167706df26Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
177706df26Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
187706df26Smrg# GNU General Public License for more details.
197706df26Smrg
207706df26Smrg# You should have received a copy of the GNU General Public License
217706df26Smrg# along with this program; if not, write to the Free Software
227706df26Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
237706df26Smrg# 02110-1301, USA.
247706df26Smrg
257706df26Smrg# As a special exception to the GNU General Public License, if you
267706df26Smrg# distribute this file as part of a program that contains a
277706df26Smrg# configuration script generated by Autoconf, you may include it under
287706df26Smrg# the same distribution terms that you use for the rest of that program.
297706df26Smrg
307706df26Smrgif test $# -eq 0; then
317706df26Smrg  echo 1>&2 "Try \`$0 --help' for more information"
327706df26Smrg  exit 1
337706df26Smrgfi
347706df26Smrg
357706df26Smrgrun=:
367706df26Smrg
377706df26Smrg# In the cases where this matters, `missing' is being run in the
387706df26Smrg# srcdir already.
397706df26Smrgif test -f configure.ac; then
407706df26Smrg  configure_ac=configure.ac
417706df26Smrgelse
427706df26Smrg  configure_ac=configure.in
437706df26Smrgfi
447706df26Smrg
457706df26Smrgmsg="missing on your system"
467706df26Smrg
477706df26Smrgcase "$1" in
487706df26Smrg--run)
497706df26Smrg  # Try to run requested program, and just exit if it succeeds.
507706df26Smrg  run=
517706df26Smrg  shift
527706df26Smrg  "$@" && exit 0
537706df26Smrg  # Exit code 63 means version mismatch.  This often happens
547706df26Smrg  # when the user try to use an ancient version of a tool on
557706df26Smrg  # a file that requires a minimum version.  In this case we
567706df26Smrg  # we should proceed has if the program had been absent, or
577706df26Smrg  # if --run hadn't been passed.
587706df26Smrg  if test $? = 63; then
597706df26Smrg    run=:
607706df26Smrg    msg="probably too old"
617706df26Smrg  fi
627706df26Smrg  ;;
637706df26Smrg
647706df26Smrg  -h|--h|--he|--hel|--help)
657706df26Smrg    echo "\
667706df26Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
677706df26Smrg
687706df26SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
697706df26Smrgerror status if there is no known handling for PROGRAM.
707706df26Smrg
717706df26SmrgOptions:
727706df26Smrg  -h, --help      display this help and exit
737706df26Smrg  -v, --version   output version information and exit
747706df26Smrg  --run           try to run the given command, and emulate it if it fails
757706df26Smrg
767706df26SmrgSupported PROGRAM values:
777706df26Smrg  aclocal      touch file \`aclocal.m4'
787706df26Smrg  autoconf     touch file \`configure'
797706df26Smrg  autoheader   touch file \`config.h.in'
807706df26Smrg  automake     touch all \`Makefile.in' files
817706df26Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
827706df26Smrg  flex         create \`lex.yy.c', if possible, from existing .c
837706df26Smrg  help2man     touch the output file
847706df26Smrg  lex          create \`lex.yy.c', if possible, from existing .c
857706df26Smrg  makeinfo     touch the output file
867706df26Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
877706df26Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
887706df26Smrg
897706df26SmrgSend bug reports to <bug-automake@gnu.org>."
907706df26Smrg    exit $?
917706df26Smrg    ;;
927706df26Smrg
937706df26Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
947706df26Smrg    echo "missing $scriptversion (GNU Automake)"
957706df26Smrg    exit $?
967706df26Smrg    ;;
977706df26Smrg
987706df26Smrg  -*)
997706df26Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1007706df26Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1017706df26Smrg    exit 1
1027706df26Smrg    ;;
1037706df26Smrg
1047706df26Smrgesac
1057706df26Smrg
1067706df26Smrg# Now exit if we have it, but it failed.  Also exit now if we
1077706df26Smrg# don't have it and --version was passed (most likely to detect
1087706df26Smrg# the program).
1097706df26Smrgcase "$1" in
1107706df26Smrg  lex|yacc)
1117706df26Smrg    # Not GNU programs, they don't have --version.
1127706df26Smrg    ;;
1137706df26Smrg
1147706df26Smrg  tar)
1157706df26Smrg    if test -n "$run"; then
1167706df26Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1177706df26Smrg       exit 1
1187706df26Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1197706df26Smrg       exit 1
1207706df26Smrg    fi
1217706df26Smrg    ;;
1227706df26Smrg
1237706df26Smrg  *)
1247706df26Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1257706df26Smrg       # We have it, but it failed.
1267706df26Smrg       exit 1
1277706df26Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1287706df26Smrg       # Could not run --version or --help.  This is probably someone
1297706df26Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1307706df26Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1317706df26Smrg       exit 1
1327706df26Smrg    fi
1337706df26Smrg    ;;
1347706df26Smrgesac
1357706df26Smrg
1367706df26Smrg# If it does not exist, or fails to run (possibly an outdated version),
1377706df26Smrg# try to emulate it.
1387706df26Smrgcase "$1" in
1397706df26Smrg  aclocal*)
1407706df26Smrg    echo 1>&2 "\
1417706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
1427706df26Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1437706df26Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1447706df26Smrg         any GNU archive site."
1457706df26Smrg    touch aclocal.m4
1467706df26Smrg    ;;
1477706df26Smrg
1487706df26Smrg  autoconf)
1497706df26Smrg    echo 1>&2 "\
1507706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
1517706df26Smrg         you modified \`${configure_ac}'.  You might want to install the
1527706df26Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1537706df26Smrg         archive site."
1547706df26Smrg    touch configure
1557706df26Smrg    ;;
1567706df26Smrg
1577706df26Smrg  autoheader)
1587706df26Smrg    echo 1>&2 "\
1597706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
1607706df26Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1617706df26Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1627706df26Smrg         from any GNU archive site."
1637706df26Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1647706df26Smrg    test -z "$files" && files="config.h"
1657706df26Smrg    touch_files=
1667706df26Smrg    for f in $files; do
1677706df26Smrg      case "$f" in
1687706df26Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1697706df26Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1707706df26Smrg      *) touch_files="$touch_files $f.in";;
1717706df26Smrg      esac
1727706df26Smrg    done
1737706df26Smrg    touch $touch_files
1747706df26Smrg    ;;
1757706df26Smrg
1767706df26Smrg  automake*)
1777706df26Smrg    echo 1>&2 "\
1787706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
1797706df26Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1807706df26Smrg         You might want to install the \`Automake' and \`Perl' packages.
1817706df26Smrg         Grab them from any GNU archive site."
1827706df26Smrg    find . -type f -name Makefile.am -print |
1837706df26Smrg	   sed 's/\.am$/.in/' |
1847706df26Smrg	   while read f; do touch "$f"; done
1857706df26Smrg    ;;
1867706df26Smrg
1877706df26Smrg  autom4te)
1887706df26Smrg    echo 1>&2 "\
1897706df26SmrgWARNING: \`$1' is needed, but is $msg.
1907706df26Smrg         You might have modified some files without having the
1917706df26Smrg         proper tools for further handling them.
1927706df26Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1937706df26Smrg         archive site."
1947706df26Smrg
1957706df26Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
1967706df26Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
1977706df26Smrg    if test -f "$file"; then
1987706df26Smrg	touch $file
1997706df26Smrg    else
2007706df26Smrg	test -z "$file" || exec >$file
2017706df26Smrg	echo "#! /bin/sh"
2027706df26Smrg	echo "# Created by GNU Automake missing as a replacement of"
2037706df26Smrg	echo "#  $ $@"
2047706df26Smrg	echo "exit 0"
2057706df26Smrg	chmod +x $file
2067706df26Smrg	exit 1
2077706df26Smrg    fi
2087706df26Smrg    ;;
2097706df26Smrg
2107706df26Smrg  bison|yacc)
2117706df26Smrg    echo 1>&2 "\
2127706df26SmrgWARNING: \`$1' $msg.  You should only need it if
2137706df26Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2147706df26Smrg         in order for those modifications to take effect.  You can get
2157706df26Smrg         \`Bison' from any GNU archive site."
2167706df26Smrg    rm -f y.tab.c y.tab.h
2177706df26Smrg    if [ $# -ne 1 ]; then
2187706df26Smrg        eval LASTARG="\${$#}"
2197706df26Smrg	case "$LASTARG" in
2207706df26Smrg	*.y)
2217706df26Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2227706df26Smrg	    if [ -f "$SRCFILE" ]; then
2237706df26Smrg	         cp "$SRCFILE" y.tab.c
2247706df26Smrg	    fi
2257706df26Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2267706df26Smrg	    if [ -f "$SRCFILE" ]; then
2277706df26Smrg	         cp "$SRCFILE" y.tab.h
2287706df26Smrg	    fi
2297706df26Smrg	  ;;
2307706df26Smrg	esac
2317706df26Smrg    fi
2327706df26Smrg    if [ ! -f y.tab.h ]; then
2337706df26Smrg	echo >y.tab.h
2347706df26Smrg    fi
2357706df26Smrg    if [ ! -f y.tab.c ]; then
2367706df26Smrg	echo 'main() { return 0; }' >y.tab.c
2377706df26Smrg    fi
2387706df26Smrg    ;;
2397706df26Smrg
2407706df26Smrg  lex|flex)
2417706df26Smrg    echo 1>&2 "\
2427706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
2437706df26Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2447706df26Smrg         in order for those modifications to take effect.  You can get
2457706df26Smrg         \`Flex' from any GNU archive site."
2467706df26Smrg    rm -f lex.yy.c
2477706df26Smrg    if [ $# -ne 1 ]; then
2487706df26Smrg        eval LASTARG="\${$#}"
2497706df26Smrg	case "$LASTARG" in
2507706df26Smrg	*.l)
2517706df26Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2527706df26Smrg	    if [ -f "$SRCFILE" ]; then
2537706df26Smrg	         cp "$SRCFILE" lex.yy.c
2547706df26Smrg	    fi
2557706df26Smrg	  ;;
2567706df26Smrg	esac
2577706df26Smrg    fi
2587706df26Smrg    if [ ! -f lex.yy.c ]; then
2597706df26Smrg	echo 'main() { return 0; }' >lex.yy.c
2607706df26Smrg    fi
2617706df26Smrg    ;;
2627706df26Smrg
2637706df26Smrg  help2man)
2647706df26Smrg    echo 1>&2 "\
2657706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
2667706df26Smrg	 you modified a dependency of a manual page.  You may need the
2677706df26Smrg	 \`Help2man' package in order for those modifications to take
2687706df26Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2697706df26Smrg
2707706df26Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2717706df26Smrg    if test -z "$file"; then
2727706df26Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2737706df26Smrg    fi
2747706df26Smrg    if [ -f "$file" ]; then
2757706df26Smrg	touch $file
2767706df26Smrg    else
2777706df26Smrg	test -z "$file" || exec >$file
2787706df26Smrg	echo ".ab help2man is required to generate this page"
2797706df26Smrg	exit 1
2807706df26Smrg    fi
2817706df26Smrg    ;;
2827706df26Smrg
2837706df26Smrg  makeinfo)
2847706df26Smrg    echo 1>&2 "\
2857706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
2867706df26Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2877706df26Smrg         indirectly affecting the aspect of the manual.  The spurious
2887706df26Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2897706df26Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2907706df26Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2917706df26Smrg    # The file to touch is that specified with -o ...
2927706df26Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2937706df26Smrg    if test -z "$file"; then
2947706df26Smrg      # ... or it is the one specified with @setfilename ...
2957706df26Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2967706df26Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
2977706df26Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
2987706df26Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
2997706df26Smrg    fi
3007706df26Smrg    # If the file does not exist, the user really needs makeinfo;
3017706df26Smrg    # let's fail without touching anything.
3027706df26Smrg    test -f $file || exit 1
3037706df26Smrg    touch $file
3047706df26Smrg    ;;
3057706df26Smrg
3067706df26Smrg  tar)
3077706df26Smrg    shift
3087706df26Smrg
3097706df26Smrg    # We have already tried tar in the generic part.
3107706df26Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3117706df26Smrg    # messages.
3127706df26Smrg    if (gnutar --version > /dev/null 2>&1); then
3137706df26Smrg       gnutar "$@" && exit 0
3147706df26Smrg    fi
3157706df26Smrg    if (gtar --version > /dev/null 2>&1); then
3167706df26Smrg       gtar "$@" && exit 0
3177706df26Smrg    fi
3187706df26Smrg    firstarg="$1"
3197706df26Smrg    if shift; then
3207706df26Smrg	case "$firstarg" in
3217706df26Smrg	*o*)
3227706df26Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3237706df26Smrg	    tar "$firstarg" "$@" && exit 0
3247706df26Smrg	    ;;
3257706df26Smrg	esac
3267706df26Smrg	case "$firstarg" in
3277706df26Smrg	*h*)
3287706df26Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3297706df26Smrg	    tar "$firstarg" "$@" && exit 0
3307706df26Smrg	    ;;
3317706df26Smrg	esac
3327706df26Smrg    fi
3337706df26Smrg
3347706df26Smrg    echo 1>&2 "\
3357706df26SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3367706df26Smrg         You may want to install GNU tar or Free paxutils, or check the
3377706df26Smrg         command line arguments."
3387706df26Smrg    exit 1
3397706df26Smrg    ;;
3407706df26Smrg
3417706df26Smrg  *)
3427706df26Smrg    echo 1>&2 "\
3437706df26SmrgWARNING: \`$1' is needed, and is $msg.
3447706df26Smrg         You might have modified some files without having the
3457706df26Smrg         proper tools for further handling them.  Check the \`README' file,
3467706df26Smrg         it often tells you about the needed prerequisites for installing
3477706df26Smrg         this package.  You may also peek at any GNU archive site, in case
3487706df26Smrg         some other package would contain this missing \`$1' program."
3497706df26Smrg    exit 1
3507706df26Smrg    ;;
3517706df26Smrgesac
3527706df26Smrg
3537706df26Smrgexit 0
3547706df26Smrg
3557706df26Smrg# Local variables:
3567706df26Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3577706df26Smrg# time-stamp-start: "scriptversion="
3587706df26Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3597706df26Smrg# time-stamp-end: "$"
3607706df26Smrg# End:
361