missing revision 62ab96ba
15eefee25Smacallan#! /bin/sh
25eefee25Smacallan# Common stub for a few missing GNU programs while installing.
35eefee25Smacallan
462ab96baSmrgscriptversion=2006-05-10.23
55eefee25Smacallan
662ab96baSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
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=:
3662ab96baSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3762ab96baSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
385eefee25Smacallan
395eefee25Smacallan# In the cases where this matters, `missing' is being run in the
405eefee25Smacallan# srcdir already.
415eefee25Smacallanif test -f configure.ac; then
425eefee25Smacallan  configure_ac=configure.ac
435eefee25Smacallanelse
445eefee25Smacallan  configure_ac=configure.in
455eefee25Smacallanfi
465eefee25Smacallan
475eefee25Smacallanmsg="missing on your system"
485eefee25Smacallan
4962ab96baSmrgcase $1 in
505eefee25Smacallan--run)
515eefee25Smacallan  # Try to run requested program, and just exit if it succeeds.
525eefee25Smacallan  run=
535eefee25Smacallan  shift
545eefee25Smacallan  "$@" && exit 0
555eefee25Smacallan  # Exit code 63 means version mismatch.  This often happens
565eefee25Smacallan  # when the user try to use an ancient version of a tool on
575eefee25Smacallan  # a file that requires a minimum version.  In this case we
585eefee25Smacallan  # we should proceed has if the program had been absent, or
595eefee25Smacallan  # if --run hadn't been passed.
605eefee25Smacallan  if test $? = 63; then
615eefee25Smacallan    run=:
625eefee25Smacallan    msg="probably too old"
635eefee25Smacallan  fi
645eefee25Smacallan  ;;
655eefee25Smacallan
665eefee25Smacallan  -h|--h|--he|--hel|--help)
675eefee25Smacallan    echo "\
685eefee25Smacallan$0 [OPTION]... PROGRAM [ARGUMENT]...
695eefee25Smacallan
705eefee25SmacallanHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
715eefee25Smacallanerror status if there is no known handling for PROGRAM.
725eefee25Smacallan
735eefee25SmacallanOptions:
745eefee25Smacallan  -h, --help      display this help and exit
755eefee25Smacallan  -v, --version   output version information and exit
765eefee25Smacallan  --run           try to run the given command, and emulate it if it fails
775eefee25Smacallan
785eefee25SmacallanSupported PROGRAM values:
795eefee25Smacallan  aclocal      touch file \`aclocal.m4'
805eefee25Smacallan  autoconf     touch file \`configure'
815eefee25Smacallan  autoheader   touch file \`config.h.in'
8262ab96baSmrg  autom4te     touch the output file, or create a stub one
835eefee25Smacallan  automake     touch all \`Makefile.in' files
845eefee25Smacallan  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
855eefee25Smacallan  flex         create \`lex.yy.c', if possible, from existing .c
865eefee25Smacallan  help2man     touch the output file
875eefee25Smacallan  lex          create \`lex.yy.c', if possible, from existing .c
885eefee25Smacallan  makeinfo     touch the output file
895eefee25Smacallan  tar          try tar, gnutar, gtar, then tar without non-portable flags
905eefee25Smacallan  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
915eefee25Smacallan
925eefee25SmacallanSend bug reports to <bug-automake@gnu.org>."
935eefee25Smacallan    exit $?
945eefee25Smacallan    ;;
955eefee25Smacallan
965eefee25Smacallan  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
975eefee25Smacallan    echo "missing $scriptversion (GNU Automake)"
985eefee25Smacallan    exit $?
995eefee25Smacallan    ;;
1005eefee25Smacallan
1015eefee25Smacallan  -*)
1025eefee25Smacallan    echo 1>&2 "$0: Unknown \`$1' option"
1035eefee25Smacallan    echo 1>&2 "Try \`$0 --help' for more information"
1045eefee25Smacallan    exit 1
1055eefee25Smacallan    ;;
1065eefee25Smacallan
1075eefee25Smacallanesac
1085eefee25Smacallan
1095eefee25Smacallan# Now exit if we have it, but it failed.  Also exit now if we
1105eefee25Smacallan# don't have it and --version was passed (most likely to detect
1115eefee25Smacallan# the program).
11262ab96baSmrgcase $1 in
1135eefee25Smacallan  lex|yacc)
1145eefee25Smacallan    # Not GNU programs, they don't have --version.
1155eefee25Smacallan    ;;
1165eefee25Smacallan
1175eefee25Smacallan  tar)
1185eefee25Smacallan    if test -n "$run"; then
1195eefee25Smacallan       echo 1>&2 "ERROR: \`tar' requires --run"
1205eefee25Smacallan       exit 1
1215eefee25Smacallan    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1225eefee25Smacallan       exit 1
1235eefee25Smacallan    fi
1245eefee25Smacallan    ;;
1255eefee25Smacallan
1265eefee25Smacallan  *)
1275eefee25Smacallan    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1285eefee25Smacallan       # We have it, but it failed.
1295eefee25Smacallan       exit 1
1305eefee25Smacallan    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1315eefee25Smacallan       # Could not run --version or --help.  This is probably someone
1325eefee25Smacallan       # running `$TOOL --version' or `$TOOL --help' to check whether
1335eefee25Smacallan       # $TOOL exists and not knowing $TOOL uses missing.
1345eefee25Smacallan       exit 1
1355eefee25Smacallan    fi
1365eefee25Smacallan    ;;
1375eefee25Smacallanesac
1385eefee25Smacallan
1395eefee25Smacallan# If it does not exist, or fails to run (possibly an outdated version),
1405eefee25Smacallan# try to emulate it.
14162ab96baSmrgcase $1 in
1425eefee25Smacallan  aclocal*)
1435eefee25Smacallan    echo 1>&2 "\
1445eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
1455eefee25Smacallan         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1465eefee25Smacallan         to install the \`Automake' and \`Perl' packages.  Grab them from
1475eefee25Smacallan         any GNU archive site."
1485eefee25Smacallan    touch aclocal.m4
1495eefee25Smacallan    ;;
1505eefee25Smacallan
1515eefee25Smacallan  autoconf)
1525eefee25Smacallan    echo 1>&2 "\
1535eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
1545eefee25Smacallan         you modified \`${configure_ac}'.  You might want to install the
1555eefee25Smacallan         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1565eefee25Smacallan         archive site."
1575eefee25Smacallan    touch configure
1585eefee25Smacallan    ;;
1595eefee25Smacallan
1605eefee25Smacallan  autoheader)
1615eefee25Smacallan    echo 1>&2 "\
1625eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
1635eefee25Smacallan         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1645eefee25Smacallan         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1655eefee25Smacallan         from any GNU archive site."
1665eefee25Smacallan    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1675eefee25Smacallan    test -z "$files" && files="config.h"
1685eefee25Smacallan    touch_files=
1695eefee25Smacallan    for f in $files; do
17062ab96baSmrg      case $f in
1715eefee25Smacallan      *:*) touch_files="$touch_files "`echo "$f" |
1725eefee25Smacallan				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1735eefee25Smacallan      *) touch_files="$touch_files $f.in";;
1745eefee25Smacallan      esac
1755eefee25Smacallan    done
1765eefee25Smacallan    touch $touch_files
1775eefee25Smacallan    ;;
1785eefee25Smacallan
1795eefee25Smacallan  automake*)
1805eefee25Smacallan    echo 1>&2 "\
1815eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
1825eefee25Smacallan         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1835eefee25Smacallan         You might want to install the \`Automake' and \`Perl' packages.
1845eefee25Smacallan         Grab them from any GNU archive site."
1855eefee25Smacallan    find . -type f -name Makefile.am -print |
1865eefee25Smacallan	   sed 's/\.am$/.in/' |
1875eefee25Smacallan	   while read f; do touch "$f"; done
1885eefee25Smacallan    ;;
1895eefee25Smacallan
1905eefee25Smacallan  autom4te)
1915eefee25Smacallan    echo 1>&2 "\
1925eefee25SmacallanWARNING: \`$1' is needed, but is $msg.
1935eefee25Smacallan         You might have modified some files without having the
1945eefee25Smacallan         proper tools for further handling them.
1955eefee25Smacallan         You can get \`$1' as part of \`Autoconf' from any GNU
1965eefee25Smacallan         archive site."
1975eefee25Smacallan
19862ab96baSmrg    file=`echo "$*" | sed -n "$sed_output"`
19962ab96baSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2005eefee25Smacallan    if test -f "$file"; then
2015eefee25Smacallan	touch $file
2025eefee25Smacallan    else
2035eefee25Smacallan	test -z "$file" || exec >$file
2045eefee25Smacallan	echo "#! /bin/sh"
2055eefee25Smacallan	echo "# Created by GNU Automake missing as a replacement of"
2065eefee25Smacallan	echo "#  $ $@"
2075eefee25Smacallan	echo "exit 0"
2085eefee25Smacallan	chmod +x $file
2095eefee25Smacallan	exit 1
2105eefee25Smacallan    fi
2115eefee25Smacallan    ;;
2125eefee25Smacallan
2135eefee25Smacallan  bison|yacc)
2145eefee25Smacallan    echo 1>&2 "\
2155eefee25SmacallanWARNING: \`$1' $msg.  You should only need it if
2165eefee25Smacallan         you modified a \`.y' file.  You may need the \`Bison' package
2175eefee25Smacallan         in order for those modifications to take effect.  You can get
2185eefee25Smacallan         \`Bison' from any GNU archive site."
2195eefee25Smacallan    rm -f y.tab.c y.tab.h
22062ab96baSmrg    if test $# -ne 1; then
2215eefee25Smacallan        eval LASTARG="\${$#}"
22262ab96baSmrg	case $LASTARG in
2235eefee25Smacallan	*.y)
2245eefee25Smacallan	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22562ab96baSmrg	    if test -f "$SRCFILE"; then
2265eefee25Smacallan	         cp "$SRCFILE" y.tab.c
2275eefee25Smacallan	    fi
2285eefee25Smacallan	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22962ab96baSmrg	    if test -f "$SRCFILE"; then
2305eefee25Smacallan	         cp "$SRCFILE" y.tab.h
2315eefee25Smacallan	    fi
2325eefee25Smacallan	  ;;
2335eefee25Smacallan	esac
2345eefee25Smacallan    fi
23562ab96baSmrg    if test ! -f y.tab.h; then
2365eefee25Smacallan	echo >y.tab.h
2375eefee25Smacallan    fi
23862ab96baSmrg    if test ! -f y.tab.c; then
2395eefee25Smacallan	echo 'main() { return 0; }' >y.tab.c
2405eefee25Smacallan    fi
2415eefee25Smacallan    ;;
2425eefee25Smacallan
2435eefee25Smacallan  lex|flex)
2445eefee25Smacallan    echo 1>&2 "\
2455eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
2465eefee25Smacallan         you modified a \`.l' file.  You may need the \`Flex' package
2475eefee25Smacallan         in order for those modifications to take effect.  You can get
2485eefee25Smacallan         \`Flex' from any GNU archive site."
2495eefee25Smacallan    rm -f lex.yy.c
25062ab96baSmrg    if test $# -ne 1; then
2515eefee25Smacallan        eval LASTARG="\${$#}"
25262ab96baSmrg	case $LASTARG in
2535eefee25Smacallan	*.l)
2545eefee25Smacallan	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25562ab96baSmrg	    if test -f "$SRCFILE"; then
2565eefee25Smacallan	         cp "$SRCFILE" lex.yy.c
2575eefee25Smacallan	    fi
2585eefee25Smacallan	  ;;
2595eefee25Smacallan	esac
2605eefee25Smacallan    fi
26162ab96baSmrg    if test ! -f lex.yy.c; then
2625eefee25Smacallan	echo 'main() { return 0; }' >lex.yy.c
2635eefee25Smacallan    fi
2645eefee25Smacallan    ;;
2655eefee25Smacallan
2665eefee25Smacallan  help2man)
2675eefee25Smacallan    echo 1>&2 "\
2685eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
2695eefee25Smacallan	 you modified a dependency of a manual page.  You may need the
2705eefee25Smacallan	 \`Help2man' package in order for those modifications to take
2715eefee25Smacallan	 effect.  You can get \`Help2man' from any GNU archive site."
2725eefee25Smacallan
27362ab96baSmrg    file=`echo "$*" | sed -n "$sed_output"`
27462ab96baSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
27562ab96baSmrg    if test -f "$file"; then
2765eefee25Smacallan	touch $file
2775eefee25Smacallan    else
2785eefee25Smacallan	test -z "$file" || exec >$file
2795eefee25Smacallan	echo ".ab help2man is required to generate this page"
2805eefee25Smacallan	exit 1
2815eefee25Smacallan    fi
2825eefee25Smacallan    ;;
2835eefee25Smacallan
2845eefee25Smacallan  makeinfo)
2855eefee25Smacallan    echo 1>&2 "\
2865eefee25SmacallanWARNING: \`$1' is $msg.  You should only need it if
2875eefee25Smacallan         you modified a \`.texi' or \`.texinfo' file, or any other file
2885eefee25Smacallan         indirectly affecting the aspect of the manual.  The spurious
2895eefee25Smacallan         call might also be the consequence of using a buggy \`make' (AIX,
2905eefee25Smacallan         DU, IRIX).  You might want to install the \`Texinfo' package or
2915eefee25Smacallan         the \`GNU make' package.  Grab either from any GNU archive site."
2925eefee25Smacallan    # The file to touch is that specified with -o ...
29362ab96baSmrg    file=`echo "$*" | sed -n "$sed_output"`
29462ab96baSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2955eefee25Smacallan    if test -z "$file"; then
2965eefee25Smacallan      # ... or it is the one specified with @setfilename ...
2975eefee25Smacallan      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29862ab96baSmrg      file=`sed -n '
29962ab96baSmrg	/^@setfilename/{
30062ab96baSmrg	  s/.* \([^ ]*\) *$/\1/
30162ab96baSmrg	  p
30262ab96baSmrg	  q
30362ab96baSmrg	}' $infile`
3045eefee25Smacallan      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3055eefee25Smacallan      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3065eefee25Smacallan    fi
3075eefee25Smacallan    # If the file does not exist, the user really needs makeinfo;
3085eefee25Smacallan    # let's fail without touching anything.
3095eefee25Smacallan    test -f $file || exit 1
3105eefee25Smacallan    touch $file
3115eefee25Smacallan    ;;
3125eefee25Smacallan
3135eefee25Smacallan  tar)
3145eefee25Smacallan    shift
3155eefee25Smacallan
3165eefee25Smacallan    # We have already tried tar in the generic part.
3175eefee25Smacallan    # Look for gnutar/gtar before invocation to avoid ugly error
3185eefee25Smacallan    # messages.
3195eefee25Smacallan    if (gnutar --version > /dev/null 2>&1); then
3205eefee25Smacallan       gnutar "$@" && exit 0
3215eefee25Smacallan    fi
3225eefee25Smacallan    if (gtar --version > /dev/null 2>&1); then
3235eefee25Smacallan       gtar "$@" && exit 0
3245eefee25Smacallan    fi
3255eefee25Smacallan    firstarg="$1"
3265eefee25Smacallan    if shift; then
32762ab96baSmrg	case $firstarg in
3285eefee25Smacallan	*o*)
3295eefee25Smacallan	    firstarg=`echo "$firstarg" | sed s/o//`
3305eefee25Smacallan	    tar "$firstarg" "$@" && exit 0
3315eefee25Smacallan	    ;;
3325eefee25Smacallan	esac
33362ab96baSmrg	case $firstarg in
3345eefee25Smacallan	*h*)
3355eefee25Smacallan	    firstarg=`echo "$firstarg" | sed s/h//`
3365eefee25Smacallan	    tar "$firstarg" "$@" && exit 0
3375eefee25Smacallan	    ;;
3385eefee25Smacallan	esac
3395eefee25Smacallan    fi
3405eefee25Smacallan
3415eefee25Smacallan    echo 1>&2 "\
3425eefee25SmacallanWARNING: I can't seem to be able to run \`tar' with the given arguments.
3435eefee25Smacallan         You may want to install GNU tar or Free paxutils, or check the
3445eefee25Smacallan         command line arguments."
3455eefee25Smacallan    exit 1
3465eefee25Smacallan    ;;
3475eefee25Smacallan
3485eefee25Smacallan  *)
3495eefee25Smacallan    echo 1>&2 "\
3505eefee25SmacallanWARNING: \`$1' is needed, and is $msg.
3515eefee25Smacallan         You might have modified some files without having the
3525eefee25Smacallan         proper tools for further handling them.  Check the \`README' file,
3535eefee25Smacallan         it often tells you about the needed prerequisites for installing
3545eefee25Smacallan         this package.  You may also peek at any GNU archive site, in case
3555eefee25Smacallan         some other package would contain this missing \`$1' program."
3565eefee25Smacallan    exit 1
3575eefee25Smacallan    ;;
3585eefee25Smacallanesac
3595eefee25Smacallan
3605eefee25Smacallanexit 0
3615eefee25Smacallan
3625eefee25Smacallan# Local variables:
3635eefee25Smacallan# eval: (add-hook 'write-file-hooks 'time-stamp)
3645eefee25Smacallan# time-stamp-start: "scriptversion="
3655eefee25Smacallan# time-stamp-format: "%:y-%02m-%02d.%02H"
3665eefee25Smacallan# time-stamp-end: "$"
3675eefee25Smacallan# End:
368