missing revision 55acc8fc
13da084b3Smrg#! /bin/sh
23da084b3Smrg# Common stub for a few missing GNU programs while installing.
33da084b3Smrg
455acc8fcSmrgscriptversion=2009-04-28.21; # UTC
53da084b3Smrg
655acc8fcSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
755acc8fcSmrg# 2008, 2009 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
2155acc8fcSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
223da084b3Smrg
233da084b3Smrg# As a special exception to the GNU General Public License, if you
243da084b3Smrg# distribute this file as part of a program that contains a
253da084b3Smrg# configuration script generated by Autoconf, you may include it under
263da084b3Smrg# the same distribution terms that you use for the rest of that program.
273da084b3Smrg
283da084b3Smrgif test $# -eq 0; then
293da084b3Smrg  echo 1>&2 "Try \`$0 --help' for more information"
303da084b3Smrg  exit 1
313da084b3Smrgfi
323da084b3Smrg
333da084b3Smrgrun=:
34d63fdb69Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35d63fdb69Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
363da084b3Smrg
373da084b3Smrg# In the cases where this matters, `missing' is being run in the
383da084b3Smrg# srcdir already.
393da084b3Smrgif test -f configure.ac; then
403da084b3Smrg  configure_ac=configure.ac
413da084b3Smrgelse
423da084b3Smrg  configure_ac=configure.in
433da084b3Smrgfi
443da084b3Smrg
453da084b3Smrgmsg="missing on your system"
463da084b3Smrg
47d63fdb69Smrgcase $1 in
483da084b3Smrg--run)
493da084b3Smrg  # Try to run requested program, and just exit if it succeeds.
503da084b3Smrg  run=
513da084b3Smrg  shift
523da084b3Smrg  "$@" && exit 0
533da084b3Smrg  # Exit code 63 means version mismatch.  This often happens
543da084b3Smrg  # when the user try to use an ancient version of a tool on
553da084b3Smrg  # a file that requires a minimum version.  In this case we
563da084b3Smrg  # we should proceed has if the program had been absent, or
573da084b3Smrg  # if --run hadn't been passed.
583da084b3Smrg  if test $? = 63; then
593da084b3Smrg    run=:
603da084b3Smrg    msg="probably too old"
613da084b3Smrg  fi
623da084b3Smrg  ;;
633da084b3Smrg
643da084b3Smrg  -h|--h|--he|--hel|--help)
653da084b3Smrg    echo "\
663da084b3Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
673da084b3Smrg
683da084b3SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
693da084b3Smrgerror status if there is no known handling for PROGRAM.
703da084b3Smrg
713da084b3SmrgOptions:
723da084b3Smrg  -h, --help      display this help and exit
733da084b3Smrg  -v, --version   output version information and exit
743da084b3Smrg  --run           try to run the given command, and emulate it if it fails
753da084b3Smrg
763da084b3SmrgSupported PROGRAM values:
773da084b3Smrg  aclocal      touch file \`aclocal.m4'
783da084b3Smrg  autoconf     touch file \`configure'
793da084b3Smrg  autoheader   touch file \`config.h.in'
80d63fdb69Smrg  autom4te     touch the output file, or create a stub one
813da084b3Smrg  automake     touch all \`Makefile.in' files
823da084b3Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
833da084b3Smrg  flex         create \`lex.yy.c', if possible, from existing .c
843da084b3Smrg  help2man     touch the output file
853da084b3Smrg  lex          create \`lex.yy.c', if possible, from existing .c
863da084b3Smrg  makeinfo     touch the output file
873da084b3Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
883da084b3Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
893da084b3Smrg
9055acc8fcSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
9155acc8fcSmrg\`g' are ignored when checking the name.
9255acc8fcSmrg
933da084b3SmrgSend bug reports to <bug-automake@gnu.org>."
943da084b3Smrg    exit $?
953da084b3Smrg    ;;
963da084b3Smrg
973da084b3Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
983da084b3Smrg    echo "missing $scriptversion (GNU Automake)"
993da084b3Smrg    exit $?
1003da084b3Smrg    ;;
1013da084b3Smrg
1023da084b3Smrg  -*)
1033da084b3Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1043da084b3Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1053da084b3Smrg    exit 1
1063da084b3Smrg    ;;
1073da084b3Smrg
1083da084b3Smrgesac
1093da084b3Smrg
11055acc8fcSmrg# normalize program name to check for.
11155acc8fcSmrgprogram=`echo "$1" | sed '
11255acc8fcSmrg  s/^gnu-//; t
11355acc8fcSmrg  s/^gnu//; t
11455acc8fcSmrg  s/^g//; t'`
11555acc8fcSmrg
1163da084b3Smrg# Now exit if we have it, but it failed.  Also exit now if we
1173da084b3Smrg# don't have it and --version was passed (most likely to detect
11855acc8fcSmrg# the program).  This is about non-GNU programs, so use $1 not
11955acc8fcSmrg# $program.
120d63fdb69Smrgcase $1 in
12155acc8fcSmrg  lex*|yacc*)
1223da084b3Smrg    # Not GNU programs, they don't have --version.
1233da084b3Smrg    ;;
1243da084b3Smrg
12555acc8fcSmrg  tar*)
1263da084b3Smrg    if test -n "$run"; then
1273da084b3Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1283da084b3Smrg       exit 1
1293da084b3Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1303da084b3Smrg       exit 1
1313da084b3Smrg    fi
1323da084b3Smrg    ;;
1333da084b3Smrg
1343da084b3Smrg  *)
1353da084b3Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1363da084b3Smrg       # We have it, but it failed.
1373da084b3Smrg       exit 1
1383da084b3Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1393da084b3Smrg       # Could not run --version or --help.  This is probably someone
1403da084b3Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1413da084b3Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1423da084b3Smrg       exit 1
1433da084b3Smrg    fi
1443da084b3Smrg    ;;
1453da084b3Smrgesac
1463da084b3Smrg
1473da084b3Smrg# If it does not exist, or fails to run (possibly an outdated version),
1483da084b3Smrg# try to emulate it.
14955acc8fcSmrgcase $program in
1503da084b3Smrg  aclocal*)
1513da084b3Smrg    echo 1>&2 "\
1523da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
1533da084b3Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1543da084b3Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1553da084b3Smrg         any GNU archive site."
1563da084b3Smrg    touch aclocal.m4
1573da084b3Smrg    ;;
1583da084b3Smrg
15955acc8fcSmrg  autoconf*)
1603da084b3Smrg    echo 1>&2 "\
1613da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
1623da084b3Smrg         you modified \`${configure_ac}'.  You might want to install the
1633da084b3Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1643da084b3Smrg         archive site."
1653da084b3Smrg    touch configure
1663da084b3Smrg    ;;
1673da084b3Smrg
16855acc8fcSmrg  autoheader*)
1693da084b3Smrg    echo 1>&2 "\
1703da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
1713da084b3Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1723da084b3Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1733da084b3Smrg         from any GNU archive site."
1743da084b3Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1753da084b3Smrg    test -z "$files" && files="config.h"
1763da084b3Smrg    touch_files=
1773da084b3Smrg    for f in $files; do
178d63fdb69Smrg      case $f in
1793da084b3Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1803da084b3Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1813da084b3Smrg      *) touch_files="$touch_files $f.in";;
1823da084b3Smrg      esac
1833da084b3Smrg    done
1843da084b3Smrg    touch $touch_files
1853da084b3Smrg    ;;
1863da084b3Smrg
1873da084b3Smrg  automake*)
1883da084b3Smrg    echo 1>&2 "\
1893da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
1903da084b3Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1913da084b3Smrg         You might want to install the \`Automake' and \`Perl' packages.
1923da084b3Smrg         Grab them from any GNU archive site."
1933da084b3Smrg    find . -type f -name Makefile.am -print |
1943da084b3Smrg	   sed 's/\.am$/.in/' |
1953da084b3Smrg	   while read f; do touch "$f"; done
1963da084b3Smrg    ;;
1973da084b3Smrg
19855acc8fcSmrg  autom4te*)
1993da084b3Smrg    echo 1>&2 "\
2003da084b3SmrgWARNING: \`$1' is needed, but is $msg.
2013da084b3Smrg         You might have modified some files without having the
2023da084b3Smrg         proper tools for further handling them.
2033da084b3Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
2043da084b3Smrg         archive site."
2053da084b3Smrg
206d63fdb69Smrg    file=`echo "$*" | sed -n "$sed_output"`
207d63fdb69Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2083da084b3Smrg    if test -f "$file"; then
2093da084b3Smrg	touch $file
2103da084b3Smrg    else
2113da084b3Smrg	test -z "$file" || exec >$file
2123da084b3Smrg	echo "#! /bin/sh"
2133da084b3Smrg	echo "# Created by GNU Automake missing as a replacement of"
2143da084b3Smrg	echo "#  $ $@"
2153da084b3Smrg	echo "exit 0"
2163da084b3Smrg	chmod +x $file
2173da084b3Smrg	exit 1
2183da084b3Smrg    fi
2193da084b3Smrg    ;;
2203da084b3Smrg
22155acc8fcSmrg  bison*|yacc*)
2223da084b3Smrg    echo 1>&2 "\
2233da084b3SmrgWARNING: \`$1' $msg.  You should only need it if
2243da084b3Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2253da084b3Smrg         in order for those modifications to take effect.  You can get
2263da084b3Smrg         \`Bison' from any GNU archive site."
2273da084b3Smrg    rm -f y.tab.c y.tab.h
228d63fdb69Smrg    if test $# -ne 1; then
2293da084b3Smrg        eval LASTARG="\${$#}"
230d63fdb69Smrg	case $LASTARG in
2313da084b3Smrg	*.y)
2323da084b3Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
233d63fdb69Smrg	    if test -f "$SRCFILE"; then
2343da084b3Smrg	         cp "$SRCFILE" y.tab.c
2353da084b3Smrg	    fi
2363da084b3Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
237d63fdb69Smrg	    if test -f "$SRCFILE"; then
2383da084b3Smrg	         cp "$SRCFILE" y.tab.h
2393da084b3Smrg	    fi
2403da084b3Smrg	  ;;
2413da084b3Smrg	esac
2423da084b3Smrg    fi
243d63fdb69Smrg    if test ! -f y.tab.h; then
2443da084b3Smrg	echo >y.tab.h
2453da084b3Smrg    fi
246d63fdb69Smrg    if test ! -f y.tab.c; then
2473da084b3Smrg	echo 'main() { return 0; }' >y.tab.c
2483da084b3Smrg    fi
2493da084b3Smrg    ;;
2503da084b3Smrg
25155acc8fcSmrg  lex*|flex*)
2523da084b3Smrg    echo 1>&2 "\
2533da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
2543da084b3Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2553da084b3Smrg         in order for those modifications to take effect.  You can get
2563da084b3Smrg         \`Flex' from any GNU archive site."
2573da084b3Smrg    rm -f lex.yy.c
258d63fdb69Smrg    if test $# -ne 1; then
2593da084b3Smrg        eval LASTARG="\${$#}"
260d63fdb69Smrg	case $LASTARG in
2613da084b3Smrg	*.l)
2623da084b3Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
263d63fdb69Smrg	    if test -f "$SRCFILE"; then
2643da084b3Smrg	         cp "$SRCFILE" lex.yy.c
2653da084b3Smrg	    fi
2663da084b3Smrg	  ;;
2673da084b3Smrg	esac
2683da084b3Smrg    fi
269d63fdb69Smrg    if test ! -f lex.yy.c; then
2703da084b3Smrg	echo 'main() { return 0; }' >lex.yy.c
2713da084b3Smrg    fi
2723da084b3Smrg    ;;
2733da084b3Smrg
27455acc8fcSmrg  help2man*)
2753da084b3Smrg    echo 1>&2 "\
2763da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
2773da084b3Smrg	 you modified a dependency of a manual page.  You may need the
2783da084b3Smrg	 \`Help2man' package in order for those modifications to take
2793da084b3Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2803da084b3Smrg
281d63fdb69Smrg    file=`echo "$*" | sed -n "$sed_output"`
282d63fdb69Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
283d63fdb69Smrg    if test -f "$file"; then
2843da084b3Smrg	touch $file
2853da084b3Smrg    else
2863da084b3Smrg	test -z "$file" || exec >$file
2873da084b3Smrg	echo ".ab help2man is required to generate this page"
28855acc8fcSmrg	exit $?
2893da084b3Smrg    fi
2903da084b3Smrg    ;;
2913da084b3Smrg
29255acc8fcSmrg  makeinfo*)
2933da084b3Smrg    echo 1>&2 "\
2943da084b3SmrgWARNING: \`$1' is $msg.  You should only need it if
2953da084b3Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2963da084b3Smrg         indirectly affecting the aspect of the manual.  The spurious
2973da084b3Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2983da084b3Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2993da084b3Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
3003da084b3Smrg    # The file to touch is that specified with -o ...
301d63fdb69Smrg    file=`echo "$*" | sed -n "$sed_output"`
302d63fdb69Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
3033da084b3Smrg    if test -z "$file"; then
3043da084b3Smrg      # ... or it is the one specified with @setfilename ...
3053da084b3Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
306d63fdb69Smrg      file=`sed -n '
307d63fdb69Smrg	/^@setfilename/{
308d63fdb69Smrg	  s/.* \([^ ]*\) *$/\1/
309d63fdb69Smrg	  p
310d63fdb69Smrg	  q
311d63fdb69Smrg	}' $infile`
3123da084b3Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3133da084b3Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3143da084b3Smrg    fi
3153da084b3Smrg    # If the file does not exist, the user really needs makeinfo;
3163da084b3Smrg    # let's fail without touching anything.
3173da084b3Smrg    test -f $file || exit 1
3183da084b3Smrg    touch $file
3193da084b3Smrg    ;;
3203da084b3Smrg
32155acc8fcSmrg  tar*)
3223da084b3Smrg    shift
3233da084b3Smrg
3243da084b3Smrg    # We have already tried tar in the generic part.
3253da084b3Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3263da084b3Smrg    # messages.
3273da084b3Smrg    if (gnutar --version > /dev/null 2>&1); then
3283da084b3Smrg       gnutar "$@" && exit 0
3293da084b3Smrg    fi
3303da084b3Smrg    if (gtar --version > /dev/null 2>&1); then
3313da084b3Smrg       gtar "$@" && exit 0
3323da084b3Smrg    fi
3333da084b3Smrg    firstarg="$1"
3343da084b3Smrg    if shift; then
335d63fdb69Smrg	case $firstarg in
3363da084b3Smrg	*o*)
3373da084b3Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3383da084b3Smrg	    tar "$firstarg" "$@" && exit 0
3393da084b3Smrg	    ;;
3403da084b3Smrg	esac
341d63fdb69Smrg	case $firstarg in
3423da084b3Smrg	*h*)
3433da084b3Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3443da084b3Smrg	    tar "$firstarg" "$@" && exit 0
3453da084b3Smrg	    ;;
3463da084b3Smrg	esac
3473da084b3Smrg    fi
3483da084b3Smrg
3493da084b3Smrg    echo 1>&2 "\
3503da084b3SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3513da084b3Smrg         You may want to install GNU tar or Free paxutils, or check the
3523da084b3Smrg         command line arguments."
3533da084b3Smrg    exit 1
3543da084b3Smrg    ;;
3553da084b3Smrg
3563da084b3Smrg  *)
3573da084b3Smrg    echo 1>&2 "\
3583da084b3SmrgWARNING: \`$1' is needed, and is $msg.
3593da084b3Smrg         You might have modified some files without having the
3603da084b3Smrg         proper tools for further handling them.  Check the \`README' file,
3613da084b3Smrg         it often tells you about the needed prerequisites for installing
3623da084b3Smrg         this package.  You may also peek at any GNU archive site, in case
3633da084b3Smrg         some other package would contain this missing \`$1' program."
3643da084b3Smrg    exit 1
3653da084b3Smrg    ;;
3663da084b3Smrgesac
3673da084b3Smrg
3683da084b3Smrgexit 0
3693da084b3Smrg
3703da084b3Smrg# Local variables:
3713da084b3Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3723da084b3Smrg# time-stamp-start: "scriptversion="
3733da084b3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
37455acc8fcSmrg# time-stamp-time-zone: "UTC"
37555acc8fcSmrg# time-stamp-end: "; # UTC"
3763da084b3Smrg# End:
377