missing revision 9027f4a0
19027f4a0Smrg#! /bin/sh
29027f4a0Smrg# Common stub for a few missing GNU programs while installing.
39027f4a0Smrg
49027f4a0Smrgscriptversion=2005-06-08.21
59027f4a0Smrg
69027f4a0Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
79027f4a0Smrg#   Free Software Foundation, Inc.
89027f4a0Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
99027f4a0Smrg
109027f4a0Smrg# This program is free software; you can redistribute it and/or modify
119027f4a0Smrg# it under the terms of the GNU General Public License as published by
129027f4a0Smrg# the Free Software Foundation; either version 2, or (at your option)
139027f4a0Smrg# any later version.
149027f4a0Smrg
159027f4a0Smrg# This program is distributed in the hope that it will be useful,
169027f4a0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
179027f4a0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
189027f4a0Smrg# GNU General Public License for more details.
199027f4a0Smrg
209027f4a0Smrg# You should have received a copy of the GNU General Public License
219027f4a0Smrg# along with this program; if not, write to the Free Software
229027f4a0Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
239027f4a0Smrg# 02110-1301, USA.
249027f4a0Smrg
259027f4a0Smrg# As a special exception to the GNU General Public License, if you
269027f4a0Smrg# distribute this file as part of a program that contains a
279027f4a0Smrg# configuration script generated by Autoconf, you may include it under
289027f4a0Smrg# the same distribution terms that you use for the rest of that program.
299027f4a0Smrg
309027f4a0Smrgif test $# -eq 0; then
319027f4a0Smrg  echo 1>&2 "Try \`$0 --help' for more information"
329027f4a0Smrg  exit 1
339027f4a0Smrgfi
349027f4a0Smrg
359027f4a0Smrgrun=:
369027f4a0Smrg
379027f4a0Smrg# In the cases where this matters, `missing' is being run in the
389027f4a0Smrg# srcdir already.
399027f4a0Smrgif test -f configure.ac; then
409027f4a0Smrg  configure_ac=configure.ac
419027f4a0Smrgelse
429027f4a0Smrg  configure_ac=configure.in
439027f4a0Smrgfi
449027f4a0Smrg
459027f4a0Smrgmsg="missing on your system"
469027f4a0Smrg
479027f4a0Smrgcase "$1" in
489027f4a0Smrg--run)
499027f4a0Smrg  # Try to run requested program, and just exit if it succeeds.
509027f4a0Smrg  run=
519027f4a0Smrg  shift
529027f4a0Smrg  "$@" && exit 0
539027f4a0Smrg  # Exit code 63 means version mismatch.  This often happens
549027f4a0Smrg  # when the user try to use an ancient version of a tool on
559027f4a0Smrg  # a file that requires a minimum version.  In this case we
569027f4a0Smrg  # we should proceed has if the program had been absent, or
579027f4a0Smrg  # if --run hadn't been passed.
589027f4a0Smrg  if test $? = 63; then
599027f4a0Smrg    run=:
609027f4a0Smrg    msg="probably too old"
619027f4a0Smrg  fi
629027f4a0Smrg  ;;
639027f4a0Smrg
649027f4a0Smrg  -h|--h|--he|--hel|--help)
659027f4a0Smrg    echo "\
669027f4a0Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
679027f4a0Smrg
689027f4a0SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
699027f4a0Smrgerror status if there is no known handling for PROGRAM.
709027f4a0Smrg
719027f4a0SmrgOptions:
729027f4a0Smrg  -h, --help      display this help and exit
739027f4a0Smrg  -v, --version   output version information and exit
749027f4a0Smrg  --run           try to run the given command, and emulate it if it fails
759027f4a0Smrg
769027f4a0SmrgSupported PROGRAM values:
779027f4a0Smrg  aclocal      touch file \`aclocal.m4'
789027f4a0Smrg  autoconf     touch file \`configure'
799027f4a0Smrg  autoheader   touch file \`config.h.in'
809027f4a0Smrg  automake     touch all \`Makefile.in' files
819027f4a0Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
829027f4a0Smrg  flex         create \`lex.yy.c', if possible, from existing .c
839027f4a0Smrg  help2man     touch the output file
849027f4a0Smrg  lex          create \`lex.yy.c', if possible, from existing .c
859027f4a0Smrg  makeinfo     touch the output file
869027f4a0Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
879027f4a0Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
889027f4a0Smrg
899027f4a0SmrgSend bug reports to <bug-automake@gnu.org>."
909027f4a0Smrg    exit $?
919027f4a0Smrg    ;;
929027f4a0Smrg
939027f4a0Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
949027f4a0Smrg    echo "missing $scriptversion (GNU Automake)"
959027f4a0Smrg    exit $?
969027f4a0Smrg    ;;
979027f4a0Smrg
989027f4a0Smrg  -*)
999027f4a0Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1009027f4a0Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1019027f4a0Smrg    exit 1
1029027f4a0Smrg    ;;
1039027f4a0Smrg
1049027f4a0Smrgesac
1059027f4a0Smrg
1069027f4a0Smrg# Now exit if we have it, but it failed.  Also exit now if we
1079027f4a0Smrg# don't have it and --version was passed (most likely to detect
1089027f4a0Smrg# the program).
1099027f4a0Smrgcase "$1" in
1109027f4a0Smrg  lex|yacc)
1119027f4a0Smrg    # Not GNU programs, they don't have --version.
1129027f4a0Smrg    ;;
1139027f4a0Smrg
1149027f4a0Smrg  tar)
1159027f4a0Smrg    if test -n "$run"; then
1169027f4a0Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1179027f4a0Smrg       exit 1
1189027f4a0Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1199027f4a0Smrg       exit 1
1209027f4a0Smrg    fi
1219027f4a0Smrg    ;;
1229027f4a0Smrg
1239027f4a0Smrg  *)
1249027f4a0Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1259027f4a0Smrg       # We have it, but it failed.
1269027f4a0Smrg       exit 1
1279027f4a0Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1289027f4a0Smrg       # Could not run --version or --help.  This is probably someone
1299027f4a0Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1309027f4a0Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1319027f4a0Smrg       exit 1
1329027f4a0Smrg    fi
1339027f4a0Smrg    ;;
1349027f4a0Smrgesac
1359027f4a0Smrg
1369027f4a0Smrg# If it does not exist, or fails to run (possibly an outdated version),
1379027f4a0Smrg# try to emulate it.
1389027f4a0Smrgcase "$1" in
1399027f4a0Smrg  aclocal*)
1409027f4a0Smrg    echo 1>&2 "\
1419027f4a0SmrgWARNING: \`$1' is $msg.  You should only need it if
1429027f4a0Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1439027f4a0Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1449027f4a0Smrg         any GNU archive site."
1459027f4a0Smrg    touch aclocal.m4
1469027f4a0Smrg    ;;
1479027f4a0Smrg
1489027f4a0Smrg  autoconf)
1499027f4a0Smrg    echo 1>&2 "\
1509027f4a0SmrgWARNING: \`$1' is $msg.  You should only need it if
1519027f4a0Smrg         you modified \`${configure_ac}'.  You might want to install the
1529027f4a0Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1539027f4a0Smrg         archive site."
1549027f4a0Smrg    touch configure
1559027f4a0Smrg    ;;
1569027f4a0Smrg
1579027f4a0Smrg  autoheader)
1589027f4a0Smrg    echo 1>&2 "\
1599027f4a0SmrgWARNING: \`$1' is $msg.  You should only need it if
1609027f4a0Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1619027f4a0Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1629027f4a0Smrg         from any GNU archive site."
1639027f4a0Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1649027f4a0Smrg    test -z "$files" && files="config.h"
1659027f4a0Smrg    touch_files=
1669027f4a0Smrg    for f in $files; do
1679027f4a0Smrg      case "$f" in
1689027f4a0Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1699027f4a0Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1709027f4a0Smrg      *) touch_files="$touch_files $f.in";;
1719027f4a0Smrg      esac
1729027f4a0Smrg    done
1739027f4a0Smrg    touch $touch_files
1749027f4a0Smrg    ;;
1759027f4a0Smrg
1769027f4a0Smrg  automake*)
1779027f4a0Smrg    echo 1>&2 "\
1789027f4a0SmrgWARNING: \`$1' is $msg.  You should only need it if
1799027f4a0Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1809027f4a0Smrg         You might want to install the \`Automake' and \`Perl' packages.
1819027f4a0Smrg         Grab them from any GNU archive site."
1829027f4a0Smrg    find . -type f -name Makefile.am -print |
1839027f4a0Smrg	   sed 's/\.am$/.in/' |
1849027f4a0Smrg	   while read f; do touch "$f"; done
1859027f4a0Smrg    ;;
1869027f4a0Smrg
1879027f4a0Smrg  autom4te)
1889027f4a0Smrg    echo 1>&2 "\
1899027f4a0SmrgWARNING: \`$1' is needed, but is $msg.
1909027f4a0Smrg         You might have modified some files without having the
1919027f4a0Smrg         proper tools for further handling them.
1929027f4a0Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1939027f4a0Smrg         archive site."
1949027f4a0Smrg
1959027f4a0Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
1969027f4a0Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
1979027f4a0Smrg    if test -f "$file"; then
1989027f4a0Smrg	touch $file
1999027f4a0Smrg    else
2009027f4a0Smrg	test -z "$file" || exec >$file
2019027f4a0Smrg	echo "#! /bin/sh"
2029027f4a0Smrg	echo "# Created by GNU Automake missing as a replacement of"
2039027f4a0Smrg	echo "#  $ $@"
2049027f4a0Smrg	echo "exit 0"
2059027f4a0Smrg	chmod +x $file
2069027f4a0Smrg	exit 1
2079027f4a0Smrg    fi
2089027f4a0Smrg    ;;
2099027f4a0Smrg
2109027f4a0Smrg  bison|yacc)
2119027f4a0Smrg    echo 1>&2 "\
2129027f4a0SmrgWARNING: \`$1' $msg.  You should only need it if
2139027f4a0Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2149027f4a0Smrg         in order for those modifications to take effect.  You can get
2159027f4a0Smrg         \`Bison' from any GNU archive site."
2169027f4a0Smrg    rm -f y.tab.c y.tab.h
2179027f4a0Smrg    if [ $# -ne 1 ]; then
2189027f4a0Smrg        eval LASTARG="\${$#}"
2199027f4a0Smrg	case "$LASTARG" in
2209027f4a0Smrg	*.y)
2219027f4a0Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2229027f4a0Smrg	    if [ -f "$SRCFILE" ]; then
2239027f4a0Smrg	         cp "$SRCFILE" y.tab.c
2249027f4a0Smrg	    fi
2259027f4a0Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2269027f4a0Smrg	    if [ -f "$SRCFILE" ]; then
2279027f4a0Smrg	         cp "$SRCFILE" y.tab.h
2289027f4a0Smrg	    fi
2299027f4a0Smrg	  ;;
2309027f4a0Smrg	esac
2319027f4a0Smrg    fi
2329027f4a0Smrg    if [ ! -f y.tab.h ]; then
2339027f4a0Smrg	echo >y.tab.h
2349027f4a0Smrg    fi
2359027f4a0Smrg    if [ ! -f y.tab.c ]; then
2369027f4a0Smrg	echo 'main() { return 0; }' >y.tab.c
2379027f4a0Smrg    fi
2389027f4a0Smrg    ;;
2399027f4a0Smrg
2409027f4a0Smrg  lex|flex)
2419027f4a0Smrg    echo 1>&2 "\
2429027f4a0SmrgWARNING: \`$1' is $msg.  You should only need it if
2439027f4a0Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2449027f4a0Smrg         in order for those modifications to take effect.  You can get
2459027f4a0Smrg         \`Flex' from any GNU archive site."
2469027f4a0Smrg    rm -f lex.yy.c
2479027f4a0Smrg    if [ $# -ne 1 ]; then
2489027f4a0Smrg        eval LASTARG="\${$#}"
2499027f4a0Smrg	case "$LASTARG" in
2509027f4a0Smrg	*.l)
2519027f4a0Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2529027f4a0Smrg	    if [ -f "$SRCFILE" ]; then
2539027f4a0Smrg	         cp "$SRCFILE" lex.yy.c
2549027f4a0Smrg	    fi
2559027f4a0Smrg	  ;;
2569027f4a0Smrg	esac
2579027f4a0Smrg    fi
2589027f4a0Smrg    if [ ! -f lex.yy.c ]; then
2599027f4a0Smrg	echo 'main() { return 0; }' >lex.yy.c
2609027f4a0Smrg    fi
2619027f4a0Smrg    ;;
2629027f4a0Smrg
2639027f4a0Smrg  help2man)
2649027f4a0Smrg    echo 1>&2 "\
2659027f4a0SmrgWARNING: \`$1' is $msg.  You should only need it if
2669027f4a0Smrg	 you modified a dependency of a manual page.  You may need the
2679027f4a0Smrg	 \`Help2man' package in order for those modifications to take
2689027f4a0Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2699027f4a0Smrg
2709027f4a0Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2719027f4a0Smrg    if test -z "$file"; then
2729027f4a0Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2739027f4a0Smrg    fi
2749027f4a0Smrg    if [ -f "$file" ]; then
2759027f4a0Smrg	touch $file
2769027f4a0Smrg    else
2779027f4a0Smrg	test -z "$file" || exec >$file
2789027f4a0Smrg	echo ".ab help2man is required to generate this page"
2799027f4a0Smrg	exit 1
2809027f4a0Smrg    fi
2819027f4a0Smrg    ;;
2829027f4a0Smrg
2839027f4a0Smrg  makeinfo)
2849027f4a0Smrg    echo 1>&2 "\
2859027f4a0SmrgWARNING: \`$1' is $msg.  You should only need it if
2869027f4a0Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2879027f4a0Smrg         indirectly affecting the aspect of the manual.  The spurious
2889027f4a0Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2899027f4a0Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2909027f4a0Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2919027f4a0Smrg    # The file to touch is that specified with -o ...
2929027f4a0Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2939027f4a0Smrg    if test -z "$file"; then
2949027f4a0Smrg      # ... or it is the one specified with @setfilename ...
2959027f4a0Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2969027f4a0Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
2979027f4a0Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
2989027f4a0Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
2999027f4a0Smrg    fi
3009027f4a0Smrg    # If the file does not exist, the user really needs makeinfo;
3019027f4a0Smrg    # let's fail without touching anything.
3029027f4a0Smrg    test -f $file || exit 1
3039027f4a0Smrg    touch $file
3049027f4a0Smrg    ;;
3059027f4a0Smrg
3069027f4a0Smrg  tar)
3079027f4a0Smrg    shift
3089027f4a0Smrg
3099027f4a0Smrg    # We have already tried tar in the generic part.
3109027f4a0Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3119027f4a0Smrg    # messages.
3129027f4a0Smrg    if (gnutar --version > /dev/null 2>&1); then
3139027f4a0Smrg       gnutar "$@" && exit 0
3149027f4a0Smrg    fi
3159027f4a0Smrg    if (gtar --version > /dev/null 2>&1); then
3169027f4a0Smrg       gtar "$@" && exit 0
3179027f4a0Smrg    fi
3189027f4a0Smrg    firstarg="$1"
3199027f4a0Smrg    if shift; then
3209027f4a0Smrg	case "$firstarg" in
3219027f4a0Smrg	*o*)
3229027f4a0Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3239027f4a0Smrg	    tar "$firstarg" "$@" && exit 0
3249027f4a0Smrg	    ;;
3259027f4a0Smrg	esac
3269027f4a0Smrg	case "$firstarg" in
3279027f4a0Smrg	*h*)
3289027f4a0Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3299027f4a0Smrg	    tar "$firstarg" "$@" && exit 0
3309027f4a0Smrg	    ;;
3319027f4a0Smrg	esac
3329027f4a0Smrg    fi
3339027f4a0Smrg
3349027f4a0Smrg    echo 1>&2 "\
3359027f4a0SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3369027f4a0Smrg         You may want to install GNU tar or Free paxutils, or check the
3379027f4a0Smrg         command line arguments."
3389027f4a0Smrg    exit 1
3399027f4a0Smrg    ;;
3409027f4a0Smrg
3419027f4a0Smrg  *)
3429027f4a0Smrg    echo 1>&2 "\
3439027f4a0SmrgWARNING: \`$1' is needed, and is $msg.
3449027f4a0Smrg         You might have modified some files without having the
3459027f4a0Smrg         proper tools for further handling them.  Check the \`README' file,
3469027f4a0Smrg         it often tells you about the needed prerequisites for installing
3479027f4a0Smrg         this package.  You may also peek at any GNU archive site, in case
3489027f4a0Smrg         some other package would contain this missing \`$1' program."
3499027f4a0Smrg    exit 1
3509027f4a0Smrg    ;;
3519027f4a0Smrgesac
3529027f4a0Smrg
3539027f4a0Smrgexit 0
3549027f4a0Smrg
3559027f4a0Smrg# Local variables:
3569027f4a0Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3579027f4a0Smrg# time-stamp-start: "scriptversion="
3589027f4a0Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3599027f4a0Smrg# time-stamp-end: "$"
3609027f4a0Smrg# End:
361