missing revision 9bc46bd4
13294c433Smrg#! /bin/sh
23294c433Smrg# Common stub for a few missing GNU programs while installing.
39bc46bd4Smrg
49bc46bd4Smrgscriptversion=2009-04-28.21; # UTC
59bc46bd4Smrg
69bc46bd4Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
79bc46bd4Smrg# 2008, 2009 Free Software Foundation, Inc.
83294c433Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
93294c433Smrg
103294c433Smrg# This program is free software; you can redistribute it and/or modify
113294c433Smrg# it under the terms of the GNU General Public License as published by
123294c433Smrg# the Free Software Foundation; either version 2, or (at your option)
133294c433Smrg# any later version.
143294c433Smrg
153294c433Smrg# This program is distributed in the hope that it will be useful,
163294c433Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
173294c433Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
183294c433Smrg# GNU General Public License for more details.
193294c433Smrg
203294c433Smrg# You should have received a copy of the GNU General Public License
219bc46bd4Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
223294c433Smrg
233294c433Smrg# As a special exception to the GNU General Public License, if you
243294c433Smrg# distribute this file as part of a program that contains a
253294c433Smrg# configuration script generated by Autoconf, you may include it under
263294c433Smrg# the same distribution terms that you use for the rest of that program.
273294c433Smrg
283294c433Smrgif test $# -eq 0; then
293294c433Smrg  echo 1>&2 "Try \`$0 --help' for more information"
303294c433Smrg  exit 1
313294c433Smrgfi
323294c433Smrg
333294c433Smrgrun=:
349bc46bd4Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
359bc46bd4Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
363294c433Smrg
373294c433Smrg# In the cases where this matters, `missing' is being run in the
383294c433Smrg# srcdir already.
393294c433Smrgif test -f configure.ac; then
403294c433Smrg  configure_ac=configure.ac
413294c433Smrgelse
423294c433Smrg  configure_ac=configure.in
433294c433Smrgfi
443294c433Smrg
459bc46bd4Smrgmsg="missing on your system"
469bc46bd4Smrg
479bc46bd4Smrgcase $1 in
483294c433Smrg--run)
493294c433Smrg  # Try to run requested program, and just exit if it succeeds.
503294c433Smrg  run=
513294c433Smrg  shift
523294c433Smrg  "$@" && exit 0
539bc46bd4Smrg  # Exit code 63 means version mismatch.  This often happens
549bc46bd4Smrg  # when the user try to use an ancient version of a tool on
559bc46bd4Smrg  # a file that requires a minimum version.  In this case we
569bc46bd4Smrg  # we should proceed has if the program had been absent, or
579bc46bd4Smrg  # if --run hadn't been passed.
589bc46bd4Smrg  if test $? = 63; then
599bc46bd4Smrg    run=:
609bc46bd4Smrg    msg="probably too old"
619bc46bd4Smrg  fi
623294c433Smrg  ;;
633294c433Smrg
643294c433Smrg  -h|--h|--he|--hel|--help)
653294c433Smrg    echo "\
663294c433Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
673294c433Smrg
683294c433SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
693294c433Smrgerror status if there is no known handling for PROGRAM.
703294c433Smrg
713294c433SmrgOptions:
723294c433Smrg  -h, --help      display this help and exit
733294c433Smrg  -v, --version   output version information and exit
743294c433Smrg  --run           try to run the given command, and emulate it if it fails
753294c433Smrg
763294c433SmrgSupported PROGRAM values:
773294c433Smrg  aclocal      touch file \`aclocal.m4'
783294c433Smrg  autoconf     touch file \`configure'
793294c433Smrg  autoheader   touch file \`config.h.in'
809bc46bd4Smrg  autom4te     touch the output file, or create a stub one
813294c433Smrg  automake     touch all \`Makefile.in' files
823294c433Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
833294c433Smrg  flex         create \`lex.yy.c', if possible, from existing .c
843294c433Smrg  help2man     touch the output file
853294c433Smrg  lex          create \`lex.yy.c', if possible, from existing .c
863294c433Smrg  makeinfo     touch the output file
873294c433Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
889bc46bd4Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
899bc46bd4Smrg
909bc46bd4SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
919bc46bd4Smrg\`g' are ignored when checking the name.
929bc46bd4Smrg
939bc46bd4SmrgSend bug reports to <bug-automake@gnu.org>."
949bc46bd4Smrg    exit $?
953294c433Smrg    ;;
963294c433Smrg
973294c433Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
989bc46bd4Smrg    echo "missing $scriptversion (GNU Automake)"
999bc46bd4Smrg    exit $?
1003294c433Smrg    ;;
1013294c433Smrg
1023294c433Smrg  -*)
1033294c433Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1043294c433Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1053294c433Smrg    exit 1
1063294c433Smrg    ;;
1073294c433Smrg
1089bc46bd4Smrgesac
1099bc46bd4Smrg
1109bc46bd4Smrg# normalize program name to check for.
1119bc46bd4Smrgprogram=`echo "$1" | sed '
1129bc46bd4Smrg  s/^gnu-//; t
1139bc46bd4Smrg  s/^gnu//; t
1149bc46bd4Smrg  s/^g//; t'`
1159bc46bd4Smrg
1169bc46bd4Smrg# Now exit if we have it, but it failed.  Also exit now if we
1179bc46bd4Smrg# don't have it and --version was passed (most likely to detect
1189bc46bd4Smrg# the program).  This is about non-GNU programs, so use $1 not
1199bc46bd4Smrg# $program.
1209bc46bd4Smrgcase $1 in
1219bc46bd4Smrg  lex*|yacc*)
1229bc46bd4Smrg    # Not GNU programs, they don't have --version.
1239bc46bd4Smrg    ;;
1249bc46bd4Smrg
1259bc46bd4Smrg  tar*)
1269bc46bd4Smrg    if test -n "$run"; then
1279bc46bd4Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1289bc46bd4Smrg       exit 1
1299bc46bd4Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1309bc46bd4Smrg       exit 1
1319bc46bd4Smrg    fi
1329bc46bd4Smrg    ;;
1339bc46bd4Smrg
1349bc46bd4Smrg  *)
1353294c433Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1363294c433Smrg       # We have it, but it failed.
1373294c433Smrg       exit 1
1389bc46bd4Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1399bc46bd4Smrg       # Could not run --version or --help.  This is probably someone
1409bc46bd4Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1419bc46bd4Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1429bc46bd4Smrg       exit 1
1433294c433Smrg    fi
1449bc46bd4Smrg    ;;
1459bc46bd4Smrgesac
1463294c433Smrg
1479bc46bd4Smrg# If it does not exist, or fails to run (possibly an outdated version),
1489bc46bd4Smrg# try to emulate it.
1499bc46bd4Smrgcase $program in
1509bc46bd4Smrg  aclocal*)
1513294c433Smrg    echo 1>&2 "\
1529bc46bd4SmrgWARNING: \`$1' is $msg.  You should only need it if
1533294c433Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1543294c433Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1553294c433Smrg         any GNU archive site."
1563294c433Smrg    touch aclocal.m4
1573294c433Smrg    ;;
1583294c433Smrg
1599bc46bd4Smrg  autoconf*)
1603294c433Smrg    echo 1>&2 "\
1619bc46bd4SmrgWARNING: \`$1' is $msg.  You should only need it if
1623294c433Smrg         you modified \`${configure_ac}'.  You might want to install the
1633294c433Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1643294c433Smrg         archive site."
1653294c433Smrg    touch configure
1663294c433Smrg    ;;
1673294c433Smrg
1689bc46bd4Smrg  autoheader*)
1693294c433Smrg    echo 1>&2 "\
1709bc46bd4SmrgWARNING: \`$1' is $msg.  You should only need it if
1713294c433Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1723294c433Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1733294c433Smrg         from any GNU archive site."
1743294c433Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1753294c433Smrg    test -z "$files" && files="config.h"
1763294c433Smrg    touch_files=
1773294c433Smrg    for f in $files; do
1789bc46bd4Smrg      case $f in
1793294c433Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1803294c433Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1813294c433Smrg      *) touch_files="$touch_files $f.in";;
1823294c433Smrg      esac
1833294c433Smrg    done
1843294c433Smrg    touch $touch_files
1853294c433Smrg    ;;
1863294c433Smrg
1873294c433Smrg  automake*)
1883294c433Smrg    echo 1>&2 "\
1899bc46bd4SmrgWARNING: \`$1' is $msg.  You should only need it if
1903294c433Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1913294c433Smrg         You might want to install the \`Automake' and \`Perl' packages.
1923294c433Smrg         Grab them from any GNU archive site."
1933294c433Smrg    find . -type f -name Makefile.am -print |
1943294c433Smrg	   sed 's/\.am$/.in/' |
1953294c433Smrg	   while read f; do touch "$f"; done
1963294c433Smrg    ;;
1973294c433Smrg
1989bc46bd4Smrg  autom4te*)
1993294c433Smrg    echo 1>&2 "\
2009bc46bd4SmrgWARNING: \`$1' is needed, but is $msg.
2019bc46bd4Smrg         You might have modified some files without having the
2023294c433Smrg         proper tools for further handling them.
2033294c433Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
2043294c433Smrg         archive site."
2053294c433Smrg
2069bc46bd4Smrg    file=`echo "$*" | sed -n "$sed_output"`
2079bc46bd4Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2083294c433Smrg    if test -f "$file"; then
2093294c433Smrg	touch $file
2103294c433Smrg    else
2113294c433Smrg	test -z "$file" || exec >$file
2123294c433Smrg	echo "#! /bin/sh"
2133294c433Smrg	echo "# Created by GNU Automake missing as a replacement of"
2143294c433Smrg	echo "#  $ $@"
2153294c433Smrg	echo "exit 0"
2163294c433Smrg	chmod +x $file
2173294c433Smrg	exit 1
2183294c433Smrg    fi
2193294c433Smrg    ;;
2203294c433Smrg
2219bc46bd4Smrg  bison*|yacc*)
2223294c433Smrg    echo 1>&2 "\
2239bc46bd4SmrgWARNING: \`$1' $msg.  You should only need it if
2243294c433Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2253294c433Smrg         in order for those modifications to take effect.  You can get
2263294c433Smrg         \`Bison' from any GNU archive site."
2273294c433Smrg    rm -f y.tab.c y.tab.h
2289bc46bd4Smrg    if test $# -ne 1; then
2293294c433Smrg        eval LASTARG="\${$#}"
2309bc46bd4Smrg	case $LASTARG in
2313294c433Smrg	*.y)
2323294c433Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2339bc46bd4Smrg	    if test -f "$SRCFILE"; then
2343294c433Smrg	         cp "$SRCFILE" y.tab.c
2353294c433Smrg	    fi
2363294c433Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2379bc46bd4Smrg	    if test -f "$SRCFILE"; then
2383294c433Smrg	         cp "$SRCFILE" y.tab.h
2393294c433Smrg	    fi
2403294c433Smrg	  ;;
2413294c433Smrg	esac
2423294c433Smrg    fi
2439bc46bd4Smrg    if test ! -f y.tab.h; then
2443294c433Smrg	echo >y.tab.h
2453294c433Smrg    fi
2469bc46bd4Smrg    if test ! -f y.tab.c; then
2473294c433Smrg	echo 'main() { return 0; }' >y.tab.c
2483294c433Smrg    fi
2493294c433Smrg    ;;
2503294c433Smrg
2519bc46bd4Smrg  lex*|flex*)
2523294c433Smrg    echo 1>&2 "\
2539bc46bd4SmrgWARNING: \`$1' is $msg.  You should only need it if
2543294c433Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2553294c433Smrg         in order for those modifications to take effect.  You can get
2563294c433Smrg         \`Flex' from any GNU archive site."
2573294c433Smrg    rm -f lex.yy.c
2589bc46bd4Smrg    if test $# -ne 1; then
2593294c433Smrg        eval LASTARG="\${$#}"
2609bc46bd4Smrg	case $LASTARG in
2613294c433Smrg	*.l)
2623294c433Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2639bc46bd4Smrg	    if test -f "$SRCFILE"; then
2643294c433Smrg	         cp "$SRCFILE" lex.yy.c
2653294c433Smrg	    fi
2663294c433Smrg	  ;;
2673294c433Smrg	esac
2683294c433Smrg    fi
2699bc46bd4Smrg    if test ! -f lex.yy.c; then
2703294c433Smrg	echo 'main() { return 0; }' >lex.yy.c
2713294c433Smrg    fi
2723294c433Smrg    ;;
2733294c433Smrg
2749bc46bd4Smrg  help2man*)
2753294c433Smrg    echo 1>&2 "\
2769bc46bd4SmrgWARNING: \`$1' is $msg.  You should only need it if
2773294c433Smrg	 you modified a dependency of a manual page.  You may need the
2783294c433Smrg	 \`Help2man' package in order for those modifications to take
2793294c433Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2803294c433Smrg
2819bc46bd4Smrg    file=`echo "$*" | sed -n "$sed_output"`
2829bc46bd4Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2839bc46bd4Smrg    if test -f "$file"; then
2843294c433Smrg	touch $file
2853294c433Smrg    else
2863294c433Smrg	test -z "$file" || exec >$file
2873294c433Smrg	echo ".ab help2man is required to generate this page"
2889bc46bd4Smrg	exit $?
2893294c433Smrg    fi
2903294c433Smrg    ;;
2913294c433Smrg
2929bc46bd4Smrg  makeinfo*)
2933294c433Smrg    echo 1>&2 "\
2949bc46bd4SmrgWARNING: \`$1' is $msg.  You should only need it if
2953294c433Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2963294c433Smrg         indirectly affecting the aspect of the manual.  The spurious
2973294c433Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2983294c433Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2993294c433Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
3009bc46bd4Smrg    # The file to touch is that specified with -o ...
3019bc46bd4Smrg    file=`echo "$*" | sed -n "$sed_output"`
3029bc46bd4Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
3033294c433Smrg    if test -z "$file"; then
3049bc46bd4Smrg      # ... or it is the one specified with @setfilename ...
3059bc46bd4Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3069bc46bd4Smrg      file=`sed -n '
3079bc46bd4Smrg	/^@setfilename/{
3089bc46bd4Smrg	  s/.* \([^ ]*\) *$/\1/
3099bc46bd4Smrg	  p
3109bc46bd4Smrg	  q
3119bc46bd4Smrg	}' $infile`
3129bc46bd4Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3139bc46bd4Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3143294c433Smrg    fi
3159bc46bd4Smrg    # If the file does not exist, the user really needs makeinfo;
3169bc46bd4Smrg    # let's fail without touching anything.
3179bc46bd4Smrg    test -f $file || exit 1
3183294c433Smrg    touch $file
3193294c433Smrg    ;;
3203294c433Smrg
3219bc46bd4Smrg  tar*)
3223294c433Smrg    shift
3233294c433Smrg
3243294c433Smrg    # We have already tried tar in the generic part.
3253294c433Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3263294c433Smrg    # messages.
3273294c433Smrg    if (gnutar --version > /dev/null 2>&1); then
3283294c433Smrg       gnutar "$@" && exit 0
3293294c433Smrg    fi
3303294c433Smrg    if (gtar --version > /dev/null 2>&1); then
3313294c433Smrg       gtar "$@" && exit 0
3323294c433Smrg    fi
3333294c433Smrg    firstarg="$1"
3343294c433Smrg    if shift; then
3359bc46bd4Smrg	case $firstarg in
3363294c433Smrg	*o*)
3373294c433Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3383294c433Smrg	    tar "$firstarg" "$@" && exit 0
3393294c433Smrg	    ;;
3403294c433Smrg	esac
3419bc46bd4Smrg	case $firstarg in
3423294c433Smrg	*h*)
3433294c433Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3443294c433Smrg	    tar "$firstarg" "$@" && exit 0
3453294c433Smrg	    ;;
3463294c433Smrg	esac
3473294c433Smrg    fi
3483294c433Smrg
3493294c433Smrg    echo 1>&2 "\
3503294c433SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3513294c433Smrg         You may want to install GNU tar or Free paxutils, or check the
3523294c433Smrg         command line arguments."
3533294c433Smrg    exit 1
3543294c433Smrg    ;;
3553294c433Smrg
3563294c433Smrg  *)
3573294c433Smrg    echo 1>&2 "\
3589bc46bd4SmrgWARNING: \`$1' is needed, and is $msg.
3599bc46bd4Smrg         You might have modified some files without having the
3603294c433Smrg         proper tools for further handling them.  Check the \`README' file,
3613294c433Smrg         it often tells you about the needed prerequisites for installing
3623294c433Smrg         this package.  You may also peek at any GNU archive site, in case
3633294c433Smrg         some other package would contain this missing \`$1' program."
3643294c433Smrg    exit 1
3653294c433Smrg    ;;
3663294c433Smrgesac
3673294c433Smrg
3683294c433Smrgexit 0
3699bc46bd4Smrg
3709bc46bd4Smrg# Local variables:
3719bc46bd4Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3729bc46bd4Smrg# time-stamp-start: "scriptversion="
3739bc46bd4Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3749bc46bd4Smrg# time-stamp-time-zone: "UTC"
3759bc46bd4Smrg# time-stamp-end: "; # UTC"
3769bc46bd4Smrg# End:
377