missing revision d63fdb69
13da084b3Smrg#! /bin/sh
23da084b3Smrg# Common stub for a few missing GNU programs while installing.
33da084b3Smrg
4d63fdb69Smrgscriptversion=2006-05-10.23
53da084b3Smrg
6d63fdb69Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
73da084b3Smrg#   Free Software Foundation, Inc.
83da084b3Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
93da084b3Smrg
103da084b3Smrg# This program is free software; you can redistribute it and/or modify
113da084b3Smrg# it under the terms of the GNU General Public License as published by
123da084b3Smrg# the Free Software Foundation; either version 2, or (at your option)
133da084b3Smrg# any later version.
143da084b3Smrg
153da084b3Smrg# This program is distributed in the hope that it will be useful,
163da084b3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
173da084b3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
183da084b3Smrg# GNU General Public License for more details.
193da084b3Smrg
203da084b3Smrg# You should have received a copy of the GNU General Public License
213da084b3Smrg# along with this program; if not, write to the Free Software
223da084b3Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
233da084b3Smrg# 02110-1301, USA.
243da084b3Smrg
253da084b3Smrg# As a special exception to the GNU General Public License, if you
263da084b3Smrg# distribute this file as part of a program that contains a
273da084b3Smrg# configuration script generated by Autoconf, you may include it under
283da084b3Smrg# the same distribution terms that you use for the rest of that program.
293da084b3Smrg
303da084b3Smrgif test $# -eq 0; then
313da084b3Smrg  echo 1>&2 "Try \`$0 --help' for more information"
323da084b3Smrg  exit 1
333da084b3Smrgfi
343da084b3Smrg
353da084b3Smrgrun=:
36d63fdb69Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
37d63fdb69Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
383da084b3Smrg
393da084b3Smrg# In the cases where this matters, `missing' is being run in the
403da084b3Smrg# srcdir already.
413da084b3Smrgif test -f configure.ac; then
423da084b3Smrg  configure_ac=configure.ac
433da084b3Smrgelse
443da084b3Smrg  configure_ac=configure.in
453da084b3Smrgfi
463da084b3Smrg
473da084b3Smrgmsg="missing on your system"
483da084b3Smrg
49d63fdb69Smrgcase $1 in
503da084b3Smrg--run)
513da084b3Smrg  # Try to run requested program, and just exit if it succeeds.
523da084b3Smrg  run=
533da084b3Smrg  shift
543da084b3Smrg  "$@" && exit 0
553da084b3Smrg  # Exit code 63 means version mismatch.  This often happens
563da084b3Smrg  # when the user try to use an ancient version of a tool on
573da084b3Smrg  # a file that requires a minimum version.  In this case we
583da084b3Smrg  # we should proceed has if the program had been absent, or
593da084b3Smrg  # if --run hadn't been passed.
603da084b3Smrg  if test $? = 63; then
613da084b3Smrg    run=:
623da084b3Smrg    msg="probably too old"
633da084b3Smrg  fi
643da084b3Smrg  ;;
653da084b3Smrg
663da084b3Smrg  -h|--h|--he|--hel|--help)
673da084b3Smrg    echo "\
683da084b3Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
693da084b3Smrg
703da084b3SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
713da084b3Smrgerror status if there is no known handling for PROGRAM.
723da084b3Smrg
733da084b3SmrgOptions:
743da084b3Smrg  -h, --help      display this help and exit
753da084b3Smrg  -v, --version   output version information and exit
763da084b3Smrg  --run           try to run the given command, and emulate it if it fails
773da084b3Smrg
783da084b3SmrgSupported PROGRAM values:
793da084b3Smrg  aclocal      touch file \`aclocal.m4'
803da084b3Smrg  autoconf     touch file \`configure'
813da084b3Smrg  autoheader   touch file \`config.h.in'
82d63fdb69Smrg  autom4te     touch the output file, or create a stub one
833da084b3Smrg  automake     touch all \`Makefile.in' files
843da084b3Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
853da084b3Smrg  flex         create \`lex.yy.c', if possible, from existing .c
863da084b3Smrg  help2man     touch the output file
873da084b3Smrg  lex          create \`lex.yy.c', if possible, from existing .c
883da084b3Smrg  makeinfo     touch the output file
893da084b3Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
903da084b3Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
913da084b3Smrg
923da084b3SmrgSend bug reports to <bug-automake@gnu.org>."
933da084b3Smrg    exit $?
943da084b3Smrg    ;;
953da084b3Smrg
963da084b3Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
973da084b3Smrg    echo "missing $scriptversion (GNU Automake)"
983da084b3Smrg    exit $?
993da084b3Smrg    ;;
1003da084b3Smrg
1013da084b3Smrg  -*)
1023da084b3Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1033da084b3Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1043da084b3Smrg    exit 1
1053da084b3Smrg    ;;
1063da084b3Smrg
1073da084b3Smrgesac
1083da084b3Smrg
1093da084b3Smrg# Now exit if we have it, but it failed.  Also exit now if we
1103da084b3Smrg# don't have it and --version was passed (most likely to detect
1113da084b3Smrg# the program).
112d63fdb69Smrgcase $1 in
1133da084b3Smrg  lex|yacc)
1143da084b3Smrg    # Not GNU programs, they don't have --version.
1153da084b3Smrg    ;;
1163da084b3Smrg
1173da084b3Smrg  tar)
1183da084b3Smrg    if test -n "$run"; then
1193da084b3Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1203da084b3Smrg       exit 1
1213da084b3Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1223da084b3Smrg       exit 1
1233da084b3Smrg    fi
1243da084b3Smrg    ;;
1253da084b3Smrg
1263da084b3Smrg  *)
1273da084b3Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1283da084b3Smrg       # We have it, but it failed.
1293da084b3Smrg       exit 1
1303da084b3Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1313da084b3Smrg       # Could not run --version or --help.  This is probably someone
1323da084b3Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1333da084b3Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1343da084b3Smrg       exit 1
1353da084b3Smrg    fi
1363da084b3Smrg    ;;
1373da084b3Smrgesac
1383da084b3Smrg
1393da084b3Smrg# If it does not exist, or fails to run (possibly an outdated version),
1403da084b3Smrg# try to emulate it.
141d63fdb69Smrgcase $1 in
1423da084b3Smrg  aclocal*)
1433da084b3Smrg    echo 1>&2 "\
1443da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
1453da084b3Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1463da084b3Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1473da084b3Smrg         any GNU archive site."
1483da084b3Smrg    touch aclocal.m4
1493da084b3Smrg    ;;
1503da084b3Smrg
1513da084b3Smrg  autoconf)
1523da084b3Smrg    echo 1>&2 "\
1533da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
1543da084b3Smrg         you modified \`${configure_ac}'.  You might want to install the
1553da084b3Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1563da084b3Smrg         archive site."
1573da084b3Smrg    touch configure
1583da084b3Smrg    ;;
1593da084b3Smrg
1603da084b3Smrg  autoheader)
1613da084b3Smrg    echo 1>&2 "\
1623da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
1633da084b3Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1643da084b3Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1653da084b3Smrg         from any GNU archive site."
1663da084b3Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1673da084b3Smrg    test -z "$files" && files="config.h"
1683da084b3Smrg    touch_files=
1693da084b3Smrg    for f in $files; do
170d63fdb69Smrg      case $f in
1713da084b3Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1723da084b3Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1733da084b3Smrg      *) touch_files="$touch_files $f.in";;
1743da084b3Smrg      esac
1753da084b3Smrg    done
1763da084b3Smrg    touch $touch_files
1773da084b3Smrg    ;;
1783da084b3Smrg
1793da084b3Smrg  automake*)
1803da084b3Smrg    echo 1>&2 "\
1813da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
1823da084b3Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1833da084b3Smrg         You might want to install the \`Automake' and \`Perl' packages.
1843da084b3Smrg         Grab them from any GNU archive site."
1853da084b3Smrg    find . -type f -name Makefile.am -print |
1863da084b3Smrg	   sed 's/\.am$/.in/' |
1873da084b3Smrg	   while read f; do touch "$f"; done
1883da084b3Smrg    ;;
1893da084b3Smrg
1903da084b3Smrg  autom4te)
1913da084b3Smrg    echo 1>&2 "\
1923da084b3SmrgWARNING: \`$1' is needed, but is $msg.
1933da084b3Smrg         You might have modified some files without having the
1943da084b3Smrg         proper tools for further handling them.
1953da084b3Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1963da084b3Smrg         archive site."
1973da084b3Smrg
198d63fdb69Smrg    file=`echo "$*" | sed -n "$sed_output"`
199d63fdb69Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2003da084b3Smrg    if test -f "$file"; then
2013da084b3Smrg	touch $file
2023da084b3Smrg    else
2033da084b3Smrg	test -z "$file" || exec >$file
2043da084b3Smrg	echo "#! /bin/sh"
2053da084b3Smrg	echo "# Created by GNU Automake missing as a replacement of"
2063da084b3Smrg	echo "#  $ $@"
2073da084b3Smrg	echo "exit 0"
2083da084b3Smrg	chmod +x $file
2093da084b3Smrg	exit 1
2103da084b3Smrg    fi
2113da084b3Smrg    ;;
2123da084b3Smrg
2133da084b3Smrg  bison|yacc)
2143da084b3Smrg    echo 1>&2 "\
2153da084b3SmrgWARNING: \`$1' $msg.  You should only need it if
2163da084b3Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2173da084b3Smrg         in order for those modifications to take effect.  You can get
2183da084b3Smrg         \`Bison' from any GNU archive site."
2193da084b3Smrg    rm -f y.tab.c y.tab.h
220d63fdb69Smrg    if test $# -ne 1; then
2213da084b3Smrg        eval LASTARG="\${$#}"
222d63fdb69Smrg	case $LASTARG in
2233da084b3Smrg	*.y)
2243da084b3Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
225d63fdb69Smrg	    if test -f "$SRCFILE"; then
2263da084b3Smrg	         cp "$SRCFILE" y.tab.c
2273da084b3Smrg	    fi
2283da084b3Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
229d63fdb69Smrg	    if test -f "$SRCFILE"; then
2303da084b3Smrg	         cp "$SRCFILE" y.tab.h
2313da084b3Smrg	    fi
2323da084b3Smrg	  ;;
2333da084b3Smrg	esac
2343da084b3Smrg    fi
235d63fdb69Smrg    if test ! -f y.tab.h; then
2363da084b3Smrg	echo >y.tab.h
2373da084b3Smrg    fi
238d63fdb69Smrg    if test ! -f y.tab.c; then
2393da084b3Smrg	echo 'main() { return 0; }' >y.tab.c
2403da084b3Smrg    fi
2413da084b3Smrg    ;;
2423da084b3Smrg
2433da084b3Smrg  lex|flex)
2443da084b3Smrg    echo 1>&2 "\
2453da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
2463da084b3Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2473da084b3Smrg         in order for those modifications to take effect.  You can get
2483da084b3Smrg         \`Flex' from any GNU archive site."
2493da084b3Smrg    rm -f lex.yy.c
250d63fdb69Smrg    if test $# -ne 1; then
2513da084b3Smrg        eval LASTARG="\${$#}"
252d63fdb69Smrg	case $LASTARG in
2533da084b3Smrg	*.l)
2543da084b3Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
255d63fdb69Smrg	    if test -f "$SRCFILE"; then
2563da084b3Smrg	         cp "$SRCFILE" lex.yy.c
2573da084b3Smrg	    fi
2583da084b3Smrg	  ;;
2593da084b3Smrg	esac
2603da084b3Smrg    fi
261d63fdb69Smrg    if test ! -f lex.yy.c; then
2623da084b3Smrg	echo 'main() { return 0; }' >lex.yy.c
2633da084b3Smrg    fi
2643da084b3Smrg    ;;
2653da084b3Smrg
2663da084b3Smrg  help2man)
2673da084b3Smrg    echo 1>&2 "\
2683da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
2693da084b3Smrg	 you modified a dependency of a manual page.  You may need the
2703da084b3Smrg	 \`Help2man' package in order for those modifications to take
2713da084b3Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2723da084b3Smrg
273d63fdb69Smrg    file=`echo "$*" | sed -n "$sed_output"`
274d63fdb69Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
275d63fdb69Smrg    if test -f "$file"; then
2763da084b3Smrg	touch $file
2773da084b3Smrg    else
2783da084b3Smrg	test -z "$file" || exec >$file
2793da084b3Smrg	echo ".ab help2man is required to generate this page"
2803da084b3Smrg	exit 1
2813da084b3Smrg    fi
2823da084b3Smrg    ;;
2833da084b3Smrg
2843da084b3Smrg  makeinfo)
2853da084b3Smrg    echo 1>&2 "\
2863da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
2873da084b3Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2883da084b3Smrg         indirectly affecting the aspect of the manual.  The spurious
2893da084b3Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2903da084b3Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2913da084b3Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2923da084b3Smrg    # The file to touch is that specified with -o ...
293d63fdb69Smrg    file=`echo "$*" | sed -n "$sed_output"`
294d63fdb69Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2953da084b3Smrg    if test -z "$file"; then
2963da084b3Smrg      # ... or it is the one specified with @setfilename ...
2973da084b3Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
298d63fdb69Smrg      file=`sed -n '
299d63fdb69Smrg	/^@setfilename/{
300d63fdb69Smrg	  s/.* \([^ ]*\) *$/\1/
301d63fdb69Smrg	  p
302d63fdb69Smrg	  q
303d63fdb69Smrg	}' $infile`
3043da084b3Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3053da084b3Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3063da084b3Smrg    fi
3073da084b3Smrg    # If the file does not exist, the user really needs makeinfo;
3083da084b3Smrg    # let's fail without touching anything.
3093da084b3Smrg    test -f $file || exit 1
3103da084b3Smrg    touch $file
3113da084b3Smrg    ;;
3123da084b3Smrg
3133da084b3Smrg  tar)
3143da084b3Smrg    shift
3153da084b3Smrg
3163da084b3Smrg    # We have already tried tar in the generic part.
3173da084b3Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3183da084b3Smrg    # messages.
3193da084b3Smrg    if (gnutar --version > /dev/null 2>&1); then
3203da084b3Smrg       gnutar "$@" && exit 0
3213da084b3Smrg    fi
3223da084b3Smrg    if (gtar --version > /dev/null 2>&1); then
3233da084b3Smrg       gtar "$@" && exit 0
3243da084b3Smrg    fi
3253da084b3Smrg    firstarg="$1"
3263da084b3Smrg    if shift; then
327d63fdb69Smrg	case $firstarg in
3283da084b3Smrg	*o*)
3293da084b3Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3303da084b3Smrg	    tar "$firstarg" "$@" && exit 0
3313da084b3Smrg	    ;;
3323da084b3Smrg	esac
333d63fdb69Smrg	case $firstarg in
3343da084b3Smrg	*h*)
3353da084b3Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3363da084b3Smrg	    tar "$firstarg" "$@" && exit 0
3373da084b3Smrg	    ;;
3383da084b3Smrg	esac
3393da084b3Smrg    fi
3403da084b3Smrg
3413da084b3Smrg    echo 1>&2 "\
3423da084b3SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3433da084b3Smrg         You may want to install GNU tar or Free paxutils, or check the
3443da084b3Smrg         command line arguments."
3453da084b3Smrg    exit 1
3463da084b3Smrg    ;;
3473da084b3Smrg
3483da084b3Smrg  *)
3493da084b3Smrg    echo 1>&2 "\
3503da084b3SmrgWARNING: \`$1' is needed, and is $msg.
3513da084b3Smrg         You might have modified some files without having the
3523da084b3Smrg         proper tools for further handling them.  Check the \`README' file,
3533da084b3Smrg         it often tells you about the needed prerequisites for installing
3543da084b3Smrg         this package.  You may also peek at any GNU archive site, in case
3553da084b3Smrg         some other package would contain this missing \`$1' program."
3563da084b3Smrg    exit 1
3573da084b3Smrg    ;;
3583da084b3Smrgesac
3593da084b3Smrg
3603da084b3Smrgexit 0
3613da084b3Smrg
3623da084b3Smrg# Local variables:
3633da084b3Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3643da084b3Smrg# time-stamp-start: "scriptversion="
3653da084b3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3663da084b3Smrg# time-stamp-end: "$"
3673da084b3Smrg# End:
368