missing revision 44af7230
18ae04fa6Smrg#! /bin/sh
28ae04fa6Smrg# Common stub for a few missing GNU programs while installing.
38ae04fa6Smrg
444af7230Smrgscriptversion=2009-04-28.21; # UTC
58ae04fa6Smrg
644af7230Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
744af7230Smrg# 2008, 2009 Free Software Foundation, Inc.
88ae04fa6Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
98ae04fa6Smrg
108ae04fa6Smrg# This program is free software; you can redistribute it and/or modify
118ae04fa6Smrg# it under the terms of the GNU General Public License as published by
128ae04fa6Smrg# the Free Software Foundation; either version 2, or (at your option)
138ae04fa6Smrg# any later version.
148ae04fa6Smrg
158ae04fa6Smrg# This program is distributed in the hope that it will be useful,
168ae04fa6Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
178ae04fa6Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
188ae04fa6Smrg# GNU General Public License for more details.
198ae04fa6Smrg
208ae04fa6Smrg# You should have received a copy of the GNU General Public License
2144af7230Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
228ae04fa6Smrg
238ae04fa6Smrg# As a special exception to the GNU General Public License, if you
248ae04fa6Smrg# distribute this file as part of a program that contains a
258ae04fa6Smrg# configuration script generated by Autoconf, you may include it under
268ae04fa6Smrg# the same distribution terms that you use for the rest of that program.
278ae04fa6Smrg
288ae04fa6Smrgif test $# -eq 0; then
298ae04fa6Smrg  echo 1>&2 "Try \`$0 --help' for more information"
308ae04fa6Smrg  exit 1
318ae04fa6Smrgfi
328ae04fa6Smrg
338ae04fa6Smrgrun=:
348ae04fa6Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
358ae04fa6Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
368ae04fa6Smrg
378ae04fa6Smrg# In the cases where this matters, `missing' is being run in the
388ae04fa6Smrg# srcdir already.
398ae04fa6Smrgif test -f configure.ac; then
408ae04fa6Smrg  configure_ac=configure.ac
418ae04fa6Smrgelse
428ae04fa6Smrg  configure_ac=configure.in
438ae04fa6Smrgfi
448ae04fa6Smrg
458ae04fa6Smrgmsg="missing on your system"
468ae04fa6Smrg
478ae04fa6Smrgcase $1 in
488ae04fa6Smrg--run)
498ae04fa6Smrg  # Try to run requested program, and just exit if it succeeds.
508ae04fa6Smrg  run=
518ae04fa6Smrg  shift
528ae04fa6Smrg  "$@" && exit 0
538ae04fa6Smrg  # Exit code 63 means version mismatch.  This often happens
548ae04fa6Smrg  # when the user try to use an ancient version of a tool on
558ae04fa6Smrg  # a file that requires a minimum version.  In this case we
568ae04fa6Smrg  # we should proceed has if the program had been absent, or
578ae04fa6Smrg  # if --run hadn't been passed.
588ae04fa6Smrg  if test $? = 63; then
598ae04fa6Smrg    run=:
608ae04fa6Smrg    msg="probably too old"
618ae04fa6Smrg  fi
628ae04fa6Smrg  ;;
638ae04fa6Smrg
648ae04fa6Smrg  -h|--h|--he|--hel|--help)
658ae04fa6Smrg    echo "\
668ae04fa6Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
678ae04fa6Smrg
688ae04fa6SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
698ae04fa6Smrgerror status if there is no known handling for PROGRAM.
708ae04fa6Smrg
718ae04fa6SmrgOptions:
728ae04fa6Smrg  -h, --help      display this help and exit
738ae04fa6Smrg  -v, --version   output version information and exit
748ae04fa6Smrg  --run           try to run the given command, and emulate it if it fails
758ae04fa6Smrg
768ae04fa6SmrgSupported PROGRAM values:
778ae04fa6Smrg  aclocal      touch file \`aclocal.m4'
788ae04fa6Smrg  autoconf     touch file \`configure'
798ae04fa6Smrg  autoheader   touch file \`config.h.in'
808ae04fa6Smrg  autom4te     touch the output file, or create a stub one
818ae04fa6Smrg  automake     touch all \`Makefile.in' files
828ae04fa6Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
838ae04fa6Smrg  flex         create \`lex.yy.c', if possible, from existing .c
848ae04fa6Smrg  help2man     touch the output file
858ae04fa6Smrg  lex          create \`lex.yy.c', if possible, from existing .c
868ae04fa6Smrg  makeinfo     touch the output file
878ae04fa6Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
888ae04fa6Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
898ae04fa6Smrg
9044af7230SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
9144af7230Smrg\`g' are ignored when checking the name.
9244af7230Smrg
938ae04fa6SmrgSend bug reports to <bug-automake@gnu.org>."
948ae04fa6Smrg    exit $?
958ae04fa6Smrg    ;;
968ae04fa6Smrg
978ae04fa6Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
988ae04fa6Smrg    echo "missing $scriptversion (GNU Automake)"
998ae04fa6Smrg    exit $?
1008ae04fa6Smrg    ;;
1018ae04fa6Smrg
1028ae04fa6Smrg  -*)
1038ae04fa6Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1048ae04fa6Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1058ae04fa6Smrg    exit 1
1068ae04fa6Smrg    ;;
1078ae04fa6Smrg
1088ae04fa6Smrgesac
1098ae04fa6Smrg
11044af7230Smrg# normalize program name to check for.
11144af7230Smrgprogram=`echo "$1" | sed '
11244af7230Smrg  s/^gnu-//; t
11344af7230Smrg  s/^gnu//; t
11444af7230Smrg  s/^g//; t'`
11544af7230Smrg
1168ae04fa6Smrg# Now exit if we have it, but it failed.  Also exit now if we
1178ae04fa6Smrg# don't have it and --version was passed (most likely to detect
11844af7230Smrg# the program).  This is about non-GNU programs, so use $1 not
11944af7230Smrg# $program.
1208ae04fa6Smrgcase $1 in
12144af7230Smrg  lex*|yacc*)
1228ae04fa6Smrg    # Not GNU programs, they don't have --version.
1238ae04fa6Smrg    ;;
1248ae04fa6Smrg
12544af7230Smrg  tar*)
1268ae04fa6Smrg    if test -n "$run"; then
1278ae04fa6Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1288ae04fa6Smrg       exit 1
1298ae04fa6Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1308ae04fa6Smrg       exit 1
1318ae04fa6Smrg    fi
1328ae04fa6Smrg    ;;
1338ae04fa6Smrg
1348ae04fa6Smrg  *)
1358ae04fa6Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1368ae04fa6Smrg       # We have it, but it failed.
1378ae04fa6Smrg       exit 1
1388ae04fa6Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1398ae04fa6Smrg       # Could not run --version or --help.  This is probably someone
1408ae04fa6Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1418ae04fa6Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1428ae04fa6Smrg       exit 1
1438ae04fa6Smrg    fi
1448ae04fa6Smrg    ;;
1458ae04fa6Smrgesac
1468ae04fa6Smrg
1478ae04fa6Smrg# If it does not exist, or fails to run (possibly an outdated version),
1488ae04fa6Smrg# try to emulate it.
14944af7230Smrgcase $program in
1508ae04fa6Smrg  aclocal*)
1518ae04fa6Smrg    echo 1>&2 "\
1528ae04fa6SmrgWARNING: \`$1' is $msg.  You should only need it if
1538ae04fa6Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1548ae04fa6Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1558ae04fa6Smrg         any GNU archive site."
1568ae04fa6Smrg    touch aclocal.m4
1578ae04fa6Smrg    ;;
1588ae04fa6Smrg
15944af7230Smrg  autoconf*)
1608ae04fa6Smrg    echo 1>&2 "\
1618ae04fa6SmrgWARNING: \`$1' is $msg.  You should only need it if
1628ae04fa6Smrg         you modified \`${configure_ac}'.  You might want to install the
1638ae04fa6Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1648ae04fa6Smrg         archive site."
1658ae04fa6Smrg    touch configure
1668ae04fa6Smrg    ;;
1678ae04fa6Smrg
16844af7230Smrg  autoheader*)
1698ae04fa6Smrg    echo 1>&2 "\
1708ae04fa6SmrgWARNING: \`$1' is $msg.  You should only need it if
1718ae04fa6Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1728ae04fa6Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1738ae04fa6Smrg         from any GNU archive site."
1748ae04fa6Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1758ae04fa6Smrg    test -z "$files" && files="config.h"
1768ae04fa6Smrg    touch_files=
1778ae04fa6Smrg    for f in $files; do
1788ae04fa6Smrg      case $f in
1798ae04fa6Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1808ae04fa6Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1818ae04fa6Smrg      *) touch_files="$touch_files $f.in";;
1828ae04fa6Smrg      esac
1838ae04fa6Smrg    done
1848ae04fa6Smrg    touch $touch_files
1858ae04fa6Smrg    ;;
1868ae04fa6Smrg
1878ae04fa6Smrg  automake*)
1888ae04fa6Smrg    echo 1>&2 "\
1898ae04fa6SmrgWARNING: \`$1' is $msg.  You should only need it if
1908ae04fa6Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1918ae04fa6Smrg         You might want to install the \`Automake' and \`Perl' packages.
1928ae04fa6Smrg         Grab them from any GNU archive site."
1938ae04fa6Smrg    find . -type f -name Makefile.am -print |
1948ae04fa6Smrg	   sed 's/\.am$/.in/' |
1958ae04fa6Smrg	   while read f; do touch "$f"; done
1968ae04fa6Smrg    ;;
1978ae04fa6Smrg
19844af7230Smrg  autom4te*)
1998ae04fa6Smrg    echo 1>&2 "\
2008ae04fa6SmrgWARNING: \`$1' is needed, but is $msg.
2018ae04fa6Smrg         You might have modified some files without having the
2028ae04fa6Smrg         proper tools for further handling them.
2038ae04fa6Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
2048ae04fa6Smrg         archive site."
2058ae04fa6Smrg
2068ae04fa6Smrg    file=`echo "$*" | sed -n "$sed_output"`
2078ae04fa6Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2088ae04fa6Smrg    if test -f "$file"; then
2098ae04fa6Smrg	touch $file
2108ae04fa6Smrg    else
2118ae04fa6Smrg	test -z "$file" || exec >$file
2128ae04fa6Smrg	echo "#! /bin/sh"
2138ae04fa6Smrg	echo "# Created by GNU Automake missing as a replacement of"
2148ae04fa6Smrg	echo "#  $ $@"
2158ae04fa6Smrg	echo "exit 0"
2168ae04fa6Smrg	chmod +x $file
2178ae04fa6Smrg	exit 1
2188ae04fa6Smrg    fi
2198ae04fa6Smrg    ;;
2208ae04fa6Smrg
22144af7230Smrg  bison*|yacc*)
2228ae04fa6Smrg    echo 1>&2 "\
2238ae04fa6SmrgWARNING: \`$1' $msg.  You should only need it if
2248ae04fa6Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2258ae04fa6Smrg         in order for those modifications to take effect.  You can get
2268ae04fa6Smrg         \`Bison' from any GNU archive site."
2278ae04fa6Smrg    rm -f y.tab.c y.tab.h
2288ae04fa6Smrg    if test $# -ne 1; then
2298ae04fa6Smrg        eval LASTARG="\${$#}"
2308ae04fa6Smrg	case $LASTARG in
2318ae04fa6Smrg	*.y)
2328ae04fa6Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2338ae04fa6Smrg	    if test -f "$SRCFILE"; then
2348ae04fa6Smrg	         cp "$SRCFILE" y.tab.c
2358ae04fa6Smrg	    fi
2368ae04fa6Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2378ae04fa6Smrg	    if test -f "$SRCFILE"; then
2388ae04fa6Smrg	         cp "$SRCFILE" y.tab.h
2398ae04fa6Smrg	    fi
2408ae04fa6Smrg	  ;;
2418ae04fa6Smrg	esac
2428ae04fa6Smrg    fi
2438ae04fa6Smrg    if test ! -f y.tab.h; then
2448ae04fa6Smrg	echo >y.tab.h
2458ae04fa6Smrg    fi
2468ae04fa6Smrg    if test ! -f y.tab.c; then
2478ae04fa6Smrg	echo 'main() { return 0; }' >y.tab.c
2488ae04fa6Smrg    fi
2498ae04fa6Smrg    ;;
2508ae04fa6Smrg
25144af7230Smrg  lex*|flex*)
2528ae04fa6Smrg    echo 1>&2 "\
2538ae04fa6SmrgWARNING: \`$1' is $msg.  You should only need it if
2548ae04fa6Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2558ae04fa6Smrg         in order for those modifications to take effect.  You can get
2568ae04fa6Smrg         \`Flex' from any GNU archive site."
2578ae04fa6Smrg    rm -f lex.yy.c
2588ae04fa6Smrg    if test $# -ne 1; then
2598ae04fa6Smrg        eval LASTARG="\${$#}"
2608ae04fa6Smrg	case $LASTARG in
2618ae04fa6Smrg	*.l)
2628ae04fa6Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2638ae04fa6Smrg	    if test -f "$SRCFILE"; then
2648ae04fa6Smrg	         cp "$SRCFILE" lex.yy.c
2658ae04fa6Smrg	    fi
2668ae04fa6Smrg	  ;;
2678ae04fa6Smrg	esac
2688ae04fa6Smrg    fi
2698ae04fa6Smrg    if test ! -f lex.yy.c; then
2708ae04fa6Smrg	echo 'main() { return 0; }' >lex.yy.c
2718ae04fa6Smrg    fi
2728ae04fa6Smrg    ;;
2738ae04fa6Smrg
27444af7230Smrg  help2man*)
2758ae04fa6Smrg    echo 1>&2 "\
2768ae04fa6SmrgWARNING: \`$1' is $msg.  You should only need it if
2778ae04fa6Smrg	 you modified a dependency of a manual page.  You may need the
2788ae04fa6Smrg	 \`Help2man' package in order for those modifications to take
2798ae04fa6Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2808ae04fa6Smrg
2818ae04fa6Smrg    file=`echo "$*" | sed -n "$sed_output"`
2828ae04fa6Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2838ae04fa6Smrg    if test -f "$file"; then
2848ae04fa6Smrg	touch $file
2858ae04fa6Smrg    else
2868ae04fa6Smrg	test -z "$file" || exec >$file
2878ae04fa6Smrg	echo ".ab help2man is required to generate this page"
28844af7230Smrg	exit $?
2898ae04fa6Smrg    fi
2908ae04fa6Smrg    ;;
2918ae04fa6Smrg
29244af7230Smrg  makeinfo*)
2938ae04fa6Smrg    echo 1>&2 "\
2948ae04fa6SmrgWARNING: \`$1' is $msg.  You should only need it if
2958ae04fa6Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2968ae04fa6Smrg         indirectly affecting the aspect of the manual.  The spurious
2978ae04fa6Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2988ae04fa6Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2998ae04fa6Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
3008ae04fa6Smrg    # The file to touch is that specified with -o ...
3018ae04fa6Smrg    file=`echo "$*" | sed -n "$sed_output"`
3028ae04fa6Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
3038ae04fa6Smrg    if test -z "$file"; then
3048ae04fa6Smrg      # ... or it is the one specified with @setfilename ...
3058ae04fa6Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3068ae04fa6Smrg      file=`sed -n '
3078ae04fa6Smrg	/^@setfilename/{
3088ae04fa6Smrg	  s/.* \([^ ]*\) *$/\1/
3098ae04fa6Smrg	  p
3108ae04fa6Smrg	  q
3118ae04fa6Smrg	}' $infile`
3128ae04fa6Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3138ae04fa6Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3148ae04fa6Smrg    fi
3158ae04fa6Smrg    # If the file does not exist, the user really needs makeinfo;
3168ae04fa6Smrg    # let's fail without touching anything.
3178ae04fa6Smrg    test -f $file || exit 1
3188ae04fa6Smrg    touch $file
3198ae04fa6Smrg    ;;
3208ae04fa6Smrg
32144af7230Smrg  tar*)
3228ae04fa6Smrg    shift
3238ae04fa6Smrg
3248ae04fa6Smrg    # We have already tried tar in the generic part.
3258ae04fa6Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3268ae04fa6Smrg    # messages.
3278ae04fa6Smrg    if (gnutar --version > /dev/null 2>&1); then
3288ae04fa6Smrg       gnutar "$@" && exit 0
3298ae04fa6Smrg    fi
3308ae04fa6Smrg    if (gtar --version > /dev/null 2>&1); then
3318ae04fa6Smrg       gtar "$@" && exit 0
3328ae04fa6Smrg    fi
3338ae04fa6Smrg    firstarg="$1"
3348ae04fa6Smrg    if shift; then
3358ae04fa6Smrg	case $firstarg in
3368ae04fa6Smrg	*o*)
3378ae04fa6Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3388ae04fa6Smrg	    tar "$firstarg" "$@" && exit 0
3398ae04fa6Smrg	    ;;
3408ae04fa6Smrg	esac
3418ae04fa6Smrg	case $firstarg in
3428ae04fa6Smrg	*h*)
3438ae04fa6Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3448ae04fa6Smrg	    tar "$firstarg" "$@" && exit 0
3458ae04fa6Smrg	    ;;
3468ae04fa6Smrg	esac
3478ae04fa6Smrg    fi
3488ae04fa6Smrg
3498ae04fa6Smrg    echo 1>&2 "\
3508ae04fa6SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3518ae04fa6Smrg         You may want to install GNU tar or Free paxutils, or check the
3528ae04fa6Smrg         command line arguments."
3538ae04fa6Smrg    exit 1
3548ae04fa6Smrg    ;;
3558ae04fa6Smrg
3568ae04fa6Smrg  *)
3578ae04fa6Smrg    echo 1>&2 "\
3588ae04fa6SmrgWARNING: \`$1' is needed, and is $msg.
3598ae04fa6Smrg         You might have modified some files without having the
3608ae04fa6Smrg         proper tools for further handling them.  Check the \`README' file,
3618ae04fa6Smrg         it often tells you about the needed prerequisites for installing
3628ae04fa6Smrg         this package.  You may also peek at any GNU archive site, in case
3638ae04fa6Smrg         some other package would contain this missing \`$1' program."
3648ae04fa6Smrg    exit 1
3658ae04fa6Smrg    ;;
3668ae04fa6Smrgesac
3678ae04fa6Smrg
3688ae04fa6Smrgexit 0
3698ae04fa6Smrg
3708ae04fa6Smrg# Local variables:
3718ae04fa6Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3728ae04fa6Smrg# time-stamp-start: "scriptversion="
3738ae04fa6Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
37444af7230Smrg# time-stamp-time-zone: "UTC"
37544af7230Smrg# time-stamp-end: "; # UTC"
3768ae04fa6Smrg# End:
377