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