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