missing revision 5eefee25
15eefee25Smacallan#! /bin/sh
25eefee25Smacallan# Common stub for a few missing GNU programs while installing.
35eefee25Smacallan
45eefee25Smacallanscriptversion=2005-06-08.21
55eefee25Smacallan
65eefee25Smacallan# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
75eefee25Smacallan#   Free Software Foundation, Inc.
85eefee25Smacallan# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
95eefee25Smacallan
105eefee25Smacallan# This program is free software; you can redistribute it and/or modify
115eefee25Smacallan# it under the terms of the GNU General Public License as published by
125eefee25Smacallan# the Free Software Foundation; either version 2, or (at your option)
135eefee25Smacallan# any later version.
145eefee25Smacallan
155eefee25Smacallan# This program is distributed in the hope that it will be useful,
165eefee25Smacallan# but WITHOUT ANY WARRANTY; without even the implied warranty of
175eefee25Smacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
185eefee25Smacallan# GNU General Public License for more details.
195eefee25Smacallan
205eefee25Smacallan# You should have received a copy of the GNU General Public License
215eefee25Smacallan# along with this program; if not, write to the Free Software
225eefee25Smacallan# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
235eefee25Smacallan# 02110-1301, USA.
245eefee25Smacallan
255eefee25Smacallan# As a special exception to the GNU General Public License, if you
265eefee25Smacallan# distribute this file as part of a program that contains a
275eefee25Smacallan# configuration script generated by Autoconf, you may include it under
285eefee25Smacallan# the same distribution terms that you use for the rest of that program.
295eefee25Smacallan
305eefee25Smacallanif test $# -eq 0; then
315eefee25Smacallan  echo 1>&2 "Try \`$0 --help' for more information"
325eefee25Smacallan  exit 1
335eefee25Smacallanfi
345eefee25Smacallan
355eefee25Smacallanrun=:
365eefee25Smacallan
375eefee25Smacallan# In the cases where this matters, `missing' is being run in the
385eefee25Smacallan# srcdir already.
395eefee25Smacallanif test -f configure.ac; then
405eefee25Smacallan  configure_ac=configure.ac
415eefee25Smacallanelse
425eefee25Smacallan  configure_ac=configure.in
435eefee25Smacallanfi
445eefee25Smacallan
455eefee25Smacallanmsg="missing on your system"
465eefee25Smacallan
475eefee25Smacallancase "$1" in
485eefee25Smacallan--run)
495eefee25Smacallan  # Try to run requested program, and just exit if it succeeds.
505eefee25Smacallan  run=
515eefee25Smacallan  shift
525eefee25Smacallan  "$@" && exit 0
535eefee25Smacallan  # Exit code 63 means version mismatch.  This often happens
545eefee25Smacallan  # when the user try to use an ancient version of a tool on
555eefee25Smacallan  # a file that requires a minimum version.  In this case we
565eefee25Smacallan  # we should proceed has if the program had been absent, or
575eefee25Smacallan  # if --run hadn't been passed.
585eefee25Smacallan  if test $? = 63; then
595eefee25Smacallan    run=:
605eefee25Smacallan    msg="probably too old"
615eefee25Smacallan  fi
625eefee25Smacallan  ;;
635eefee25Smacallan
645eefee25Smacallan  -h|--h|--he|--hel|--help)
655eefee25Smacallan    echo "\
665eefee25Smacallan$0 [OPTION]... PROGRAM [ARGUMENT]...
675eefee25Smacallan
685eefee25SmacallanHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
695eefee25Smacallanerror status if there is no known handling for PROGRAM.
705eefee25Smacallan
715eefee25SmacallanOptions:
725eefee25Smacallan  -h, --help      display this help and exit
735eefee25Smacallan  -v, --version   output version information and exit
745eefee25Smacallan  --run           try to run the given command, and emulate it if it fails
755eefee25Smacallan
765eefee25SmacallanSupported PROGRAM values:
775eefee25Smacallan  aclocal      touch file \`aclocal.m4'
785eefee25Smacallan  autoconf     touch file \`configure'
795eefee25Smacallan  autoheader   touch file \`config.h.in'
805eefee25Smacallan  automake     touch all \`Makefile.in' files
815eefee25Smacallan  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
825eefee25Smacallan  flex         create \`lex.yy.c', if possible, from existing .c
835eefee25Smacallan  help2man     touch the output file
845eefee25Smacallan  lex          create \`lex.yy.c', if possible, from existing .c
855eefee25Smacallan  makeinfo     touch the output file
865eefee25Smacallan  tar          try tar, gnutar, gtar, then tar without non-portable flags
875eefee25Smacallan  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
885eefee25Smacallan
895eefee25SmacallanSend bug reports to <bug-automake@gnu.org>."
905eefee25Smacallan    exit $?
915eefee25Smacallan    ;;
925eefee25Smacallan
935eefee25Smacallan  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
945eefee25Smacallan    echo "missing $scriptversion (GNU Automake)"
955eefee25Smacallan    exit $?
965eefee25Smacallan    ;;
975eefee25Smacallan
985eefee25Smacallan  -*)
995eefee25Smacallan    echo 1>&2 "$0: Unknown \`$1' option"
1005eefee25Smacallan    echo 1>&2 "Try \`$0 --help' for more information"
1015eefee25Smacallan    exit 1
1025eefee25Smacallan    ;;
1035eefee25Smacallan
1045eefee25Smacallanesac
1055eefee25Smacallan
1065eefee25Smacallan# Now exit if we have it, but it failed.  Also exit now if we
1075eefee25Smacallan# don't have it and --version was passed (most likely to detect
1085eefee25Smacallan# the program).
1095eefee25Smacallancase "$1" in
1105eefee25Smacallan  lex|yacc)
1115eefee25Smacallan    # Not GNU programs, they don't have --version.
1125eefee25Smacallan    ;;
1135eefee25Smacallan
1145eefee25Smacallan  tar)
1155eefee25Smacallan    if test -n "$run"; then
1165eefee25Smacallan       echo 1>&2 "ERROR: \`tar' requires --run"
1175eefee25Smacallan       exit 1
1185eefee25Smacallan    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1195eefee25Smacallan       exit 1
1205eefee25Smacallan    fi
1215eefee25Smacallan    ;;
1225eefee25Smacallan
1235eefee25Smacallan  *)
1245eefee25Smacallan    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1255eefee25Smacallan       # We have it, but it failed.
1265eefee25Smacallan       exit 1
1275eefee25Smacallan    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1285eefee25Smacallan       # Could not run --version or --help.  This is probably someone
1295eefee25Smacallan       # running `$TOOL --version' or `$TOOL --help' to check whether
1305eefee25Smacallan       # $TOOL exists and not knowing $TOOL uses missing.
1315eefee25Smacallan       exit 1
1325eefee25Smacallan    fi
1335eefee25Smacallan    ;;
1345eefee25Smacallanesac
1355eefee25Smacallan
1365eefee25Smacallan# If it does not exist, or fails to run (possibly an outdated version),
1375eefee25Smacallan# try to emulate it.
1385eefee25Smacallancase "$1" in
1395eefee25Smacallan  aclocal*)
1405eefee25Smacallan    echo 1>&2 "\
1415eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
1425eefee25Smacallan         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1435eefee25Smacallan         to install the \`Automake' and \`Perl' packages.  Grab them from
1445eefee25Smacallan         any GNU archive site."
1455eefee25Smacallan    touch aclocal.m4
1465eefee25Smacallan    ;;
1475eefee25Smacallan
1485eefee25Smacallan  autoconf)
1495eefee25Smacallan    echo 1>&2 "\
1505eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
1515eefee25Smacallan         you modified \`${configure_ac}'.  You might want to install the
1525eefee25Smacallan         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1535eefee25Smacallan         archive site."
1545eefee25Smacallan    touch configure
1555eefee25Smacallan    ;;
1565eefee25Smacallan
1575eefee25Smacallan  autoheader)
1585eefee25Smacallan    echo 1>&2 "\
1595eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
1605eefee25Smacallan         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1615eefee25Smacallan         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1625eefee25Smacallan         from any GNU archive site."
1635eefee25Smacallan    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1645eefee25Smacallan    test -z "$files" && files="config.h"
1655eefee25Smacallan    touch_files=
1665eefee25Smacallan    for f in $files; do
1675eefee25Smacallan      case "$f" in
1685eefee25Smacallan      *:*) touch_files="$touch_files "`echo "$f" |
1695eefee25Smacallan				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1705eefee25Smacallan      *) touch_files="$touch_files $f.in";;
1715eefee25Smacallan      esac
1725eefee25Smacallan    done
1735eefee25Smacallan    touch $touch_files
1745eefee25Smacallan    ;;
1755eefee25Smacallan
1765eefee25Smacallan  automake*)
1775eefee25Smacallan    echo 1>&2 "\
1785eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
1795eefee25Smacallan         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1805eefee25Smacallan         You might want to install the \`Automake' and \`Perl' packages.
1815eefee25Smacallan         Grab them from any GNU archive site."
1825eefee25Smacallan    find . -type f -name Makefile.am -print |
1835eefee25Smacallan	   sed 's/\.am$/.in/' |
1845eefee25Smacallan	   while read f; do touch "$f"; done
1855eefee25Smacallan    ;;
1865eefee25Smacallan
1875eefee25Smacallan  autom4te)
1885eefee25Smacallan    echo 1>&2 "\
1895eefee25SmacallanWARNING: \`$1' is needed, but is $msg.
1905eefee25Smacallan         You might have modified some files without having the
1915eefee25Smacallan         proper tools for further handling them.
1925eefee25Smacallan         You can get \`$1' as part of \`Autoconf' from any GNU
1935eefee25Smacallan         archive site."
1945eefee25Smacallan
1955eefee25Smacallan    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
1965eefee25Smacallan    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
1975eefee25Smacallan    if test -f "$file"; then
1985eefee25Smacallan	touch $file
1995eefee25Smacallan    else
2005eefee25Smacallan	test -z "$file" || exec >$file
2015eefee25Smacallan	echo "#! /bin/sh"
2025eefee25Smacallan	echo "# Created by GNU Automake missing as a replacement of"
2035eefee25Smacallan	echo "#  $ $@"
2045eefee25Smacallan	echo "exit 0"
2055eefee25Smacallan	chmod +x $file
2065eefee25Smacallan	exit 1
2075eefee25Smacallan    fi
2085eefee25Smacallan    ;;
2095eefee25Smacallan
2105eefee25Smacallan  bison|yacc)
2115eefee25Smacallan    echo 1>&2 "\
2125eefee25SmacallanWARNING: \`$1' $msg.  You should only need it if
2135eefee25Smacallan         you modified a \`.y' file.  You may need the \`Bison' package
2145eefee25Smacallan         in order for those modifications to take effect.  You can get
2155eefee25Smacallan         \`Bison' from any GNU archive site."
2165eefee25Smacallan    rm -f y.tab.c y.tab.h
2175eefee25Smacallan    if [ $# -ne 1 ]; then
2185eefee25Smacallan        eval LASTARG="\${$#}"
2195eefee25Smacallan	case "$LASTARG" in
2205eefee25Smacallan	*.y)
2215eefee25Smacallan	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2225eefee25Smacallan	    if [ -f "$SRCFILE" ]; then
2235eefee25Smacallan	         cp "$SRCFILE" y.tab.c
2245eefee25Smacallan	    fi
2255eefee25Smacallan	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2265eefee25Smacallan	    if [ -f "$SRCFILE" ]; then
2275eefee25Smacallan	         cp "$SRCFILE" y.tab.h
2285eefee25Smacallan	    fi
2295eefee25Smacallan	  ;;
2305eefee25Smacallan	esac
2315eefee25Smacallan    fi
2325eefee25Smacallan    if [ ! -f y.tab.h ]; then
2335eefee25Smacallan	echo >y.tab.h
2345eefee25Smacallan    fi
2355eefee25Smacallan    if [ ! -f y.tab.c ]; then
2365eefee25Smacallan	echo 'main() { return 0; }' >y.tab.c
2375eefee25Smacallan    fi
2385eefee25Smacallan    ;;
2395eefee25Smacallan
2405eefee25Smacallan  lex|flex)
2415eefee25Smacallan    echo 1>&2 "\
2425eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
2435eefee25Smacallan         you modified a \`.l' file.  You may need the \`Flex' package
2445eefee25Smacallan         in order for those modifications to take effect.  You can get
2455eefee25Smacallan         \`Flex' from any GNU archive site."
2465eefee25Smacallan    rm -f lex.yy.c
2475eefee25Smacallan    if [ $# -ne 1 ]; then
2485eefee25Smacallan        eval LASTARG="\${$#}"
2495eefee25Smacallan	case "$LASTARG" in
2505eefee25Smacallan	*.l)
2515eefee25Smacallan	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2525eefee25Smacallan	    if [ -f "$SRCFILE" ]; then
2535eefee25Smacallan	         cp "$SRCFILE" lex.yy.c
2545eefee25Smacallan	    fi
2555eefee25Smacallan	  ;;
2565eefee25Smacallan	esac
2575eefee25Smacallan    fi
2585eefee25Smacallan    if [ ! -f lex.yy.c ]; then
2595eefee25Smacallan	echo 'main() { return 0; }' >lex.yy.c
2605eefee25Smacallan    fi
2615eefee25Smacallan    ;;
2625eefee25Smacallan
2635eefee25Smacallan  help2man)
2645eefee25Smacallan    echo 1>&2 "\
2655eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
2665eefee25Smacallan	 you modified a dependency of a manual page.  You may need the
2675eefee25Smacallan	 \`Help2man' package in order for those modifications to take
2685eefee25Smacallan	 effect.  You can get \`Help2man' from any GNU archive site."
2695eefee25Smacallan
2705eefee25Smacallan    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2715eefee25Smacallan    if test -z "$file"; then
2725eefee25Smacallan	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2735eefee25Smacallan    fi
2745eefee25Smacallan    if [ -f "$file" ]; then
2755eefee25Smacallan	touch $file
2765eefee25Smacallan    else
2775eefee25Smacallan	test -z "$file" || exec >$file
2785eefee25Smacallan	echo ".ab help2man is required to generate this page"
2795eefee25Smacallan	exit 1
2805eefee25Smacallan    fi
2815eefee25Smacallan    ;;
2825eefee25Smacallan
2835eefee25Smacallan  makeinfo)
2845eefee25Smacallan    echo 1>&2 "\
2855eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
2865eefee25Smacallan         you modified a \`.texi' or \`.texinfo' file, or any other file
2875eefee25Smacallan         indirectly affecting the aspect of the manual.  The spurious
2885eefee25Smacallan         call might also be the consequence of using a buggy \`make' (AIX,
2895eefee25Smacallan         DU, IRIX).  You might want to install the \`Texinfo' package or
2905eefee25Smacallan         the \`GNU make' package.  Grab either from any GNU archive site."
2915eefee25Smacallan    # The file to touch is that specified with -o ...
2925eefee25Smacallan    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2935eefee25Smacallan    if test -z "$file"; then
2945eefee25Smacallan      # ... or it is the one specified with @setfilename ...
2955eefee25Smacallan      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2965eefee25Smacallan      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
2975eefee25Smacallan      # ... or it is derived from the source name (dir/f.texi becomes f.info)
2985eefee25Smacallan      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
2995eefee25Smacallan    fi
3005eefee25Smacallan    # If the file does not exist, the user really needs makeinfo;
3015eefee25Smacallan    # let's fail without touching anything.
3025eefee25Smacallan    test -f $file || exit 1
3035eefee25Smacallan    touch $file
3045eefee25Smacallan    ;;
3055eefee25Smacallan
3065eefee25Smacallan  tar)
3075eefee25Smacallan    shift
3085eefee25Smacallan
3095eefee25Smacallan    # We have already tried tar in the generic part.
3105eefee25Smacallan    # Look for gnutar/gtar before invocation to avoid ugly error
3115eefee25Smacallan    # messages.
3125eefee25Smacallan    if (gnutar --version > /dev/null 2>&1); then
3135eefee25Smacallan       gnutar "$@" && exit 0
3145eefee25Smacallan    fi
3155eefee25Smacallan    if (gtar --version > /dev/null 2>&1); then
3165eefee25Smacallan       gtar "$@" && exit 0
3175eefee25Smacallan    fi
3185eefee25Smacallan    firstarg="$1"
3195eefee25Smacallan    if shift; then
3205eefee25Smacallan	case "$firstarg" in
3215eefee25Smacallan	*o*)
3225eefee25Smacallan	    firstarg=`echo "$firstarg" | sed s/o//`
3235eefee25Smacallan	    tar "$firstarg" "$@" && exit 0
3245eefee25Smacallan	    ;;
3255eefee25Smacallan	esac
3265eefee25Smacallan	case "$firstarg" in
3275eefee25Smacallan	*h*)
3285eefee25Smacallan	    firstarg=`echo "$firstarg" | sed s/h//`
3295eefee25Smacallan	    tar "$firstarg" "$@" && exit 0
3305eefee25Smacallan	    ;;
3315eefee25Smacallan	esac
3325eefee25Smacallan    fi
3335eefee25Smacallan
3345eefee25Smacallan    echo 1>&2 "\
3355eefee25SmacallanWARNING: I can't seem to be able to run \`tar' with the given arguments.
3365eefee25Smacallan         You may want to install GNU tar or Free paxutils, or check the
3375eefee25Smacallan         command line arguments."
3385eefee25Smacallan    exit 1
3395eefee25Smacallan    ;;
3405eefee25Smacallan
3415eefee25Smacallan  *)
3425eefee25Smacallan    echo 1>&2 "\
3435eefee25SmacallanWARNING: \`$1' is needed, and is $msg.
3445eefee25Smacallan         You might have modified some files without having the
3455eefee25Smacallan         proper tools for further handling them.  Check the \`README' file,
3465eefee25Smacallan         it often tells you about the needed prerequisites for installing
3475eefee25Smacallan         this package.  You may also peek at any GNU archive site, in case
3485eefee25Smacallan         some other package would contain this missing \`$1' program."
3495eefee25Smacallan    exit 1
3505eefee25Smacallan    ;;
3515eefee25Smacallanesac
3525eefee25Smacallan
3535eefee25Smacallanexit 0
3545eefee25Smacallan
3555eefee25Smacallan# Local variables:
3565eefee25Smacallan# eval: (add-hook 'write-file-hooks 'time-stamp)
3575eefee25Smacallan# time-stamp-start: "scriptversion="
3585eefee25Smacallan# time-stamp-format: "%:y-%02m-%02d.%02H"
3595eefee25Smacallan# time-stamp-end: "$"
3605eefee25Smacallan# End:
361