missing revision 32034fa5
14ecf19b2Smrg#! /bin/sh
24ecf19b2Smrg# Common stub for a few missing GNU programs while installing.
332034fa5Smrg
432034fa5Smrgscriptversion=2009-04-28.21; # UTC
532034fa5Smrg
632034fa5Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
732034fa5Smrg# 2008, 2009 Free Software Foundation, Inc.
84ecf19b2Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
94ecf19b2Smrg
104ecf19b2Smrg# This program is free software; you can redistribute it and/or modify
114ecf19b2Smrg# it under the terms of the GNU General Public License as published by
124ecf19b2Smrg# the Free Software Foundation; either version 2, or (at your option)
134ecf19b2Smrg# any later version.
144ecf19b2Smrg
154ecf19b2Smrg# This program is distributed in the hope that it will be useful,
164ecf19b2Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
174ecf19b2Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
184ecf19b2Smrg# GNU General Public License for more details.
194ecf19b2Smrg
204ecf19b2Smrg# You should have received a copy of the GNU General Public License
2132034fa5Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
224ecf19b2Smrg
234ecf19b2Smrg# As a special exception to the GNU General Public License, if you
244ecf19b2Smrg# distribute this file as part of a program that contains a
254ecf19b2Smrg# configuration script generated by Autoconf, you may include it under
264ecf19b2Smrg# the same distribution terms that you use for the rest of that program.
274ecf19b2Smrg
284ecf19b2Smrgif test $# -eq 0; then
294ecf19b2Smrg  echo 1>&2 "Try \`$0 --help' for more information"
304ecf19b2Smrg  exit 1
314ecf19b2Smrgfi
324ecf19b2Smrg
334ecf19b2Smrgrun=:
3432034fa5Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3532034fa5Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
364ecf19b2Smrg
374ecf19b2Smrg# In the cases where this matters, `missing' is being run in the
384ecf19b2Smrg# srcdir already.
394ecf19b2Smrgif test -f configure.ac; then
404ecf19b2Smrg  configure_ac=configure.ac
414ecf19b2Smrgelse
424ecf19b2Smrg  configure_ac=configure.in
434ecf19b2Smrgfi
444ecf19b2Smrg
4532034fa5Smrgmsg="missing on your system"
4632034fa5Smrg
4732034fa5Smrgcase $1 in
484ecf19b2Smrg--run)
494ecf19b2Smrg  # Try to run requested program, and just exit if it succeeds.
504ecf19b2Smrg  run=
514ecf19b2Smrg  shift
524ecf19b2Smrg  "$@" && exit 0
5332034fa5Smrg  # Exit code 63 means version mismatch.  This often happens
5432034fa5Smrg  # when the user try to use an ancient version of a tool on
5532034fa5Smrg  # a file that requires a minimum version.  In this case we
5632034fa5Smrg  # we should proceed has if the program had been absent, or
5732034fa5Smrg  # if --run hadn't been passed.
5832034fa5Smrg  if test $? = 63; then
5932034fa5Smrg    run=:
6032034fa5Smrg    msg="probably too old"
6132034fa5Smrg  fi
624ecf19b2Smrg  ;;
634ecf19b2Smrg
644ecf19b2Smrg  -h|--h|--he|--hel|--help)
654ecf19b2Smrg    echo "\
664ecf19b2Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
674ecf19b2Smrg
684ecf19b2SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
694ecf19b2Smrgerror status if there is no known handling for PROGRAM.
704ecf19b2Smrg
714ecf19b2SmrgOptions:
724ecf19b2Smrg  -h, --help      display this help and exit
734ecf19b2Smrg  -v, --version   output version information and exit
744ecf19b2Smrg  --run           try to run the given command, and emulate it if it fails
754ecf19b2Smrg
764ecf19b2SmrgSupported PROGRAM values:
774ecf19b2Smrg  aclocal      touch file \`aclocal.m4'
784ecf19b2Smrg  autoconf     touch file \`configure'
794ecf19b2Smrg  autoheader   touch file \`config.h.in'
8032034fa5Smrg  autom4te     touch the output file, or create a stub one
814ecf19b2Smrg  automake     touch all \`Makefile.in' files
824ecf19b2Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
834ecf19b2Smrg  flex         create \`lex.yy.c', if possible, from existing .c
844ecf19b2Smrg  help2man     touch the output file
854ecf19b2Smrg  lex          create \`lex.yy.c', if possible, from existing .c
864ecf19b2Smrg  makeinfo     touch the output file
874ecf19b2Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8832034fa5Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8932034fa5Smrg
9032034fa5SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
9132034fa5Smrg\`g' are ignored when checking the name.
9232034fa5Smrg
9332034fa5SmrgSend bug reports to <bug-automake@gnu.org>."
9432034fa5Smrg    exit $?
954ecf19b2Smrg    ;;
964ecf19b2Smrg
974ecf19b2Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9832034fa5Smrg    echo "missing $scriptversion (GNU Automake)"
9932034fa5Smrg    exit $?
1004ecf19b2Smrg    ;;
1014ecf19b2Smrg
1024ecf19b2Smrg  -*)
1034ecf19b2Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1044ecf19b2Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1054ecf19b2Smrg    exit 1
1064ecf19b2Smrg    ;;
1074ecf19b2Smrg
10832034fa5Smrgesac
10932034fa5Smrg
11032034fa5Smrg# normalize program name to check for.
11132034fa5Smrgprogram=`echo "$1" | sed '
11232034fa5Smrg  s/^gnu-//; t
11332034fa5Smrg  s/^gnu//; t
11432034fa5Smrg  s/^g//; t'`
11532034fa5Smrg
11632034fa5Smrg# Now exit if we have it, but it failed.  Also exit now if we
11732034fa5Smrg# don't have it and --version was passed (most likely to detect
11832034fa5Smrg# the program).  This is about non-GNU programs, so use $1 not
11932034fa5Smrg# $program.
12032034fa5Smrgcase $1 in
12132034fa5Smrg  lex*|yacc*)
12232034fa5Smrg    # Not GNU programs, they don't have --version.
12332034fa5Smrg    ;;
12432034fa5Smrg
12532034fa5Smrg  tar*)
12632034fa5Smrg    if test -n "$run"; then
12732034fa5Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12832034fa5Smrg       exit 1
12932034fa5Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13032034fa5Smrg       exit 1
13132034fa5Smrg    fi
13232034fa5Smrg    ;;
13332034fa5Smrg
13432034fa5Smrg  *)
1354ecf19b2Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1364ecf19b2Smrg       # We have it, but it failed.
1374ecf19b2Smrg       exit 1
13832034fa5Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13932034fa5Smrg       # Could not run --version or --help.  This is probably someone
14032034fa5Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
14132034fa5Smrg       # $TOOL exists and not knowing $TOOL uses missing.
14232034fa5Smrg       exit 1
1434ecf19b2Smrg    fi
14432034fa5Smrg    ;;
14532034fa5Smrgesac
1464ecf19b2Smrg
14732034fa5Smrg# If it does not exist, or fails to run (possibly an outdated version),
14832034fa5Smrg# try to emulate it.
14932034fa5Smrgcase $program in
15032034fa5Smrg  aclocal*)
1514ecf19b2Smrg    echo 1>&2 "\
15232034fa5SmrgWARNING: \`$1' is $msg.  You should only need it if
1534ecf19b2Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1544ecf19b2Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1554ecf19b2Smrg         any GNU archive site."
1564ecf19b2Smrg    touch aclocal.m4
1574ecf19b2Smrg    ;;
1584ecf19b2Smrg
15932034fa5Smrg  autoconf*)
1604ecf19b2Smrg    echo 1>&2 "\
16132034fa5SmrgWARNING: \`$1' is $msg.  You should only need it if
1624ecf19b2Smrg         you modified \`${configure_ac}'.  You might want to install the
1634ecf19b2Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1644ecf19b2Smrg         archive site."
1654ecf19b2Smrg    touch configure
1664ecf19b2Smrg    ;;
1674ecf19b2Smrg
16832034fa5Smrg  autoheader*)
1694ecf19b2Smrg    echo 1>&2 "\
17032034fa5SmrgWARNING: \`$1' is $msg.  You should only need it if
1714ecf19b2Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1724ecf19b2Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1734ecf19b2Smrg         from any GNU archive site."
1744ecf19b2Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1754ecf19b2Smrg    test -z "$files" && files="config.h"
1764ecf19b2Smrg    touch_files=
1774ecf19b2Smrg    for f in $files; do
17832034fa5Smrg      case $f in
1794ecf19b2Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1804ecf19b2Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1814ecf19b2Smrg      *) touch_files="$touch_files $f.in";;
1824ecf19b2Smrg      esac
1834ecf19b2Smrg    done
1844ecf19b2Smrg    touch $touch_files
1854ecf19b2Smrg    ;;
1864ecf19b2Smrg
1874ecf19b2Smrg  automake*)
1884ecf19b2Smrg    echo 1>&2 "\
18932034fa5SmrgWARNING: \`$1' is $msg.  You should only need it if
1904ecf19b2Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1914ecf19b2Smrg         You might want to install the \`Automake' and \`Perl' packages.
1924ecf19b2Smrg         Grab them from any GNU archive site."
1934ecf19b2Smrg    find . -type f -name Makefile.am -print |
1944ecf19b2Smrg	   sed 's/\.am$/.in/' |
1954ecf19b2Smrg	   while read f; do touch "$f"; done
1964ecf19b2Smrg    ;;
1974ecf19b2Smrg
19832034fa5Smrg  autom4te*)
1994ecf19b2Smrg    echo 1>&2 "\
20032034fa5SmrgWARNING: \`$1' is needed, but is $msg.
20132034fa5Smrg         You might have modified some files without having the
2024ecf19b2Smrg         proper tools for further handling them.
2034ecf19b2Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
2044ecf19b2Smrg         archive site."
2054ecf19b2Smrg
20632034fa5Smrg    file=`echo "$*" | sed -n "$sed_output"`
20732034fa5Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2084ecf19b2Smrg    if test -f "$file"; then
2094ecf19b2Smrg	touch $file
2104ecf19b2Smrg    else
2114ecf19b2Smrg	test -z "$file" || exec >$file
2124ecf19b2Smrg	echo "#! /bin/sh"
2134ecf19b2Smrg	echo "# Created by GNU Automake missing as a replacement of"
2144ecf19b2Smrg	echo "#  $ $@"
2154ecf19b2Smrg	echo "exit 0"
2164ecf19b2Smrg	chmod +x $file
2174ecf19b2Smrg	exit 1
2184ecf19b2Smrg    fi
2194ecf19b2Smrg    ;;
2204ecf19b2Smrg
22132034fa5Smrg  bison*|yacc*)
2224ecf19b2Smrg    echo 1>&2 "\
22332034fa5SmrgWARNING: \`$1' $msg.  You should only need it if
2244ecf19b2Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2254ecf19b2Smrg         in order for those modifications to take effect.  You can get
2264ecf19b2Smrg         \`Bison' from any GNU archive site."
2274ecf19b2Smrg    rm -f y.tab.c y.tab.h
22832034fa5Smrg    if test $# -ne 1; then
2294ecf19b2Smrg        eval LASTARG="\${$#}"
23032034fa5Smrg	case $LASTARG in
2314ecf19b2Smrg	*.y)
2324ecf19b2Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
23332034fa5Smrg	    if test -f "$SRCFILE"; then
2344ecf19b2Smrg	         cp "$SRCFILE" y.tab.c
2354ecf19b2Smrg	    fi
2364ecf19b2Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
23732034fa5Smrg	    if test -f "$SRCFILE"; then
2384ecf19b2Smrg	         cp "$SRCFILE" y.tab.h
2394ecf19b2Smrg	    fi
2404ecf19b2Smrg	  ;;
2414ecf19b2Smrg	esac
2424ecf19b2Smrg    fi
24332034fa5Smrg    if test ! -f y.tab.h; then
2444ecf19b2Smrg	echo >y.tab.h
2454ecf19b2Smrg    fi
24632034fa5Smrg    if test ! -f y.tab.c; then
2474ecf19b2Smrg	echo 'main() { return 0; }' >y.tab.c
2484ecf19b2Smrg    fi
2494ecf19b2Smrg    ;;
2504ecf19b2Smrg
25132034fa5Smrg  lex*|flex*)
2524ecf19b2Smrg    echo 1>&2 "\
25332034fa5SmrgWARNING: \`$1' is $msg.  You should only need it if
2544ecf19b2Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2554ecf19b2Smrg         in order for those modifications to take effect.  You can get
2564ecf19b2Smrg         \`Flex' from any GNU archive site."
2574ecf19b2Smrg    rm -f lex.yy.c
25832034fa5Smrg    if test $# -ne 1; then
2594ecf19b2Smrg        eval LASTARG="\${$#}"
26032034fa5Smrg	case $LASTARG in
2614ecf19b2Smrg	*.l)
2624ecf19b2Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
26332034fa5Smrg	    if test -f "$SRCFILE"; then
2644ecf19b2Smrg	         cp "$SRCFILE" lex.yy.c
2654ecf19b2Smrg	    fi
2664ecf19b2Smrg	  ;;
2674ecf19b2Smrg	esac
2684ecf19b2Smrg    fi
26932034fa5Smrg    if test ! -f lex.yy.c; then
2704ecf19b2Smrg	echo 'main() { return 0; }' >lex.yy.c
2714ecf19b2Smrg    fi
2724ecf19b2Smrg    ;;
2734ecf19b2Smrg
27432034fa5Smrg  help2man*)
2754ecf19b2Smrg    echo 1>&2 "\
27632034fa5SmrgWARNING: \`$1' is $msg.  You should only need it if
2774ecf19b2Smrg	 you modified a dependency of a manual page.  You may need the
2784ecf19b2Smrg	 \`Help2man' package in order for those modifications to take
2794ecf19b2Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2804ecf19b2Smrg
28132034fa5Smrg    file=`echo "$*" | sed -n "$sed_output"`
28232034fa5Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
28332034fa5Smrg    if test -f "$file"; then
2844ecf19b2Smrg	touch $file
2854ecf19b2Smrg    else
2864ecf19b2Smrg	test -z "$file" || exec >$file
2874ecf19b2Smrg	echo ".ab help2man is required to generate this page"
28832034fa5Smrg	exit $?
2894ecf19b2Smrg    fi
2904ecf19b2Smrg    ;;
2914ecf19b2Smrg
29232034fa5Smrg  makeinfo*)
2934ecf19b2Smrg    echo 1>&2 "\
29432034fa5SmrgWARNING: \`$1' is $msg.  You should only need it if
2954ecf19b2Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2964ecf19b2Smrg         indirectly affecting the aspect of the manual.  The spurious
2974ecf19b2Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2984ecf19b2Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2994ecf19b2Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
30032034fa5Smrg    # The file to touch is that specified with -o ...
30132034fa5Smrg    file=`echo "$*" | sed -n "$sed_output"`
30232034fa5Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
3034ecf19b2Smrg    if test -z "$file"; then
30432034fa5Smrg      # ... or it is the one specified with @setfilename ...
30532034fa5Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
30632034fa5Smrg      file=`sed -n '
30732034fa5Smrg	/^@setfilename/{
30832034fa5Smrg	  s/.* \([^ ]*\) *$/\1/
30932034fa5Smrg	  p
31032034fa5Smrg	  q
31132034fa5Smrg	}' $infile`
31232034fa5Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
31332034fa5Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3144ecf19b2Smrg    fi
31532034fa5Smrg    # If the file does not exist, the user really needs makeinfo;
31632034fa5Smrg    # let's fail without touching anything.
31732034fa5Smrg    test -f $file || exit 1
3184ecf19b2Smrg    touch $file
3194ecf19b2Smrg    ;;
3204ecf19b2Smrg
32132034fa5Smrg  tar*)
3224ecf19b2Smrg    shift
3234ecf19b2Smrg
3244ecf19b2Smrg    # We have already tried tar in the generic part.
3254ecf19b2Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3264ecf19b2Smrg    # messages.
3274ecf19b2Smrg    if (gnutar --version > /dev/null 2>&1); then
3284ecf19b2Smrg       gnutar "$@" && exit 0
3294ecf19b2Smrg    fi
3304ecf19b2Smrg    if (gtar --version > /dev/null 2>&1); then
3314ecf19b2Smrg       gtar "$@" && exit 0
3324ecf19b2Smrg    fi
3334ecf19b2Smrg    firstarg="$1"
3344ecf19b2Smrg    if shift; then
33532034fa5Smrg	case $firstarg in
3364ecf19b2Smrg	*o*)
3374ecf19b2Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3384ecf19b2Smrg	    tar "$firstarg" "$@" && exit 0
3394ecf19b2Smrg	    ;;
3404ecf19b2Smrg	esac
34132034fa5Smrg	case $firstarg in
3424ecf19b2Smrg	*h*)
3434ecf19b2Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3444ecf19b2Smrg	    tar "$firstarg" "$@" && exit 0
3454ecf19b2Smrg	    ;;
3464ecf19b2Smrg	esac
3474ecf19b2Smrg    fi
3484ecf19b2Smrg
3494ecf19b2Smrg    echo 1>&2 "\
3504ecf19b2SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3514ecf19b2Smrg         You may want to install GNU tar or Free paxutils, or check the
3524ecf19b2Smrg         command line arguments."
3534ecf19b2Smrg    exit 1
3544ecf19b2Smrg    ;;
3554ecf19b2Smrg
3564ecf19b2Smrg  *)
3574ecf19b2Smrg    echo 1>&2 "\
35832034fa5SmrgWARNING: \`$1' is needed, and is $msg.
35932034fa5Smrg         You might have modified some files without having the
3604ecf19b2Smrg         proper tools for further handling them.  Check the \`README' file,
3614ecf19b2Smrg         it often tells you about the needed prerequisites for installing
3624ecf19b2Smrg         this package.  You may also peek at any GNU archive site, in case
3634ecf19b2Smrg         some other package would contain this missing \`$1' program."
3644ecf19b2Smrg    exit 1
3654ecf19b2Smrg    ;;
3664ecf19b2Smrgesac
3674ecf19b2Smrg
3684ecf19b2Smrgexit 0
36932034fa5Smrg
37032034fa5Smrg# Local variables:
37132034fa5Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
37232034fa5Smrg# time-stamp-start: "scriptversion="
37332034fa5Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
37432034fa5Smrg# time-stamp-time-zone: "UTC"
37532034fa5Smrg# time-stamp-end: "; # UTC"
37632034fa5Smrg# End:
377