missing revision 9bd41f2c
19bd41f2cSmrg#! /bin/sh
29bd41f2cSmrg# Common stub for a few missing GNU programs while installing.
39bd41f2cSmrg
49bd41f2cSmrgscriptversion=2006-05-10.23
59bd41f2cSmrg
69bd41f2cSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
79bd41f2cSmrg#   Free Software Foundation, Inc.
89bd41f2cSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
99bd41f2cSmrg
109bd41f2cSmrg# This program is free software; you can redistribute it and/or modify
119bd41f2cSmrg# it under the terms of the GNU General Public License as published by
129bd41f2cSmrg# the Free Software Foundation; either version 2, or (at your option)
139bd41f2cSmrg# any later version.
149bd41f2cSmrg
159bd41f2cSmrg# This program is distributed in the hope that it will be useful,
169bd41f2cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
179bd41f2cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
189bd41f2cSmrg# GNU General Public License for more details.
199bd41f2cSmrg
209bd41f2cSmrg# You should have received a copy of the GNU General Public License
219bd41f2cSmrg# along with this program; if not, write to the Free Software
229bd41f2cSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
239bd41f2cSmrg# 02110-1301, USA.
249bd41f2cSmrg
259bd41f2cSmrg# As a special exception to the GNU General Public License, if you
269bd41f2cSmrg# distribute this file as part of a program that contains a
279bd41f2cSmrg# configuration script generated by Autoconf, you may include it under
289bd41f2cSmrg# the same distribution terms that you use for the rest of that program.
299bd41f2cSmrg
309bd41f2cSmrgif test $# -eq 0; then
319bd41f2cSmrg  echo 1>&2 "Try \`$0 --help' for more information"
329bd41f2cSmrg  exit 1
339bd41f2cSmrgfi
349bd41f2cSmrg
359bd41f2cSmrgrun=:
369bd41f2cSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
379bd41f2cSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
389bd41f2cSmrg
399bd41f2cSmrg# In the cases where this matters, `missing' is being run in the
409bd41f2cSmrg# srcdir already.
419bd41f2cSmrgif test -f configure.ac; then
429bd41f2cSmrg  configure_ac=configure.ac
439bd41f2cSmrgelse
449bd41f2cSmrg  configure_ac=configure.in
459bd41f2cSmrgfi
469bd41f2cSmrg
479bd41f2cSmrgmsg="missing on your system"
489bd41f2cSmrg
499bd41f2cSmrgcase $1 in
509bd41f2cSmrg--run)
519bd41f2cSmrg  # Try to run requested program, and just exit if it succeeds.
529bd41f2cSmrg  run=
539bd41f2cSmrg  shift
549bd41f2cSmrg  "$@" && exit 0
559bd41f2cSmrg  # Exit code 63 means version mismatch.  This often happens
569bd41f2cSmrg  # when the user try to use an ancient version of a tool on
579bd41f2cSmrg  # a file that requires a minimum version.  In this case we
589bd41f2cSmrg  # we should proceed has if the program had been absent, or
599bd41f2cSmrg  # if --run hadn't been passed.
609bd41f2cSmrg  if test $? = 63; then
619bd41f2cSmrg    run=:
629bd41f2cSmrg    msg="probably too old"
639bd41f2cSmrg  fi
649bd41f2cSmrg  ;;
659bd41f2cSmrg
669bd41f2cSmrg  -h|--h|--he|--hel|--help)
679bd41f2cSmrg    echo "\
689bd41f2cSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
699bd41f2cSmrg
709bd41f2cSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
719bd41f2cSmrgerror status if there is no known handling for PROGRAM.
729bd41f2cSmrg
739bd41f2cSmrgOptions:
749bd41f2cSmrg  -h, --help      display this help and exit
759bd41f2cSmrg  -v, --version   output version information and exit
769bd41f2cSmrg  --run           try to run the given command, and emulate it if it fails
779bd41f2cSmrg
789bd41f2cSmrgSupported PROGRAM values:
799bd41f2cSmrg  aclocal      touch file \`aclocal.m4'
809bd41f2cSmrg  autoconf     touch file \`configure'
819bd41f2cSmrg  autoheader   touch file \`config.h.in'
829bd41f2cSmrg  autom4te     touch the output file, or create a stub one
839bd41f2cSmrg  automake     touch all \`Makefile.in' files
849bd41f2cSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
859bd41f2cSmrg  flex         create \`lex.yy.c', if possible, from existing .c
869bd41f2cSmrg  help2man     touch the output file
879bd41f2cSmrg  lex          create \`lex.yy.c', if possible, from existing .c
889bd41f2cSmrg  makeinfo     touch the output file
899bd41f2cSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
909bd41f2cSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
919bd41f2cSmrg
929bd41f2cSmrgSend bug reports to <bug-automake@gnu.org>."
939bd41f2cSmrg    exit $?
949bd41f2cSmrg    ;;
959bd41f2cSmrg
969bd41f2cSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
979bd41f2cSmrg    echo "missing $scriptversion (GNU Automake)"
989bd41f2cSmrg    exit $?
999bd41f2cSmrg    ;;
1009bd41f2cSmrg
1019bd41f2cSmrg  -*)
1029bd41f2cSmrg    echo 1>&2 "$0: Unknown \`$1' option"
1039bd41f2cSmrg    echo 1>&2 "Try \`$0 --help' for more information"
1049bd41f2cSmrg    exit 1
1059bd41f2cSmrg    ;;
1069bd41f2cSmrg
1079bd41f2cSmrgesac
1089bd41f2cSmrg
1099bd41f2cSmrg# Now exit if we have it, but it failed.  Also exit now if we
1109bd41f2cSmrg# don't have it and --version was passed (most likely to detect
1119bd41f2cSmrg# the program).
1129bd41f2cSmrgcase $1 in
1139bd41f2cSmrg  lex|yacc)
1149bd41f2cSmrg    # Not GNU programs, they don't have --version.
1159bd41f2cSmrg    ;;
1169bd41f2cSmrg
1179bd41f2cSmrg  tar)
1189bd41f2cSmrg    if test -n "$run"; then
1199bd41f2cSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
1209bd41f2cSmrg       exit 1
1219bd41f2cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1229bd41f2cSmrg       exit 1
1239bd41f2cSmrg    fi
1249bd41f2cSmrg    ;;
1259bd41f2cSmrg
1269bd41f2cSmrg  *)
1279bd41f2cSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1289bd41f2cSmrg       # We have it, but it failed.
1299bd41f2cSmrg       exit 1
1309bd41f2cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1319bd41f2cSmrg       # Could not run --version or --help.  This is probably someone
1329bd41f2cSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1339bd41f2cSmrg       # $TOOL exists and not knowing $TOOL uses missing.
1349bd41f2cSmrg       exit 1
1359bd41f2cSmrg    fi
1369bd41f2cSmrg    ;;
1379bd41f2cSmrgesac
1389bd41f2cSmrg
1399bd41f2cSmrg# If it does not exist, or fails to run (possibly an outdated version),
1409bd41f2cSmrg# try to emulate it.
1419bd41f2cSmrgcase $1 in
1429bd41f2cSmrg  aclocal*)
1439bd41f2cSmrg    echo 1>&2 "\
1449bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
1459bd41f2cSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1469bd41f2cSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1479bd41f2cSmrg         any GNU archive site."
1489bd41f2cSmrg    touch aclocal.m4
1499bd41f2cSmrg    ;;
1509bd41f2cSmrg
1519bd41f2cSmrg  autoconf)
1529bd41f2cSmrg    echo 1>&2 "\
1539bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
1549bd41f2cSmrg         you modified \`${configure_ac}'.  You might want to install the
1559bd41f2cSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1569bd41f2cSmrg         archive site."
1579bd41f2cSmrg    touch configure
1589bd41f2cSmrg    ;;
1599bd41f2cSmrg
1609bd41f2cSmrg  autoheader)
1619bd41f2cSmrg    echo 1>&2 "\
1629bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
1639bd41f2cSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1649bd41f2cSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1659bd41f2cSmrg         from any GNU archive site."
1669bd41f2cSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1679bd41f2cSmrg    test -z "$files" && files="config.h"
1689bd41f2cSmrg    touch_files=
1699bd41f2cSmrg    for f in $files; do
1709bd41f2cSmrg      case $f in
1719bd41f2cSmrg      *:*) touch_files="$touch_files "`echo "$f" |
1729bd41f2cSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1739bd41f2cSmrg      *) touch_files="$touch_files $f.in";;
1749bd41f2cSmrg      esac
1759bd41f2cSmrg    done
1769bd41f2cSmrg    touch $touch_files
1779bd41f2cSmrg    ;;
1789bd41f2cSmrg
1799bd41f2cSmrg  automake*)
1809bd41f2cSmrg    echo 1>&2 "\
1819bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
1829bd41f2cSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1839bd41f2cSmrg         You might want to install the \`Automake' and \`Perl' packages.
1849bd41f2cSmrg         Grab them from any GNU archive site."
1859bd41f2cSmrg    find . -type f -name Makefile.am -print |
1869bd41f2cSmrg	   sed 's/\.am$/.in/' |
1879bd41f2cSmrg	   while read f; do touch "$f"; done
1889bd41f2cSmrg    ;;
1899bd41f2cSmrg
1909bd41f2cSmrg  autom4te)
1919bd41f2cSmrg    echo 1>&2 "\
1929bd41f2cSmrgWARNING: \`$1' is needed, but is $msg.
1939bd41f2cSmrg         You might have modified some files without having the
1949bd41f2cSmrg         proper tools for further handling them.
1959bd41f2cSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
1969bd41f2cSmrg         archive site."
1979bd41f2cSmrg
1989bd41f2cSmrg    file=`echo "$*" | sed -n "$sed_output"`
1999bd41f2cSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2009bd41f2cSmrg    if test -f "$file"; then
2019bd41f2cSmrg	touch $file
2029bd41f2cSmrg    else
2039bd41f2cSmrg	test -z "$file" || exec >$file
2049bd41f2cSmrg	echo "#! /bin/sh"
2059bd41f2cSmrg	echo "# Created by GNU Automake missing as a replacement of"
2069bd41f2cSmrg	echo "#  $ $@"
2079bd41f2cSmrg	echo "exit 0"
2089bd41f2cSmrg	chmod +x $file
2099bd41f2cSmrg	exit 1
2109bd41f2cSmrg    fi
2119bd41f2cSmrg    ;;
2129bd41f2cSmrg
2139bd41f2cSmrg  bison|yacc)
2149bd41f2cSmrg    echo 1>&2 "\
2159bd41f2cSmrgWARNING: \`$1' $msg.  You should only need it if
2169bd41f2cSmrg         you modified a \`.y' file.  You may need the \`Bison' package
2179bd41f2cSmrg         in order for those modifications to take effect.  You can get
2189bd41f2cSmrg         \`Bison' from any GNU archive site."
2199bd41f2cSmrg    rm -f y.tab.c y.tab.h
2209bd41f2cSmrg    if test $# -ne 1; then
2219bd41f2cSmrg        eval LASTARG="\${$#}"
2229bd41f2cSmrg	case $LASTARG in
2239bd41f2cSmrg	*.y)
2249bd41f2cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2259bd41f2cSmrg	    if test -f "$SRCFILE"; then
2269bd41f2cSmrg	         cp "$SRCFILE" y.tab.c
2279bd41f2cSmrg	    fi
2289bd41f2cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2299bd41f2cSmrg	    if test -f "$SRCFILE"; then
2309bd41f2cSmrg	         cp "$SRCFILE" y.tab.h
2319bd41f2cSmrg	    fi
2329bd41f2cSmrg	  ;;
2339bd41f2cSmrg	esac
2349bd41f2cSmrg    fi
2359bd41f2cSmrg    if test ! -f y.tab.h; then
2369bd41f2cSmrg	echo >y.tab.h
2379bd41f2cSmrg    fi
2389bd41f2cSmrg    if test ! -f y.tab.c; then
2399bd41f2cSmrg	echo 'main() { return 0; }' >y.tab.c
2409bd41f2cSmrg    fi
2419bd41f2cSmrg    ;;
2429bd41f2cSmrg
2439bd41f2cSmrg  lex|flex)
2449bd41f2cSmrg    echo 1>&2 "\
2459bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
2469bd41f2cSmrg         you modified a \`.l' file.  You may need the \`Flex' package
2479bd41f2cSmrg         in order for those modifications to take effect.  You can get
2489bd41f2cSmrg         \`Flex' from any GNU archive site."
2499bd41f2cSmrg    rm -f lex.yy.c
2509bd41f2cSmrg    if test $# -ne 1; then
2519bd41f2cSmrg        eval LASTARG="\${$#}"
2529bd41f2cSmrg	case $LASTARG in
2539bd41f2cSmrg	*.l)
2549bd41f2cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2559bd41f2cSmrg	    if test -f "$SRCFILE"; then
2569bd41f2cSmrg	         cp "$SRCFILE" lex.yy.c
2579bd41f2cSmrg	    fi
2589bd41f2cSmrg	  ;;
2599bd41f2cSmrg	esac
2609bd41f2cSmrg    fi
2619bd41f2cSmrg    if test ! -f lex.yy.c; then
2629bd41f2cSmrg	echo 'main() { return 0; }' >lex.yy.c
2639bd41f2cSmrg    fi
2649bd41f2cSmrg    ;;
2659bd41f2cSmrg
2669bd41f2cSmrg  help2man)
2679bd41f2cSmrg    echo 1>&2 "\
2689bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
2699bd41f2cSmrg	 you modified a dependency of a manual page.  You may need the
2709bd41f2cSmrg	 \`Help2man' package in order for those modifications to take
2719bd41f2cSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
2729bd41f2cSmrg
2739bd41f2cSmrg    file=`echo "$*" | sed -n "$sed_output"`
2749bd41f2cSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2759bd41f2cSmrg    if test -f "$file"; then
2769bd41f2cSmrg	touch $file
2779bd41f2cSmrg    else
2789bd41f2cSmrg	test -z "$file" || exec >$file
2799bd41f2cSmrg	echo ".ab help2man is required to generate this page"
2809bd41f2cSmrg	exit 1
2819bd41f2cSmrg    fi
2829bd41f2cSmrg    ;;
2839bd41f2cSmrg
2849bd41f2cSmrg  makeinfo)
2859bd41f2cSmrg    echo 1>&2 "\
2869bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
2879bd41f2cSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2889bd41f2cSmrg         indirectly affecting the aspect of the manual.  The spurious
2899bd41f2cSmrg         call might also be the consequence of using a buggy \`make' (AIX,
2909bd41f2cSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2919bd41f2cSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
2929bd41f2cSmrg    # The file to touch is that specified with -o ...
2939bd41f2cSmrg    file=`echo "$*" | sed -n "$sed_output"`
2949bd41f2cSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2959bd41f2cSmrg    if test -z "$file"; then
2969bd41f2cSmrg      # ... or it is the one specified with @setfilename ...
2979bd41f2cSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2989bd41f2cSmrg      file=`sed -n '
2999bd41f2cSmrg	/^@setfilename/{
3009bd41f2cSmrg	  s/.* \([^ ]*\) *$/\1/
3019bd41f2cSmrg	  p
3029bd41f2cSmrg	  q
3039bd41f2cSmrg	}' $infile`
3049bd41f2cSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3059bd41f2cSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3069bd41f2cSmrg    fi
3079bd41f2cSmrg    # If the file does not exist, the user really needs makeinfo;
3089bd41f2cSmrg    # let's fail without touching anything.
3099bd41f2cSmrg    test -f $file || exit 1
3109bd41f2cSmrg    touch $file
3119bd41f2cSmrg    ;;
3129bd41f2cSmrg
3139bd41f2cSmrg  tar)
3149bd41f2cSmrg    shift
3159bd41f2cSmrg
3169bd41f2cSmrg    # We have already tried tar in the generic part.
3179bd41f2cSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
3189bd41f2cSmrg    # messages.
3199bd41f2cSmrg    if (gnutar --version > /dev/null 2>&1); then
3209bd41f2cSmrg       gnutar "$@" && exit 0
3219bd41f2cSmrg    fi
3229bd41f2cSmrg    if (gtar --version > /dev/null 2>&1); then
3239bd41f2cSmrg       gtar "$@" && exit 0
3249bd41f2cSmrg    fi
3259bd41f2cSmrg    firstarg="$1"
3269bd41f2cSmrg    if shift; then
3279bd41f2cSmrg	case $firstarg in
3289bd41f2cSmrg	*o*)
3299bd41f2cSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
3309bd41f2cSmrg	    tar "$firstarg" "$@" && exit 0
3319bd41f2cSmrg	    ;;
3329bd41f2cSmrg	esac
3339bd41f2cSmrg	case $firstarg in
3349bd41f2cSmrg	*h*)
3359bd41f2cSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
3369bd41f2cSmrg	    tar "$firstarg" "$@" && exit 0
3379bd41f2cSmrg	    ;;
3389bd41f2cSmrg	esac
3399bd41f2cSmrg    fi
3409bd41f2cSmrg
3419bd41f2cSmrg    echo 1>&2 "\
3429bd41f2cSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3439bd41f2cSmrg         You may want to install GNU tar or Free paxutils, or check the
3449bd41f2cSmrg         command line arguments."
3459bd41f2cSmrg    exit 1
3469bd41f2cSmrg    ;;
3479bd41f2cSmrg
3489bd41f2cSmrg  *)
3499bd41f2cSmrg    echo 1>&2 "\
3509bd41f2cSmrgWARNING: \`$1' is needed, and is $msg.
3519bd41f2cSmrg         You might have modified some files without having the
3529bd41f2cSmrg         proper tools for further handling them.  Check the \`README' file,
3539bd41f2cSmrg         it often tells you about the needed prerequisites for installing
3549bd41f2cSmrg         this package.  You may also peek at any GNU archive site, in case
3559bd41f2cSmrg         some other package would contain this missing \`$1' program."
3569bd41f2cSmrg    exit 1
3579bd41f2cSmrg    ;;
3589bd41f2cSmrgesac
3599bd41f2cSmrg
3609bd41f2cSmrgexit 0
3619bd41f2cSmrg
3629bd41f2cSmrg# Local variables:
3639bd41f2cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3649bd41f2cSmrg# time-stamp-start: "scriptversion="
3659bd41f2cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3669bd41f2cSmrg# time-stamp-end: "$"
3679bd41f2cSmrg# End:
368