missing revision 1abf7346
11abf7346Smrg#! /bin/sh
21abf7346Smrg# Common stub for a few missing GNU programs while installing.
31abf7346Smrg
41abf7346Smrgscriptversion=2006-05-10.23
51abf7346Smrg
61abf7346Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
71abf7346Smrg#   Free Software Foundation, Inc.
81abf7346Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
91abf7346Smrg
101abf7346Smrg# This program is free software; you can redistribute it and/or modify
111abf7346Smrg# it under the terms of the GNU General Public License as published by
121abf7346Smrg# the Free Software Foundation; either version 2, or (at your option)
131abf7346Smrg# any later version.
141abf7346Smrg
151abf7346Smrg# This program is distributed in the hope that it will be useful,
161abf7346Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
171abf7346Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
181abf7346Smrg# GNU General Public License for more details.
191abf7346Smrg
201abf7346Smrg# You should have received a copy of the GNU General Public License
211abf7346Smrg# along with this program; if not, write to the Free Software
221abf7346Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
231abf7346Smrg# 02110-1301, USA.
241abf7346Smrg
251abf7346Smrg# As a special exception to the GNU General Public License, if you
261abf7346Smrg# distribute this file as part of a program that contains a
271abf7346Smrg# configuration script generated by Autoconf, you may include it under
281abf7346Smrg# the same distribution terms that you use for the rest of that program.
291abf7346Smrg
301abf7346Smrgif test $# -eq 0; then
311abf7346Smrg  echo 1>&2 "Try \`$0 --help' for more information"
321abf7346Smrg  exit 1
331abf7346Smrgfi
341abf7346Smrg
351abf7346Smrgrun=:
361abf7346Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
371abf7346Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
381abf7346Smrg
391abf7346Smrg# In the cases where this matters, `missing' is being run in the
401abf7346Smrg# srcdir already.
411abf7346Smrgif test -f configure.ac; then
421abf7346Smrg  configure_ac=configure.ac
431abf7346Smrgelse
441abf7346Smrg  configure_ac=configure.in
451abf7346Smrgfi
461abf7346Smrg
471abf7346Smrgmsg="missing on your system"
481abf7346Smrg
491abf7346Smrgcase $1 in
501abf7346Smrg--run)
511abf7346Smrg  # Try to run requested program, and just exit if it succeeds.
521abf7346Smrg  run=
531abf7346Smrg  shift
541abf7346Smrg  "$@" && exit 0
551abf7346Smrg  # Exit code 63 means version mismatch.  This often happens
561abf7346Smrg  # when the user try to use an ancient version of a tool on
571abf7346Smrg  # a file that requires a minimum version.  In this case we
581abf7346Smrg  # we should proceed has if the program had been absent, or
591abf7346Smrg  # if --run hadn't been passed.
601abf7346Smrg  if test $? = 63; then
611abf7346Smrg    run=:
621abf7346Smrg    msg="probably too old"
631abf7346Smrg  fi
641abf7346Smrg  ;;
651abf7346Smrg
661abf7346Smrg  -h|--h|--he|--hel|--help)
671abf7346Smrg    echo "\
681abf7346Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
691abf7346Smrg
701abf7346SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
711abf7346Smrgerror status if there is no known handling for PROGRAM.
721abf7346Smrg
731abf7346SmrgOptions:
741abf7346Smrg  -h, --help      display this help and exit
751abf7346Smrg  -v, --version   output version information and exit
761abf7346Smrg  --run           try to run the given command, and emulate it if it fails
771abf7346Smrg
781abf7346SmrgSupported PROGRAM values:
791abf7346Smrg  aclocal      touch file \`aclocal.m4'
801abf7346Smrg  autoconf     touch file \`configure'
811abf7346Smrg  autoheader   touch file \`config.h.in'
821abf7346Smrg  autom4te     touch the output file, or create a stub one
831abf7346Smrg  automake     touch all \`Makefile.in' files
841abf7346Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
851abf7346Smrg  flex         create \`lex.yy.c', if possible, from existing .c
861abf7346Smrg  help2man     touch the output file
871abf7346Smrg  lex          create \`lex.yy.c', if possible, from existing .c
881abf7346Smrg  makeinfo     touch the output file
891abf7346Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
901abf7346Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
911abf7346Smrg
921abf7346SmrgSend bug reports to <bug-automake@gnu.org>."
931abf7346Smrg    exit $?
941abf7346Smrg    ;;
951abf7346Smrg
961abf7346Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
971abf7346Smrg    echo "missing $scriptversion (GNU Automake)"
981abf7346Smrg    exit $?
991abf7346Smrg    ;;
1001abf7346Smrg
1011abf7346Smrg  -*)
1021abf7346Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1031abf7346Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1041abf7346Smrg    exit 1
1051abf7346Smrg    ;;
1061abf7346Smrg
1071abf7346Smrgesac
1081abf7346Smrg
1091abf7346Smrg# Now exit if we have it, but it failed.  Also exit now if we
1101abf7346Smrg# don't have it and --version was passed (most likely to detect
1111abf7346Smrg# the program).
1121abf7346Smrgcase $1 in
1131abf7346Smrg  lex|yacc)
1141abf7346Smrg    # Not GNU programs, they don't have --version.
1151abf7346Smrg    ;;
1161abf7346Smrg
1171abf7346Smrg  tar)
1181abf7346Smrg    if test -n "$run"; then
1191abf7346Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1201abf7346Smrg       exit 1
1211abf7346Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1221abf7346Smrg       exit 1
1231abf7346Smrg    fi
1241abf7346Smrg    ;;
1251abf7346Smrg
1261abf7346Smrg  *)
1271abf7346Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1281abf7346Smrg       # We have it, but it failed.
1291abf7346Smrg       exit 1
1301abf7346Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1311abf7346Smrg       # Could not run --version or --help.  This is probably someone
1321abf7346Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1331abf7346Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1341abf7346Smrg       exit 1
1351abf7346Smrg    fi
1361abf7346Smrg    ;;
1371abf7346Smrgesac
1381abf7346Smrg
1391abf7346Smrg# If it does not exist, or fails to run (possibly an outdated version),
1401abf7346Smrg# try to emulate it.
1411abf7346Smrgcase $1 in
1421abf7346Smrg  aclocal*)
1431abf7346Smrg    echo 1>&2 "\
1441abf7346SmrgWARNING: \`$1' is $msg.  You should only need it if
1451abf7346Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1461abf7346Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1471abf7346Smrg         any GNU archive site."
1481abf7346Smrg    touch aclocal.m4
1491abf7346Smrg    ;;
1501abf7346Smrg
1511abf7346Smrg  autoconf)
1521abf7346Smrg    echo 1>&2 "\
1531abf7346SmrgWARNING: \`$1' is $msg.  You should only need it if
1541abf7346Smrg         you modified \`${configure_ac}'.  You might want to install the
1551abf7346Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1561abf7346Smrg         archive site."
1571abf7346Smrg    touch configure
1581abf7346Smrg    ;;
1591abf7346Smrg
1601abf7346Smrg  autoheader)
1611abf7346Smrg    echo 1>&2 "\
1621abf7346SmrgWARNING: \`$1' is $msg.  You should only need it if
1631abf7346Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1641abf7346Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1651abf7346Smrg         from any GNU archive site."
1661abf7346Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1671abf7346Smrg    test -z "$files" && files="config.h"
1681abf7346Smrg    touch_files=
1691abf7346Smrg    for f in $files; do
1701abf7346Smrg      case $f in
1711abf7346Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1721abf7346Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1731abf7346Smrg      *) touch_files="$touch_files $f.in";;
1741abf7346Smrg      esac
1751abf7346Smrg    done
1761abf7346Smrg    touch $touch_files
1771abf7346Smrg    ;;
1781abf7346Smrg
1791abf7346Smrg  automake*)
1801abf7346Smrg    echo 1>&2 "\
1811abf7346SmrgWARNING: \`$1' is $msg.  You should only need it if
1821abf7346Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1831abf7346Smrg         You might want to install the \`Automake' and \`Perl' packages.
1841abf7346Smrg         Grab them from any GNU archive site."
1851abf7346Smrg    find . -type f -name Makefile.am -print |
1861abf7346Smrg	   sed 's/\.am$/.in/' |
1871abf7346Smrg	   while read f; do touch "$f"; done
1881abf7346Smrg    ;;
1891abf7346Smrg
1901abf7346Smrg  autom4te)
1911abf7346Smrg    echo 1>&2 "\
1921abf7346SmrgWARNING: \`$1' is needed, but is $msg.
1931abf7346Smrg         You might have modified some files without having the
1941abf7346Smrg         proper tools for further handling them.
1951abf7346Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1961abf7346Smrg         archive site."
1971abf7346Smrg
1981abf7346Smrg    file=`echo "$*" | sed -n "$sed_output"`
1991abf7346Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2001abf7346Smrg    if test -f "$file"; then
2011abf7346Smrg	touch $file
2021abf7346Smrg    else
2031abf7346Smrg	test -z "$file" || exec >$file
2041abf7346Smrg	echo "#! /bin/sh"
2051abf7346Smrg	echo "# Created by GNU Automake missing as a replacement of"
2061abf7346Smrg	echo "#  $ $@"
2071abf7346Smrg	echo "exit 0"
2081abf7346Smrg	chmod +x $file
2091abf7346Smrg	exit 1
2101abf7346Smrg    fi
2111abf7346Smrg    ;;
2121abf7346Smrg
2131abf7346Smrg  bison|yacc)
2141abf7346Smrg    echo 1>&2 "\
2151abf7346SmrgWARNING: \`$1' $msg.  You should only need it if
2161abf7346Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2171abf7346Smrg         in order for those modifications to take effect.  You can get
2181abf7346Smrg         \`Bison' from any GNU archive site."
2191abf7346Smrg    rm -f y.tab.c y.tab.h
2201abf7346Smrg    if test $# -ne 1; then
2211abf7346Smrg        eval LASTARG="\${$#}"
2221abf7346Smrg	case $LASTARG in
2231abf7346Smrg	*.y)
2241abf7346Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2251abf7346Smrg	    if test -f "$SRCFILE"; then
2261abf7346Smrg	         cp "$SRCFILE" y.tab.c
2271abf7346Smrg	    fi
2281abf7346Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2291abf7346Smrg	    if test -f "$SRCFILE"; then
2301abf7346Smrg	         cp "$SRCFILE" y.tab.h
2311abf7346Smrg	    fi
2321abf7346Smrg	  ;;
2331abf7346Smrg	esac
2341abf7346Smrg    fi
2351abf7346Smrg    if test ! -f y.tab.h; then
2361abf7346Smrg	echo >y.tab.h
2371abf7346Smrg    fi
2381abf7346Smrg    if test ! -f y.tab.c; then
2391abf7346Smrg	echo 'main() { return 0; }' >y.tab.c
2401abf7346Smrg    fi
2411abf7346Smrg    ;;
2421abf7346Smrg
2431abf7346Smrg  lex|flex)
2441abf7346Smrg    echo 1>&2 "\
2451abf7346SmrgWARNING: \`$1' is $msg.  You should only need it if
2461abf7346Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2471abf7346Smrg         in order for those modifications to take effect.  You can get
2481abf7346Smrg         \`Flex' from any GNU archive site."
2491abf7346Smrg    rm -f lex.yy.c
2501abf7346Smrg    if test $# -ne 1; then
2511abf7346Smrg        eval LASTARG="\${$#}"
2521abf7346Smrg	case $LASTARG in
2531abf7346Smrg	*.l)
2541abf7346Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2551abf7346Smrg	    if test -f "$SRCFILE"; then
2561abf7346Smrg	         cp "$SRCFILE" lex.yy.c
2571abf7346Smrg	    fi
2581abf7346Smrg	  ;;
2591abf7346Smrg	esac
2601abf7346Smrg    fi
2611abf7346Smrg    if test ! -f lex.yy.c; then
2621abf7346Smrg	echo 'main() { return 0; }' >lex.yy.c
2631abf7346Smrg    fi
2641abf7346Smrg    ;;
2651abf7346Smrg
2661abf7346Smrg  help2man)
2671abf7346Smrg    echo 1>&2 "\
2681abf7346SmrgWARNING: \`$1' is $msg.  You should only need it if
2691abf7346Smrg	 you modified a dependency of a manual page.  You may need the
2701abf7346Smrg	 \`Help2man' package in order for those modifications to take
2711abf7346Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2721abf7346Smrg
2731abf7346Smrg    file=`echo "$*" | sed -n "$sed_output"`
2741abf7346Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2751abf7346Smrg    if test -f "$file"; then
2761abf7346Smrg	touch $file
2771abf7346Smrg    else
2781abf7346Smrg	test -z "$file" || exec >$file
2791abf7346Smrg	echo ".ab help2man is required to generate this page"
2801abf7346Smrg	exit 1
2811abf7346Smrg    fi
2821abf7346Smrg    ;;
2831abf7346Smrg
2841abf7346Smrg  makeinfo)
2851abf7346Smrg    echo 1>&2 "\
2861abf7346SmrgWARNING: \`$1' is $msg.  You should only need it if
2871abf7346Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2881abf7346Smrg         indirectly affecting the aspect of the manual.  The spurious
2891abf7346Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2901abf7346Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2911abf7346Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2921abf7346Smrg    # The file to touch is that specified with -o ...
2931abf7346Smrg    file=`echo "$*" | sed -n "$sed_output"`
2941abf7346Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2951abf7346Smrg    if test -z "$file"; then
2961abf7346Smrg      # ... or it is the one specified with @setfilename ...
2971abf7346Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2981abf7346Smrg      file=`sed -n '
2991abf7346Smrg	/^@setfilename/{
3001abf7346Smrg	  s/.* \([^ ]*\) *$/\1/
3011abf7346Smrg	  p
3021abf7346Smrg	  q
3031abf7346Smrg	}' $infile`
3041abf7346Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3051abf7346Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3061abf7346Smrg    fi
3071abf7346Smrg    # If the file does not exist, the user really needs makeinfo;
3081abf7346Smrg    # let's fail without touching anything.
3091abf7346Smrg    test -f $file || exit 1
3101abf7346Smrg    touch $file
3111abf7346Smrg    ;;
3121abf7346Smrg
3131abf7346Smrg  tar)
3141abf7346Smrg    shift
3151abf7346Smrg
3161abf7346Smrg    # We have already tried tar in the generic part.
3171abf7346Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3181abf7346Smrg    # messages.
3191abf7346Smrg    if (gnutar --version > /dev/null 2>&1); then
3201abf7346Smrg       gnutar "$@" && exit 0
3211abf7346Smrg    fi
3221abf7346Smrg    if (gtar --version > /dev/null 2>&1); then
3231abf7346Smrg       gtar "$@" && exit 0
3241abf7346Smrg    fi
3251abf7346Smrg    firstarg="$1"
3261abf7346Smrg    if shift; then
3271abf7346Smrg	case $firstarg in
3281abf7346Smrg	*o*)
3291abf7346Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3301abf7346Smrg	    tar "$firstarg" "$@" && exit 0
3311abf7346Smrg	    ;;
3321abf7346Smrg	esac
3331abf7346Smrg	case $firstarg in
3341abf7346Smrg	*h*)
3351abf7346Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3361abf7346Smrg	    tar "$firstarg" "$@" && exit 0
3371abf7346Smrg	    ;;
3381abf7346Smrg	esac
3391abf7346Smrg    fi
3401abf7346Smrg
3411abf7346Smrg    echo 1>&2 "\
3421abf7346SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3431abf7346Smrg         You may want to install GNU tar or Free paxutils, or check the
3441abf7346Smrg         command line arguments."
3451abf7346Smrg    exit 1
3461abf7346Smrg    ;;
3471abf7346Smrg
3481abf7346Smrg  *)
3491abf7346Smrg    echo 1>&2 "\
3501abf7346SmrgWARNING: \`$1' is needed, and is $msg.
3511abf7346Smrg         You might have modified some files without having the
3521abf7346Smrg         proper tools for further handling them.  Check the \`README' file,
3531abf7346Smrg         it often tells you about the needed prerequisites for installing
3541abf7346Smrg         this package.  You may also peek at any GNU archive site, in case
3551abf7346Smrg         some other package would contain this missing \`$1' program."
3561abf7346Smrg    exit 1
3571abf7346Smrg    ;;
3581abf7346Smrgesac
3591abf7346Smrg
3601abf7346Smrgexit 0
3611abf7346Smrg
3621abf7346Smrg# Local variables:
3631abf7346Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3641abf7346Smrg# time-stamp-start: "scriptversion="
3651abf7346Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3661abf7346Smrg# time-stamp-end: "$"
3671abf7346Smrg# End:
368