missing revision 047944f3
17706df26Smrg#! /bin/sh
27706df26Smrg# Common stub for a few missing GNU programs while installing.
37706df26Smrg
4047944f3Smrgscriptversion=2006-05-10.23
57706df26Smrg
6047944f3Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
77706df26Smrg#   Free Software Foundation, Inc.
87706df26Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
97706df26Smrg
107706df26Smrg# This program is free software; you can redistribute it and/or modify
117706df26Smrg# it under the terms of the GNU General Public License as published by
127706df26Smrg# the Free Software Foundation; either version 2, or (at your option)
137706df26Smrg# any later version.
147706df26Smrg
157706df26Smrg# This program is distributed in the hope that it will be useful,
167706df26Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
177706df26Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
187706df26Smrg# GNU General Public License for more details.
197706df26Smrg
207706df26Smrg# You should have received a copy of the GNU General Public License
217706df26Smrg# along with this program; if not, write to the Free Software
227706df26Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
237706df26Smrg# 02110-1301, USA.
247706df26Smrg
257706df26Smrg# As a special exception to the GNU General Public License, if you
267706df26Smrg# distribute this file as part of a program that contains a
277706df26Smrg# configuration script generated by Autoconf, you may include it under
287706df26Smrg# the same distribution terms that you use for the rest of that program.
297706df26Smrg
307706df26Smrgif test $# -eq 0; then
317706df26Smrg  echo 1>&2 "Try \`$0 --help' for more information"
327706df26Smrg  exit 1
337706df26Smrgfi
347706df26Smrg
357706df26Smrgrun=:
36047944f3Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
37047944f3Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
387706df26Smrg
397706df26Smrg# In the cases where this matters, `missing' is being run in the
407706df26Smrg# srcdir already.
417706df26Smrgif test -f configure.ac; then
427706df26Smrg  configure_ac=configure.ac
437706df26Smrgelse
447706df26Smrg  configure_ac=configure.in
457706df26Smrgfi
467706df26Smrg
477706df26Smrgmsg="missing on your system"
487706df26Smrg
49047944f3Smrgcase $1 in
507706df26Smrg--run)
517706df26Smrg  # Try to run requested program, and just exit if it succeeds.
527706df26Smrg  run=
537706df26Smrg  shift
547706df26Smrg  "$@" && exit 0
557706df26Smrg  # Exit code 63 means version mismatch.  This often happens
567706df26Smrg  # when the user try to use an ancient version of a tool on
577706df26Smrg  # a file that requires a minimum version.  In this case we
587706df26Smrg  # we should proceed has if the program had been absent, or
597706df26Smrg  # if --run hadn't been passed.
607706df26Smrg  if test $? = 63; then
617706df26Smrg    run=:
627706df26Smrg    msg="probably too old"
637706df26Smrg  fi
647706df26Smrg  ;;
657706df26Smrg
667706df26Smrg  -h|--h|--he|--hel|--help)
677706df26Smrg    echo "\
687706df26Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
697706df26Smrg
707706df26SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
717706df26Smrgerror status if there is no known handling for PROGRAM.
727706df26Smrg
737706df26SmrgOptions:
747706df26Smrg  -h, --help      display this help and exit
757706df26Smrg  -v, --version   output version information and exit
767706df26Smrg  --run           try to run the given command, and emulate it if it fails
777706df26Smrg
787706df26SmrgSupported PROGRAM values:
797706df26Smrg  aclocal      touch file \`aclocal.m4'
807706df26Smrg  autoconf     touch file \`configure'
817706df26Smrg  autoheader   touch file \`config.h.in'
82047944f3Smrg  autom4te     touch the output file, or create a stub one
837706df26Smrg  automake     touch all \`Makefile.in' files
847706df26Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
857706df26Smrg  flex         create \`lex.yy.c', if possible, from existing .c
867706df26Smrg  help2man     touch the output file
877706df26Smrg  lex          create \`lex.yy.c', if possible, from existing .c
887706df26Smrg  makeinfo     touch the output file
897706df26Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
907706df26Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
917706df26Smrg
927706df26SmrgSend bug reports to <bug-automake@gnu.org>."
937706df26Smrg    exit $?
947706df26Smrg    ;;
957706df26Smrg
967706df26Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
977706df26Smrg    echo "missing $scriptversion (GNU Automake)"
987706df26Smrg    exit $?
997706df26Smrg    ;;
1007706df26Smrg
1017706df26Smrg  -*)
1027706df26Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1037706df26Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1047706df26Smrg    exit 1
1057706df26Smrg    ;;
1067706df26Smrg
1077706df26Smrgesac
1087706df26Smrg
1097706df26Smrg# Now exit if we have it, but it failed.  Also exit now if we
1107706df26Smrg# don't have it and --version was passed (most likely to detect
1117706df26Smrg# the program).
112047944f3Smrgcase $1 in
1137706df26Smrg  lex|yacc)
1147706df26Smrg    # Not GNU programs, they don't have --version.
1157706df26Smrg    ;;
1167706df26Smrg
1177706df26Smrg  tar)
1187706df26Smrg    if test -n "$run"; then
1197706df26Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1207706df26Smrg       exit 1
1217706df26Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1227706df26Smrg       exit 1
1237706df26Smrg    fi
1247706df26Smrg    ;;
1257706df26Smrg
1267706df26Smrg  *)
1277706df26Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1287706df26Smrg       # We have it, but it failed.
1297706df26Smrg       exit 1
1307706df26Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1317706df26Smrg       # Could not run --version or --help.  This is probably someone
1327706df26Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1337706df26Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1347706df26Smrg       exit 1
1357706df26Smrg    fi
1367706df26Smrg    ;;
1377706df26Smrgesac
1387706df26Smrg
1397706df26Smrg# If it does not exist, or fails to run (possibly an outdated version),
1407706df26Smrg# try to emulate it.
141047944f3Smrgcase $1 in
1427706df26Smrg  aclocal*)
1437706df26Smrg    echo 1>&2 "\
1447706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
1457706df26Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1467706df26Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1477706df26Smrg         any GNU archive site."
1487706df26Smrg    touch aclocal.m4
1497706df26Smrg    ;;
1507706df26Smrg
1517706df26Smrg  autoconf)
1527706df26Smrg    echo 1>&2 "\
1537706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
1547706df26Smrg         you modified \`${configure_ac}'.  You might want to install the
1557706df26Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1567706df26Smrg         archive site."
1577706df26Smrg    touch configure
1587706df26Smrg    ;;
1597706df26Smrg
1607706df26Smrg  autoheader)
1617706df26Smrg    echo 1>&2 "\
1627706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
1637706df26Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1647706df26Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1657706df26Smrg         from any GNU archive site."
1667706df26Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1677706df26Smrg    test -z "$files" && files="config.h"
1687706df26Smrg    touch_files=
1697706df26Smrg    for f in $files; do
170047944f3Smrg      case $f in
1717706df26Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1727706df26Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1737706df26Smrg      *) touch_files="$touch_files $f.in";;
1747706df26Smrg      esac
1757706df26Smrg    done
1767706df26Smrg    touch $touch_files
1777706df26Smrg    ;;
1787706df26Smrg
1797706df26Smrg  automake*)
1807706df26Smrg    echo 1>&2 "\
1817706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
1827706df26Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1837706df26Smrg         You might want to install the \`Automake' and \`Perl' packages.
1847706df26Smrg         Grab them from any GNU archive site."
1857706df26Smrg    find . -type f -name Makefile.am -print |
1867706df26Smrg	   sed 's/\.am$/.in/' |
1877706df26Smrg	   while read f; do touch "$f"; done
1887706df26Smrg    ;;
1897706df26Smrg
1907706df26Smrg  autom4te)
1917706df26Smrg    echo 1>&2 "\
1927706df26SmrgWARNING: \`$1' is needed, but is $msg.
1937706df26Smrg         You might have modified some files without having the
1947706df26Smrg         proper tools for further handling them.
1957706df26Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1967706df26Smrg         archive site."
1977706df26Smrg
198047944f3Smrg    file=`echo "$*" | sed -n "$sed_output"`
199047944f3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2007706df26Smrg    if test -f "$file"; then
2017706df26Smrg	touch $file
2027706df26Smrg    else
2037706df26Smrg	test -z "$file" || exec >$file
2047706df26Smrg	echo "#! /bin/sh"
2057706df26Smrg	echo "# Created by GNU Automake missing as a replacement of"
2067706df26Smrg	echo "#  $ $@"
2077706df26Smrg	echo "exit 0"
2087706df26Smrg	chmod +x $file
2097706df26Smrg	exit 1
2107706df26Smrg    fi
2117706df26Smrg    ;;
2127706df26Smrg
2137706df26Smrg  bison|yacc)
2147706df26Smrg    echo 1>&2 "\
2157706df26SmrgWARNING: \`$1' $msg.  You should only need it if
2167706df26Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2177706df26Smrg         in order for those modifications to take effect.  You can get
2187706df26Smrg         \`Bison' from any GNU archive site."
2197706df26Smrg    rm -f y.tab.c y.tab.h
220047944f3Smrg    if test $# -ne 1; then
2217706df26Smrg        eval LASTARG="\${$#}"
222047944f3Smrg	case $LASTARG in
2237706df26Smrg	*.y)
2247706df26Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
225047944f3Smrg	    if test -f "$SRCFILE"; then
2267706df26Smrg	         cp "$SRCFILE" y.tab.c
2277706df26Smrg	    fi
2287706df26Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
229047944f3Smrg	    if test -f "$SRCFILE"; then
2307706df26Smrg	         cp "$SRCFILE" y.tab.h
2317706df26Smrg	    fi
2327706df26Smrg	  ;;
2337706df26Smrg	esac
2347706df26Smrg    fi
235047944f3Smrg    if test ! -f y.tab.h; then
2367706df26Smrg	echo >y.tab.h
2377706df26Smrg    fi
238047944f3Smrg    if test ! -f y.tab.c; then
2397706df26Smrg	echo 'main() { return 0; }' >y.tab.c
2407706df26Smrg    fi
2417706df26Smrg    ;;
2427706df26Smrg
2437706df26Smrg  lex|flex)
2447706df26Smrg    echo 1>&2 "\
2457706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
2467706df26Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2477706df26Smrg         in order for those modifications to take effect.  You can get
2487706df26Smrg         \`Flex' from any GNU archive site."
2497706df26Smrg    rm -f lex.yy.c
250047944f3Smrg    if test $# -ne 1; then
2517706df26Smrg        eval LASTARG="\${$#}"
252047944f3Smrg	case $LASTARG in
2537706df26Smrg	*.l)
2547706df26Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
255047944f3Smrg	    if test -f "$SRCFILE"; then
2567706df26Smrg	         cp "$SRCFILE" lex.yy.c
2577706df26Smrg	    fi
2587706df26Smrg	  ;;
2597706df26Smrg	esac
2607706df26Smrg    fi
261047944f3Smrg    if test ! -f lex.yy.c; then
2627706df26Smrg	echo 'main() { return 0; }' >lex.yy.c
2637706df26Smrg    fi
2647706df26Smrg    ;;
2657706df26Smrg
2667706df26Smrg  help2man)
2677706df26Smrg    echo 1>&2 "\
2687706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
2697706df26Smrg	 you modified a dependency of a manual page.  You may need the
2707706df26Smrg	 \`Help2man' package in order for those modifications to take
2717706df26Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2727706df26Smrg
273047944f3Smrg    file=`echo "$*" | sed -n "$sed_output"`
274047944f3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
275047944f3Smrg    if test -f "$file"; then
2767706df26Smrg	touch $file
2777706df26Smrg    else
2787706df26Smrg	test -z "$file" || exec >$file
2797706df26Smrg	echo ".ab help2man is required to generate this page"
2807706df26Smrg	exit 1
2817706df26Smrg    fi
2827706df26Smrg    ;;
2837706df26Smrg
2847706df26Smrg  makeinfo)
2857706df26Smrg    echo 1>&2 "\
2867706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
2877706df26Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2887706df26Smrg         indirectly affecting the aspect of the manual.  The spurious
2897706df26Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2907706df26Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2917706df26Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2927706df26Smrg    # The file to touch is that specified with -o ...
293047944f3Smrg    file=`echo "$*" | sed -n "$sed_output"`
294047944f3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2957706df26Smrg    if test -z "$file"; then
2967706df26Smrg      # ... or it is the one specified with @setfilename ...
2977706df26Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
298047944f3Smrg      file=`sed -n '
299047944f3Smrg	/^@setfilename/{
300047944f3Smrg	  s/.* \([^ ]*\) *$/\1/
301047944f3Smrg	  p
302047944f3Smrg	  q
303047944f3Smrg	}' $infile`
3047706df26Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3057706df26Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3067706df26Smrg    fi
3077706df26Smrg    # If the file does not exist, the user really needs makeinfo;
3087706df26Smrg    # let's fail without touching anything.
3097706df26Smrg    test -f $file || exit 1
3107706df26Smrg    touch $file
3117706df26Smrg    ;;
3127706df26Smrg
3137706df26Smrg  tar)
3147706df26Smrg    shift
3157706df26Smrg
3167706df26Smrg    # We have already tried tar in the generic part.
3177706df26Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3187706df26Smrg    # messages.
3197706df26Smrg    if (gnutar --version > /dev/null 2>&1); then
3207706df26Smrg       gnutar "$@" && exit 0
3217706df26Smrg    fi
3227706df26Smrg    if (gtar --version > /dev/null 2>&1); then
3237706df26Smrg       gtar "$@" && exit 0
3247706df26Smrg    fi
3257706df26Smrg    firstarg="$1"
3267706df26Smrg    if shift; then
327047944f3Smrg	case $firstarg in
3287706df26Smrg	*o*)
3297706df26Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3307706df26Smrg	    tar "$firstarg" "$@" && exit 0
3317706df26Smrg	    ;;
3327706df26Smrg	esac
333047944f3Smrg	case $firstarg in
3347706df26Smrg	*h*)
3357706df26Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3367706df26Smrg	    tar "$firstarg" "$@" && exit 0
3377706df26Smrg	    ;;
3387706df26Smrg	esac
3397706df26Smrg    fi
3407706df26Smrg
3417706df26Smrg    echo 1>&2 "\
3427706df26SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3437706df26Smrg         You may want to install GNU tar or Free paxutils, or check the
3447706df26Smrg         command line arguments."
3457706df26Smrg    exit 1
3467706df26Smrg    ;;
3477706df26Smrg
3487706df26Smrg  *)
3497706df26Smrg    echo 1>&2 "\
3507706df26SmrgWARNING: \`$1' is needed, and is $msg.
3517706df26Smrg         You might have modified some files without having the
3527706df26Smrg         proper tools for further handling them.  Check the \`README' file,
3537706df26Smrg         it often tells you about the needed prerequisites for installing
3547706df26Smrg         this package.  You may also peek at any GNU archive site, in case
3557706df26Smrg         some other package would contain this missing \`$1' program."
3567706df26Smrg    exit 1
3577706df26Smrg    ;;
3587706df26Smrgesac
3597706df26Smrg
3607706df26Smrgexit 0
3617706df26Smrg
3627706df26Smrg# Local variables:
3637706df26Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3647706df26Smrg# time-stamp-start: "scriptversion="
3657706df26Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3667706df26Smrg# time-stamp-end: "$"
3677706df26Smrg# End:
368