missing revision 4a041c5b
14a041c5bSmacallan#! /bin/sh
24a041c5bSmacallan# Common stub for a few missing GNU programs while installing.
34a041c5bSmacallan
44a041c5bSmacallanscriptversion=2006-05-10.23
54a041c5bSmacallan
64a041c5bSmacallan# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
74a041c5bSmacallan#   Free Software Foundation, Inc.
84a041c5bSmacallan# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
94a041c5bSmacallan
104a041c5bSmacallan# This program is free software; you can redistribute it and/or modify
114a041c5bSmacallan# it under the terms of the GNU General Public License as published by
124a041c5bSmacallan# the Free Software Foundation; either version 2, or (at your option)
134a041c5bSmacallan# any later version.
144a041c5bSmacallan
154a041c5bSmacallan# This program is distributed in the hope that it will be useful,
164a041c5bSmacallan# but WITHOUT ANY WARRANTY; without even the implied warranty of
174a041c5bSmacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
184a041c5bSmacallan# GNU General Public License for more details.
194a041c5bSmacallan
204a041c5bSmacallan# You should have received a copy of the GNU General Public License
214a041c5bSmacallan# along with this program; if not, write to the Free Software
224a041c5bSmacallan# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
234a041c5bSmacallan# 02110-1301, USA.
244a041c5bSmacallan
254a041c5bSmacallan# As a special exception to the GNU General Public License, if you
264a041c5bSmacallan# distribute this file as part of a program that contains a
274a041c5bSmacallan# configuration script generated by Autoconf, you may include it under
284a041c5bSmacallan# the same distribution terms that you use for the rest of that program.
294a041c5bSmacallan
304a041c5bSmacallanif test $# -eq 0; then
314a041c5bSmacallan  echo 1>&2 "Try \`$0 --help' for more information"
324a041c5bSmacallan  exit 1
334a041c5bSmacallanfi
344a041c5bSmacallan
354a041c5bSmacallanrun=:
364a041c5bSmacallansed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
374a041c5bSmacallansed_minuso='s/.* -o \([^ ]*\).*/\1/p'
384a041c5bSmacallan
394a041c5bSmacallan# In the cases where this matters, `missing' is being run in the
404a041c5bSmacallan# srcdir already.
414a041c5bSmacallanif test -f configure.ac; then
424a041c5bSmacallan  configure_ac=configure.ac
434a041c5bSmacallanelse
444a041c5bSmacallan  configure_ac=configure.in
454a041c5bSmacallanfi
464a041c5bSmacallan
474a041c5bSmacallanmsg="missing on your system"
484a041c5bSmacallan
494a041c5bSmacallancase $1 in
504a041c5bSmacallan--run)
514a041c5bSmacallan  # Try to run requested program, and just exit if it succeeds.
524a041c5bSmacallan  run=
534a041c5bSmacallan  shift
544a041c5bSmacallan  "$@" && exit 0
554a041c5bSmacallan  # Exit code 63 means version mismatch.  This often happens
564a041c5bSmacallan  # when the user try to use an ancient version of a tool on
574a041c5bSmacallan  # a file that requires a minimum version.  In this case we
584a041c5bSmacallan  # we should proceed has if the program had been absent, or
594a041c5bSmacallan  # if --run hadn't been passed.
604a041c5bSmacallan  if test $? = 63; then
614a041c5bSmacallan    run=:
624a041c5bSmacallan    msg="probably too old"
634a041c5bSmacallan  fi
644a041c5bSmacallan  ;;
654a041c5bSmacallan
664a041c5bSmacallan  -h|--h|--he|--hel|--help)
674a041c5bSmacallan    echo "\
684a041c5bSmacallan$0 [OPTION]... PROGRAM [ARGUMENT]...
694a041c5bSmacallan
704a041c5bSmacallanHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
714a041c5bSmacallanerror status if there is no known handling for PROGRAM.
724a041c5bSmacallan
734a041c5bSmacallanOptions:
744a041c5bSmacallan  -h, --help      display this help and exit
754a041c5bSmacallan  -v, --version   output version information and exit
764a041c5bSmacallan  --run           try to run the given command, and emulate it if it fails
774a041c5bSmacallan
784a041c5bSmacallanSupported PROGRAM values:
794a041c5bSmacallan  aclocal      touch file \`aclocal.m4'
804a041c5bSmacallan  autoconf     touch file \`configure'
814a041c5bSmacallan  autoheader   touch file \`config.h.in'
824a041c5bSmacallan  autom4te     touch the output file, or create a stub one
834a041c5bSmacallan  automake     touch all \`Makefile.in' files
844a041c5bSmacallan  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
854a041c5bSmacallan  flex         create \`lex.yy.c', if possible, from existing .c
864a041c5bSmacallan  help2man     touch the output file
874a041c5bSmacallan  lex          create \`lex.yy.c', if possible, from existing .c
884a041c5bSmacallan  makeinfo     touch the output file
894a041c5bSmacallan  tar          try tar, gnutar, gtar, then tar without non-portable flags
904a041c5bSmacallan  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
914a041c5bSmacallan
924a041c5bSmacallanSend bug reports to <bug-automake@gnu.org>."
934a041c5bSmacallan    exit $?
944a041c5bSmacallan    ;;
954a041c5bSmacallan
964a041c5bSmacallan  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
974a041c5bSmacallan    echo "missing $scriptversion (GNU Automake)"
984a041c5bSmacallan    exit $?
994a041c5bSmacallan    ;;
1004a041c5bSmacallan
1014a041c5bSmacallan  -*)
1024a041c5bSmacallan    echo 1>&2 "$0: Unknown \`$1' option"
1034a041c5bSmacallan    echo 1>&2 "Try \`$0 --help' for more information"
1044a041c5bSmacallan    exit 1
1054a041c5bSmacallan    ;;
1064a041c5bSmacallan
1074a041c5bSmacallanesac
1084a041c5bSmacallan
1094a041c5bSmacallan# Now exit if we have it, but it failed.  Also exit now if we
1104a041c5bSmacallan# don't have it and --version was passed (most likely to detect
1114a041c5bSmacallan# the program).
1124a041c5bSmacallancase $1 in
1134a041c5bSmacallan  lex|yacc)
1144a041c5bSmacallan    # Not GNU programs, they don't have --version.
1154a041c5bSmacallan    ;;
1164a041c5bSmacallan
1174a041c5bSmacallan  tar)
1184a041c5bSmacallan    if test -n "$run"; then
1194a041c5bSmacallan       echo 1>&2 "ERROR: \`tar' requires --run"
1204a041c5bSmacallan       exit 1
1214a041c5bSmacallan    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1224a041c5bSmacallan       exit 1
1234a041c5bSmacallan    fi
1244a041c5bSmacallan    ;;
1254a041c5bSmacallan
1264a041c5bSmacallan  *)
1274a041c5bSmacallan    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1284a041c5bSmacallan       # We have it, but it failed.
1294a041c5bSmacallan       exit 1
1304a041c5bSmacallan    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1314a041c5bSmacallan       # Could not run --version or --help.  This is probably someone
1324a041c5bSmacallan       # running `$TOOL --version' or `$TOOL --help' to check whether
1334a041c5bSmacallan       # $TOOL exists and not knowing $TOOL uses missing.
1344a041c5bSmacallan       exit 1
1354a041c5bSmacallan    fi
1364a041c5bSmacallan    ;;
1374a041c5bSmacallanesac
1384a041c5bSmacallan
1394a041c5bSmacallan# If it does not exist, or fails to run (possibly an outdated version),
1404a041c5bSmacallan# try to emulate it.
1414a041c5bSmacallancase $1 in
1424a041c5bSmacallan  aclocal*)
1434a041c5bSmacallan    echo 1>&2 "\
1444a041c5bSmacallanWARNING: \`$1' is $msg.  You should only need it if
1454a041c5bSmacallan         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1464a041c5bSmacallan         to install the \`Automake' and \`Perl' packages.  Grab them from
1474a041c5bSmacallan         any GNU archive site."
1484a041c5bSmacallan    touch aclocal.m4
1494a041c5bSmacallan    ;;
1504a041c5bSmacallan
1514a041c5bSmacallan  autoconf)
1524a041c5bSmacallan    echo 1>&2 "\
1534a041c5bSmacallanWARNING: \`$1' is $msg.  You should only need it if
1544a041c5bSmacallan         you modified \`${configure_ac}'.  You might want to install the
1554a041c5bSmacallan         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1564a041c5bSmacallan         archive site."
1574a041c5bSmacallan    touch configure
1584a041c5bSmacallan    ;;
1594a041c5bSmacallan
1604a041c5bSmacallan  autoheader)
1614a041c5bSmacallan    echo 1>&2 "\
1624a041c5bSmacallanWARNING: \`$1' is $msg.  You should only need it if
1634a041c5bSmacallan         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1644a041c5bSmacallan         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1654a041c5bSmacallan         from any GNU archive site."
1664a041c5bSmacallan    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1674a041c5bSmacallan    test -z "$files" && files="config.h"
1684a041c5bSmacallan    touch_files=
1694a041c5bSmacallan    for f in $files; do
1704a041c5bSmacallan      case $f in
1714a041c5bSmacallan      *:*) touch_files="$touch_files "`echo "$f" |
1724a041c5bSmacallan				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1734a041c5bSmacallan      *) touch_files="$touch_files $f.in";;
1744a041c5bSmacallan      esac
1754a041c5bSmacallan    done
1764a041c5bSmacallan    touch $touch_files
1774a041c5bSmacallan    ;;
1784a041c5bSmacallan
1794a041c5bSmacallan  automake*)
1804a041c5bSmacallan    echo 1>&2 "\
1814a041c5bSmacallanWARNING: \`$1' is $msg.  You should only need it if
1824a041c5bSmacallan         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1834a041c5bSmacallan         You might want to install the \`Automake' and \`Perl' packages.
1844a041c5bSmacallan         Grab them from any GNU archive site."
1854a041c5bSmacallan    find . -type f -name Makefile.am -print |
1864a041c5bSmacallan	   sed 's/\.am$/.in/' |
1874a041c5bSmacallan	   while read f; do touch "$f"; done
1884a041c5bSmacallan    ;;
1894a041c5bSmacallan
1904a041c5bSmacallan  autom4te)
1914a041c5bSmacallan    echo 1>&2 "\
1924a041c5bSmacallanWARNING: \`$1' is needed, but is $msg.
1934a041c5bSmacallan         You might have modified some files without having the
1944a041c5bSmacallan         proper tools for further handling them.
1954a041c5bSmacallan         You can get \`$1' as part of \`Autoconf' from any GNU
1964a041c5bSmacallan         archive site."
1974a041c5bSmacallan
1984a041c5bSmacallan    file=`echo "$*" | sed -n "$sed_output"`
1994a041c5bSmacallan    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2004a041c5bSmacallan    if test -f "$file"; then
2014a041c5bSmacallan	touch $file
2024a041c5bSmacallan    else
2034a041c5bSmacallan	test -z "$file" || exec >$file
2044a041c5bSmacallan	echo "#! /bin/sh"
2054a041c5bSmacallan	echo "# Created by GNU Automake missing as a replacement of"
2064a041c5bSmacallan	echo "#  $ $@"
2074a041c5bSmacallan	echo "exit 0"
2084a041c5bSmacallan	chmod +x $file
2094a041c5bSmacallan	exit 1
2104a041c5bSmacallan    fi
2114a041c5bSmacallan    ;;
2124a041c5bSmacallan
2134a041c5bSmacallan  bison|yacc)
2144a041c5bSmacallan    echo 1>&2 "\
2154a041c5bSmacallanWARNING: \`$1' $msg.  You should only need it if
2164a041c5bSmacallan         you modified a \`.y' file.  You may need the \`Bison' package
2174a041c5bSmacallan         in order for those modifications to take effect.  You can get
2184a041c5bSmacallan         \`Bison' from any GNU archive site."
2194a041c5bSmacallan    rm -f y.tab.c y.tab.h
2204a041c5bSmacallan    if test $# -ne 1; then
2214a041c5bSmacallan        eval LASTARG="\${$#}"
2224a041c5bSmacallan	case $LASTARG in
2234a041c5bSmacallan	*.y)
2244a041c5bSmacallan	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2254a041c5bSmacallan	    if test -f "$SRCFILE"; then
2264a041c5bSmacallan	         cp "$SRCFILE" y.tab.c
2274a041c5bSmacallan	    fi
2284a041c5bSmacallan	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2294a041c5bSmacallan	    if test -f "$SRCFILE"; then
2304a041c5bSmacallan	         cp "$SRCFILE" y.tab.h
2314a041c5bSmacallan	    fi
2324a041c5bSmacallan	  ;;
2334a041c5bSmacallan	esac
2344a041c5bSmacallan    fi
2354a041c5bSmacallan    if test ! -f y.tab.h; then
2364a041c5bSmacallan	echo >y.tab.h
2374a041c5bSmacallan    fi
2384a041c5bSmacallan    if test ! -f y.tab.c; then
2394a041c5bSmacallan	echo 'main() { return 0; }' >y.tab.c
2404a041c5bSmacallan    fi
2414a041c5bSmacallan    ;;
2424a041c5bSmacallan
2434a041c5bSmacallan  lex|flex)
2444a041c5bSmacallan    echo 1>&2 "\
2454a041c5bSmacallanWARNING: \`$1' is $msg.  You should only need it if
2464a041c5bSmacallan         you modified a \`.l' file.  You may need the \`Flex' package
2474a041c5bSmacallan         in order for those modifications to take effect.  You can get
2484a041c5bSmacallan         \`Flex' from any GNU archive site."
2494a041c5bSmacallan    rm -f lex.yy.c
2504a041c5bSmacallan    if test $# -ne 1; then
2514a041c5bSmacallan        eval LASTARG="\${$#}"
2524a041c5bSmacallan	case $LASTARG in
2534a041c5bSmacallan	*.l)
2544a041c5bSmacallan	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2554a041c5bSmacallan	    if test -f "$SRCFILE"; then
2564a041c5bSmacallan	         cp "$SRCFILE" lex.yy.c
2574a041c5bSmacallan	    fi
2584a041c5bSmacallan	  ;;
2594a041c5bSmacallan	esac
2604a041c5bSmacallan    fi
2614a041c5bSmacallan    if test ! -f lex.yy.c; then
2624a041c5bSmacallan	echo 'main() { return 0; }' >lex.yy.c
2634a041c5bSmacallan    fi
2644a041c5bSmacallan    ;;
2654a041c5bSmacallan
2664a041c5bSmacallan  help2man)
2674a041c5bSmacallan    echo 1>&2 "\
2684a041c5bSmacallanWARNING: \`$1' is $msg.  You should only need it if
2694a041c5bSmacallan	 you modified a dependency of a manual page.  You may need the
2704a041c5bSmacallan	 \`Help2man' package in order for those modifications to take
2714a041c5bSmacallan	 effect.  You can get \`Help2man' from any GNU archive site."
2724a041c5bSmacallan
2734a041c5bSmacallan    file=`echo "$*" | sed -n "$sed_output"`
2744a041c5bSmacallan    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2754a041c5bSmacallan    if test -f "$file"; then
2764a041c5bSmacallan	touch $file
2774a041c5bSmacallan    else
2784a041c5bSmacallan	test -z "$file" || exec >$file
2794a041c5bSmacallan	echo ".ab help2man is required to generate this page"
2804a041c5bSmacallan	exit 1
2814a041c5bSmacallan    fi
2824a041c5bSmacallan    ;;
2834a041c5bSmacallan
2844a041c5bSmacallan  makeinfo)
2854a041c5bSmacallan    echo 1>&2 "\
2864a041c5bSmacallanWARNING: \`$1' is $msg.  You should only need it if
2874a041c5bSmacallan         you modified a \`.texi' or \`.texinfo' file, or any other file
2884a041c5bSmacallan         indirectly affecting the aspect of the manual.  The spurious
2894a041c5bSmacallan         call might also be the consequence of using a buggy \`make' (AIX,
2904a041c5bSmacallan         DU, IRIX).  You might want to install the \`Texinfo' package or
2914a041c5bSmacallan         the \`GNU make' package.  Grab either from any GNU archive site."
2924a041c5bSmacallan    # The file to touch is that specified with -o ...
2934a041c5bSmacallan    file=`echo "$*" | sed -n "$sed_output"`
2944a041c5bSmacallan    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2954a041c5bSmacallan    if test -z "$file"; then
2964a041c5bSmacallan      # ... or it is the one specified with @setfilename ...
2974a041c5bSmacallan      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2984a041c5bSmacallan      file=`sed -n '
2994a041c5bSmacallan	/^@setfilename/{
3004a041c5bSmacallan	  s/.* \([^ ]*\) *$/\1/
3014a041c5bSmacallan	  p
3024a041c5bSmacallan	  q
3034a041c5bSmacallan	}' $infile`
3044a041c5bSmacallan      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3054a041c5bSmacallan      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3064a041c5bSmacallan    fi
3074a041c5bSmacallan    # If the file does not exist, the user really needs makeinfo;
3084a041c5bSmacallan    # let's fail without touching anything.
3094a041c5bSmacallan    test -f $file || exit 1
3104a041c5bSmacallan    touch $file
3114a041c5bSmacallan    ;;
3124a041c5bSmacallan
3134a041c5bSmacallan  tar)
3144a041c5bSmacallan    shift
3154a041c5bSmacallan
3164a041c5bSmacallan    # We have already tried tar in the generic part.
3174a041c5bSmacallan    # Look for gnutar/gtar before invocation to avoid ugly error
3184a041c5bSmacallan    # messages.
3194a041c5bSmacallan    if (gnutar --version > /dev/null 2>&1); then
3204a041c5bSmacallan       gnutar "$@" && exit 0
3214a041c5bSmacallan    fi
3224a041c5bSmacallan    if (gtar --version > /dev/null 2>&1); then
3234a041c5bSmacallan       gtar "$@" && exit 0
3244a041c5bSmacallan    fi
3254a041c5bSmacallan    firstarg="$1"
3264a041c5bSmacallan    if shift; then
3274a041c5bSmacallan	case $firstarg in
3284a041c5bSmacallan	*o*)
3294a041c5bSmacallan	    firstarg=`echo "$firstarg" | sed s/o//`
3304a041c5bSmacallan	    tar "$firstarg" "$@" && exit 0
3314a041c5bSmacallan	    ;;
3324a041c5bSmacallan	esac
3334a041c5bSmacallan	case $firstarg in
3344a041c5bSmacallan	*h*)
3354a041c5bSmacallan	    firstarg=`echo "$firstarg" | sed s/h//`
3364a041c5bSmacallan	    tar "$firstarg" "$@" && exit 0
3374a041c5bSmacallan	    ;;
3384a041c5bSmacallan	esac
3394a041c5bSmacallan    fi
3404a041c5bSmacallan
3414a041c5bSmacallan    echo 1>&2 "\
3424a041c5bSmacallanWARNING: I can't seem to be able to run \`tar' with the given arguments.
3434a041c5bSmacallan         You may want to install GNU tar or Free paxutils, or check the
3444a041c5bSmacallan         command line arguments."
3454a041c5bSmacallan    exit 1
3464a041c5bSmacallan    ;;
3474a041c5bSmacallan
3484a041c5bSmacallan  *)
3494a041c5bSmacallan    echo 1>&2 "\
3504a041c5bSmacallanWARNING: \`$1' is needed, and is $msg.
3514a041c5bSmacallan         You might have modified some files without having the
3524a041c5bSmacallan         proper tools for further handling them.  Check the \`README' file,
3534a041c5bSmacallan         it often tells you about the needed prerequisites for installing
3544a041c5bSmacallan         this package.  You may also peek at any GNU archive site, in case
3554a041c5bSmacallan         some other package would contain this missing \`$1' program."
3564a041c5bSmacallan    exit 1
3574a041c5bSmacallan    ;;
3584a041c5bSmacallanesac
3594a041c5bSmacallan
3604a041c5bSmacallanexit 0
3614a041c5bSmacallan
3624a041c5bSmacallan# Local variables:
3634a041c5bSmacallan# eval: (add-hook 'write-file-hooks 'time-stamp)
3644a041c5bSmacallan# time-stamp-start: "scriptversion="
3654a041c5bSmacallan# time-stamp-format: "%:y-%02m-%02d.%02H"
3664a041c5bSmacallan# time-stamp-end: "$"
3674a041c5bSmacallan# End:
368