missing revision 42d69509
14456fccdSmrg#! /bin/sh
24456fccdSmrg# Common stub for a few missing GNU programs while installing.
34456fccdSmrg
442d69509Smrgscriptversion=2009-04-28.21; # UTC
54456fccdSmrg
642d69509Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
742d69509Smrg# 2008, 2009 Free Software Foundation, Inc.
84456fccdSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
94456fccdSmrg
104456fccdSmrg# This program is free software; you can redistribute it and/or modify
114456fccdSmrg# it under the terms of the GNU General Public License as published by
124456fccdSmrg# the Free Software Foundation; either version 2, or (at your option)
134456fccdSmrg# any later version.
144456fccdSmrg
154456fccdSmrg# This program is distributed in the hope that it will be useful,
164456fccdSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
174456fccdSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
184456fccdSmrg# GNU General Public License for more details.
194456fccdSmrg
204456fccdSmrg# You should have received a copy of the GNU General Public License
2142d69509Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
224456fccdSmrg
234456fccdSmrg# As a special exception to the GNU General Public License, if you
244456fccdSmrg# distribute this file as part of a program that contains a
254456fccdSmrg# configuration script generated by Autoconf, you may include it under
264456fccdSmrg# the same distribution terms that you use for the rest of that program.
274456fccdSmrg
284456fccdSmrgif test $# -eq 0; then
294456fccdSmrg  echo 1>&2 "Try \`$0 --help' for more information"
304456fccdSmrg  exit 1
314456fccdSmrgfi
324456fccdSmrg
334456fccdSmrgrun=:
3442d69509Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3542d69509Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
364456fccdSmrg
374456fccdSmrg# In the cases where this matters, `missing' is being run in the
384456fccdSmrg# srcdir already.
394456fccdSmrgif test -f configure.ac; then
404456fccdSmrg  configure_ac=configure.ac
414456fccdSmrgelse
424456fccdSmrg  configure_ac=configure.in
434456fccdSmrgfi
444456fccdSmrg
454456fccdSmrgmsg="missing on your system"
464456fccdSmrg
4742d69509Smrgcase $1 in
484456fccdSmrg--run)
494456fccdSmrg  # Try to run requested program, and just exit if it succeeds.
504456fccdSmrg  run=
514456fccdSmrg  shift
524456fccdSmrg  "$@" && exit 0
534456fccdSmrg  # Exit code 63 means version mismatch.  This often happens
544456fccdSmrg  # when the user try to use an ancient version of a tool on
554456fccdSmrg  # a file that requires a minimum version.  In this case we
564456fccdSmrg  # we should proceed has if the program had been absent, or
574456fccdSmrg  # if --run hadn't been passed.
584456fccdSmrg  if test $? = 63; then
594456fccdSmrg    run=:
604456fccdSmrg    msg="probably too old"
614456fccdSmrg  fi
624456fccdSmrg  ;;
634456fccdSmrg
644456fccdSmrg  -h|--h|--he|--hel|--help)
654456fccdSmrg    echo "\
664456fccdSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
674456fccdSmrg
684456fccdSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
694456fccdSmrgerror status if there is no known handling for PROGRAM.
704456fccdSmrg
714456fccdSmrgOptions:
724456fccdSmrg  -h, --help      display this help and exit
734456fccdSmrg  -v, --version   output version information and exit
744456fccdSmrg  --run           try to run the given command, and emulate it if it fails
754456fccdSmrg
764456fccdSmrgSupported PROGRAM values:
774456fccdSmrg  aclocal      touch file \`aclocal.m4'
784456fccdSmrg  autoconf     touch file \`configure'
794456fccdSmrg  autoheader   touch file \`config.h.in'
8042d69509Smrg  autom4te     touch the output file, or create a stub one
814456fccdSmrg  automake     touch all \`Makefile.in' files
824456fccdSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
834456fccdSmrg  flex         create \`lex.yy.c', if possible, from existing .c
844456fccdSmrg  help2man     touch the output file
854456fccdSmrg  lex          create \`lex.yy.c', if possible, from existing .c
864456fccdSmrg  makeinfo     touch the output file
874456fccdSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
884456fccdSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
894456fccdSmrg
9042d69509SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
9142d69509Smrg\`g' are ignored when checking the name.
9242d69509Smrg
934456fccdSmrgSend bug reports to <bug-automake@gnu.org>."
944456fccdSmrg    exit $?
954456fccdSmrg    ;;
964456fccdSmrg
974456fccdSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
984456fccdSmrg    echo "missing $scriptversion (GNU Automake)"
994456fccdSmrg    exit $?
1004456fccdSmrg    ;;
1014456fccdSmrg
1024456fccdSmrg  -*)
1034456fccdSmrg    echo 1>&2 "$0: Unknown \`$1' option"
1044456fccdSmrg    echo 1>&2 "Try \`$0 --help' for more information"
1054456fccdSmrg    exit 1
1064456fccdSmrg    ;;
1074456fccdSmrg
1084456fccdSmrgesac
1094456fccdSmrg
11042d69509Smrg# normalize program name to check for.
11142d69509Smrgprogram=`echo "$1" | sed '
11242d69509Smrg  s/^gnu-//; t
11342d69509Smrg  s/^gnu//; t
11442d69509Smrg  s/^g//; t'`
11542d69509Smrg
1164456fccdSmrg# Now exit if we have it, but it failed.  Also exit now if we
1174456fccdSmrg# don't have it and --version was passed (most likely to detect
11842d69509Smrg# the program).  This is about non-GNU programs, so use $1 not
11942d69509Smrg# $program.
12042d69509Smrgcase $1 in
12142d69509Smrg  lex*|yacc*)
1224456fccdSmrg    # Not GNU programs, they don't have --version.
1234456fccdSmrg    ;;
1244456fccdSmrg
12542d69509Smrg  tar*)
1264456fccdSmrg    if test -n "$run"; then
1274456fccdSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
1284456fccdSmrg       exit 1
1294456fccdSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1304456fccdSmrg       exit 1
1314456fccdSmrg    fi
1324456fccdSmrg    ;;
1334456fccdSmrg
1344456fccdSmrg  *)
1354456fccdSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1364456fccdSmrg       # We have it, but it failed.
1374456fccdSmrg       exit 1
1384456fccdSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1394456fccdSmrg       # Could not run --version or --help.  This is probably someone
1404456fccdSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1414456fccdSmrg       # $TOOL exists and not knowing $TOOL uses missing.
1424456fccdSmrg       exit 1
1434456fccdSmrg    fi
1444456fccdSmrg    ;;
1454456fccdSmrgesac
1464456fccdSmrg
1474456fccdSmrg# If it does not exist, or fails to run (possibly an outdated version),
1484456fccdSmrg# try to emulate it.
14942d69509Smrgcase $program in
1504456fccdSmrg  aclocal*)
1514456fccdSmrg    echo 1>&2 "\
1524456fccdSmrgWARNING: \`$1' is $msg.  You should only need it if
1534456fccdSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1544456fccdSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1554456fccdSmrg         any GNU archive site."
1564456fccdSmrg    touch aclocal.m4
1574456fccdSmrg    ;;
1584456fccdSmrg
15942d69509Smrg  autoconf*)
1604456fccdSmrg    echo 1>&2 "\
1614456fccdSmrgWARNING: \`$1' is $msg.  You should only need it if
1624456fccdSmrg         you modified \`${configure_ac}'.  You might want to install the
1634456fccdSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1644456fccdSmrg         archive site."
1654456fccdSmrg    touch configure
1664456fccdSmrg    ;;
1674456fccdSmrg
16842d69509Smrg  autoheader*)
1694456fccdSmrg    echo 1>&2 "\
1704456fccdSmrgWARNING: \`$1' is $msg.  You should only need it if
1714456fccdSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1724456fccdSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1734456fccdSmrg         from any GNU archive site."
1744456fccdSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1754456fccdSmrg    test -z "$files" && files="config.h"
1764456fccdSmrg    touch_files=
1774456fccdSmrg    for f in $files; do
17842d69509Smrg      case $f in
1794456fccdSmrg      *:*) touch_files="$touch_files "`echo "$f" |
1804456fccdSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1814456fccdSmrg      *) touch_files="$touch_files $f.in";;
1824456fccdSmrg      esac
1834456fccdSmrg    done
1844456fccdSmrg    touch $touch_files
1854456fccdSmrg    ;;
1864456fccdSmrg
1874456fccdSmrg  automake*)
1884456fccdSmrg    echo 1>&2 "\
1894456fccdSmrgWARNING: \`$1' is $msg.  You should only need it if
1904456fccdSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1914456fccdSmrg         You might want to install the \`Automake' and \`Perl' packages.
1924456fccdSmrg         Grab them from any GNU archive site."
1934456fccdSmrg    find . -type f -name Makefile.am -print |
1944456fccdSmrg	   sed 's/\.am$/.in/' |
1954456fccdSmrg	   while read f; do touch "$f"; done
1964456fccdSmrg    ;;
1974456fccdSmrg
19842d69509Smrg  autom4te*)
1994456fccdSmrg    echo 1>&2 "\
2004456fccdSmrgWARNING: \`$1' is needed, but is $msg.
2014456fccdSmrg         You might have modified some files without having the
2024456fccdSmrg         proper tools for further handling them.
2034456fccdSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
2044456fccdSmrg         archive site."
2054456fccdSmrg
20642d69509Smrg    file=`echo "$*" | sed -n "$sed_output"`
20742d69509Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2084456fccdSmrg    if test -f "$file"; then
2094456fccdSmrg	touch $file
2104456fccdSmrg    else
2114456fccdSmrg	test -z "$file" || exec >$file
2124456fccdSmrg	echo "#! /bin/sh"
2134456fccdSmrg	echo "# Created by GNU Automake missing as a replacement of"
2144456fccdSmrg	echo "#  $ $@"
2154456fccdSmrg	echo "exit 0"
2164456fccdSmrg	chmod +x $file
2174456fccdSmrg	exit 1
2184456fccdSmrg    fi
2194456fccdSmrg    ;;
2204456fccdSmrg
22142d69509Smrg  bison*|yacc*)
2224456fccdSmrg    echo 1>&2 "\
2234456fccdSmrgWARNING: \`$1' $msg.  You should only need it if
2244456fccdSmrg         you modified a \`.y' file.  You may need the \`Bison' package
2254456fccdSmrg         in order for those modifications to take effect.  You can get
2264456fccdSmrg         \`Bison' from any GNU archive site."
2274456fccdSmrg    rm -f y.tab.c y.tab.h
22842d69509Smrg    if test $# -ne 1; then
2294456fccdSmrg        eval LASTARG="\${$#}"
23042d69509Smrg	case $LASTARG in
2314456fccdSmrg	*.y)
2324456fccdSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
23342d69509Smrg	    if test -f "$SRCFILE"; then
2344456fccdSmrg	         cp "$SRCFILE" y.tab.c
2354456fccdSmrg	    fi
2364456fccdSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
23742d69509Smrg	    if test -f "$SRCFILE"; then
2384456fccdSmrg	         cp "$SRCFILE" y.tab.h
2394456fccdSmrg	    fi
2404456fccdSmrg	  ;;
2414456fccdSmrg	esac
2424456fccdSmrg    fi
24342d69509Smrg    if test ! -f y.tab.h; then
2444456fccdSmrg	echo >y.tab.h
2454456fccdSmrg    fi
24642d69509Smrg    if test ! -f y.tab.c; then
2474456fccdSmrg	echo 'main() { return 0; }' >y.tab.c
2484456fccdSmrg    fi
2494456fccdSmrg    ;;
2504456fccdSmrg
25142d69509Smrg  lex*|flex*)
2524456fccdSmrg    echo 1>&2 "\
2534456fccdSmrgWARNING: \`$1' is $msg.  You should only need it if
2544456fccdSmrg         you modified a \`.l' file.  You may need the \`Flex' package
2554456fccdSmrg         in order for those modifications to take effect.  You can get
2564456fccdSmrg         \`Flex' from any GNU archive site."
2574456fccdSmrg    rm -f lex.yy.c
25842d69509Smrg    if test $# -ne 1; then
2594456fccdSmrg        eval LASTARG="\${$#}"
26042d69509Smrg	case $LASTARG in
2614456fccdSmrg	*.l)
2624456fccdSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
26342d69509Smrg	    if test -f "$SRCFILE"; then
2644456fccdSmrg	         cp "$SRCFILE" lex.yy.c
2654456fccdSmrg	    fi
2664456fccdSmrg	  ;;
2674456fccdSmrg	esac
2684456fccdSmrg    fi
26942d69509Smrg    if test ! -f lex.yy.c; then
2704456fccdSmrg	echo 'main() { return 0; }' >lex.yy.c
2714456fccdSmrg    fi
2724456fccdSmrg    ;;
2734456fccdSmrg
27442d69509Smrg  help2man*)
2754456fccdSmrg    echo 1>&2 "\
2764456fccdSmrgWARNING: \`$1' is $msg.  You should only need it if
2774456fccdSmrg	 you modified a dependency of a manual page.  You may need the
2784456fccdSmrg	 \`Help2man' package in order for those modifications to take
2794456fccdSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
2804456fccdSmrg
28142d69509Smrg    file=`echo "$*" | sed -n "$sed_output"`
28242d69509Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
28342d69509Smrg    if test -f "$file"; then
2844456fccdSmrg	touch $file
2854456fccdSmrg    else
2864456fccdSmrg	test -z "$file" || exec >$file
2874456fccdSmrg	echo ".ab help2man is required to generate this page"
28842d69509Smrg	exit $?
2894456fccdSmrg    fi
2904456fccdSmrg    ;;
2914456fccdSmrg
29242d69509Smrg  makeinfo*)
2934456fccdSmrg    echo 1>&2 "\
2944456fccdSmrgWARNING: \`$1' is $msg.  You should only need it if
2954456fccdSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2964456fccdSmrg         indirectly affecting the aspect of the manual.  The spurious
2974456fccdSmrg         call might also be the consequence of using a buggy \`make' (AIX,
2984456fccdSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2994456fccdSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
3004456fccdSmrg    # The file to touch is that specified with -o ...
30142d69509Smrg    file=`echo "$*" | sed -n "$sed_output"`
30242d69509Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
3034456fccdSmrg    if test -z "$file"; then
3044456fccdSmrg      # ... or it is the one specified with @setfilename ...
3054456fccdSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
30642d69509Smrg      file=`sed -n '
30742d69509Smrg	/^@setfilename/{
30842d69509Smrg	  s/.* \([^ ]*\) *$/\1/
30942d69509Smrg	  p
31042d69509Smrg	  q
31142d69509Smrg	}' $infile`
3124456fccdSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3134456fccdSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3144456fccdSmrg    fi
3154456fccdSmrg    # If the file does not exist, the user really needs makeinfo;
3164456fccdSmrg    # let's fail without touching anything.
3174456fccdSmrg    test -f $file || exit 1
3184456fccdSmrg    touch $file
3194456fccdSmrg    ;;
3204456fccdSmrg
32142d69509Smrg  tar*)
3224456fccdSmrg    shift
3234456fccdSmrg
3244456fccdSmrg    # We have already tried tar in the generic part.
3254456fccdSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
3264456fccdSmrg    # messages.
3274456fccdSmrg    if (gnutar --version > /dev/null 2>&1); then
3284456fccdSmrg       gnutar "$@" && exit 0
3294456fccdSmrg    fi
3304456fccdSmrg    if (gtar --version > /dev/null 2>&1); then
3314456fccdSmrg       gtar "$@" && exit 0
3324456fccdSmrg    fi
3334456fccdSmrg    firstarg="$1"
3344456fccdSmrg    if shift; then
33542d69509Smrg	case $firstarg in
3364456fccdSmrg	*o*)
3374456fccdSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
3384456fccdSmrg	    tar "$firstarg" "$@" && exit 0
3394456fccdSmrg	    ;;
3404456fccdSmrg	esac
34142d69509Smrg	case $firstarg in
3424456fccdSmrg	*h*)
3434456fccdSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
3444456fccdSmrg	    tar "$firstarg" "$@" && exit 0
3454456fccdSmrg	    ;;
3464456fccdSmrg	esac
3474456fccdSmrg    fi
3484456fccdSmrg
3494456fccdSmrg    echo 1>&2 "\
3504456fccdSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3514456fccdSmrg         You may want to install GNU tar or Free paxutils, or check the
3524456fccdSmrg         command line arguments."
3534456fccdSmrg    exit 1
3544456fccdSmrg    ;;
3554456fccdSmrg
3564456fccdSmrg  *)
3574456fccdSmrg    echo 1>&2 "\
3584456fccdSmrgWARNING: \`$1' is needed, and is $msg.
3594456fccdSmrg         You might have modified some files without having the
3604456fccdSmrg         proper tools for further handling them.  Check the \`README' file,
3614456fccdSmrg         it often tells you about the needed prerequisites for installing
3624456fccdSmrg         this package.  You may also peek at any GNU archive site, in case
3634456fccdSmrg         some other package would contain this missing \`$1' program."
3644456fccdSmrg    exit 1
3654456fccdSmrg    ;;
3664456fccdSmrgesac
3674456fccdSmrg
3684456fccdSmrgexit 0
3694456fccdSmrg
3704456fccdSmrg# Local variables:
3714456fccdSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3724456fccdSmrg# time-stamp-start: "scriptversion="
3734456fccdSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
37442d69509Smrg# time-stamp-time-zone: "UTC"
37542d69509Smrg# time-stamp-end: "; # UTC"
3764456fccdSmrg# End:
377