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