missing revision 3294c433
13294c433Smrg#! /bin/sh
23294c433Smrg# Common stub for a few missing GNU programs while installing.
33294c433Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
43294c433Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
53294c433Smrg
63294c433Smrg# This program is free software; you can redistribute it and/or modify
73294c433Smrg# it under the terms of the GNU General Public License as published by
83294c433Smrg# the Free Software Foundation; either version 2, or (at your option)
93294c433Smrg# any later version.
103294c433Smrg
113294c433Smrg# This program is distributed in the hope that it will be useful,
123294c433Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
133294c433Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
143294c433Smrg# GNU General Public License for more details.
153294c433Smrg
163294c433Smrg# You should have received a copy of the GNU General Public License
173294c433Smrg# along with this program; if not, write to the Free Software
183294c433Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
193294c433Smrg# 02111-1307, USA.
203294c433Smrg
213294c433Smrg# As a special exception to the GNU General Public License, if you
223294c433Smrg# distribute this file as part of a program that contains a
233294c433Smrg# configuration script generated by Autoconf, you may include it under
243294c433Smrg# the same distribution terms that you use for the rest of that program.
253294c433Smrg
263294c433Smrgif test $# -eq 0; then
273294c433Smrg  echo 1>&2 "Try \`$0 --help' for more information"
283294c433Smrg  exit 1
293294c433Smrgfi
303294c433Smrg
313294c433Smrgrun=:
323294c433Smrg
333294c433Smrg# In the cases where this matters, `missing' is being run in the
343294c433Smrg# srcdir already.
353294c433Smrgif test -f configure.ac; then
363294c433Smrg  configure_ac=configure.ac
373294c433Smrgelse
383294c433Smrg  configure_ac=configure.in
393294c433Smrgfi
403294c433Smrg
413294c433Smrgcase "$1" in
423294c433Smrg--run)
433294c433Smrg  # Try to run requested program, and just exit if it succeeds.
443294c433Smrg  run=
453294c433Smrg  shift
463294c433Smrg  "$@" && exit 0
473294c433Smrg  ;;
483294c433Smrgesac
493294c433Smrg
503294c433Smrg# If it does not exist, or fails to run (possibly an outdated version),
513294c433Smrg# try to emulate it.
523294c433Smrgcase "$1" in
533294c433Smrg
543294c433Smrg  -h|--h|--he|--hel|--help)
553294c433Smrg    echo "\
563294c433Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
573294c433Smrg
583294c433SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
593294c433Smrgerror status if there is no known handling for PROGRAM.
603294c433Smrg
613294c433SmrgOptions:
623294c433Smrg  -h, --help      display this help and exit
633294c433Smrg  -v, --version   output version information and exit
643294c433Smrg  --run           try to run the given command, and emulate it if it fails
653294c433Smrg
663294c433SmrgSupported PROGRAM values:
673294c433Smrg  aclocal      touch file \`aclocal.m4'
683294c433Smrg  autoconf     touch file \`configure'
693294c433Smrg  autoheader   touch file \`config.h.in'
703294c433Smrg  automake     touch all \`Makefile.in' files
713294c433Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
723294c433Smrg  flex         create \`lex.yy.c', if possible, from existing .c
733294c433Smrg  help2man     touch the output file
743294c433Smrg  lex          create \`lex.yy.c', if possible, from existing .c
753294c433Smrg  makeinfo     touch the output file
763294c433Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
773294c433Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
783294c433Smrg    ;;
793294c433Smrg
803294c433Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
813294c433Smrg    echo "missing 0.4 - GNU automake"
823294c433Smrg    ;;
833294c433Smrg
843294c433Smrg  -*)
853294c433Smrg    echo 1>&2 "$0: Unknown \`$1' option"
863294c433Smrg    echo 1>&2 "Try \`$0 --help' for more information"
873294c433Smrg    exit 1
883294c433Smrg    ;;
893294c433Smrg
903294c433Smrg  aclocal*)
913294c433Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
923294c433Smrg       # We have it, but it failed.
933294c433Smrg       exit 1
943294c433Smrg    fi
953294c433Smrg
963294c433Smrg    echo 1>&2 "\
973294c433SmrgWARNING: \`$1' is missing on your system.  You should only need it if
983294c433Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
993294c433Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1003294c433Smrg         any GNU archive site."
1013294c433Smrg    touch aclocal.m4
1023294c433Smrg    ;;
1033294c433Smrg
1043294c433Smrg  autoconf)
1053294c433Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1063294c433Smrg       # We have it, but it failed.
1073294c433Smrg       exit 1
1083294c433Smrg    fi
1093294c433Smrg
1103294c433Smrg    echo 1>&2 "\
1113294c433SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1123294c433Smrg         you modified \`${configure_ac}'.  You might want to install the
1133294c433Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1143294c433Smrg         archive site."
1153294c433Smrg    touch configure
1163294c433Smrg    ;;
1173294c433Smrg
1183294c433Smrg  autoheader)
1193294c433Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1203294c433Smrg       # We have it, but it failed.
1213294c433Smrg       exit 1
1223294c433Smrg    fi
1233294c433Smrg
1243294c433Smrg    echo 1>&2 "\
1253294c433SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1263294c433Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1273294c433Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1283294c433Smrg         from any GNU archive site."
1293294c433Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1303294c433Smrg    test -z "$files" && files="config.h"
1313294c433Smrg    touch_files=
1323294c433Smrg    for f in $files; do
1333294c433Smrg      case "$f" in
1343294c433Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1353294c433Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1363294c433Smrg      *) touch_files="$touch_files $f.in";;
1373294c433Smrg      esac
1383294c433Smrg    done
1393294c433Smrg    touch $touch_files
1403294c433Smrg    ;;
1413294c433Smrg
1423294c433Smrg  automake*)
1433294c433Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1443294c433Smrg       # We have it, but it failed.
1453294c433Smrg       exit 1
1463294c433Smrg    fi
1473294c433Smrg
1483294c433Smrg    echo 1>&2 "\
1493294c433SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1503294c433Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1513294c433Smrg         You might want to install the \`Automake' and \`Perl' packages.
1523294c433Smrg         Grab them from any GNU archive site."
1533294c433Smrg    find . -type f -name Makefile.am -print |
1543294c433Smrg	   sed 's/\.am$/.in/' |
1553294c433Smrg	   while read f; do touch "$f"; done
1563294c433Smrg    ;;
1573294c433Smrg
1583294c433Smrg  autom4te)
1593294c433Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1603294c433Smrg       # We have it, but it failed.
1613294c433Smrg       exit 1
1623294c433Smrg    fi
1633294c433Smrg
1643294c433Smrg    echo 1>&2 "\
1653294c433SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
1663294c433Smrg         system.  You might have modified some files without having the
1673294c433Smrg         proper tools for further handling them.
1683294c433Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1693294c433Smrg         archive site."
1703294c433Smrg
1713294c433Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
1723294c433Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
1733294c433Smrg    if test -f "$file"; then
1743294c433Smrg	touch $file
1753294c433Smrg    else
1763294c433Smrg	test -z "$file" || exec >$file
1773294c433Smrg	echo "#! /bin/sh"
1783294c433Smrg	echo "# Created by GNU Automake missing as a replacement of"
1793294c433Smrg	echo "#  $ $@"
1803294c433Smrg	echo "exit 0"
1813294c433Smrg	chmod +x $file
1823294c433Smrg	exit 1
1833294c433Smrg    fi
1843294c433Smrg    ;;
1853294c433Smrg
1863294c433Smrg  bison|yacc)
1873294c433Smrg    echo 1>&2 "\
1883294c433SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1893294c433Smrg         you modified a \`.y' file.  You may need the \`Bison' package
1903294c433Smrg         in order for those modifications to take effect.  You can get
1913294c433Smrg         \`Bison' from any GNU archive site."
1923294c433Smrg    rm -f y.tab.c y.tab.h
1933294c433Smrg    if [ $# -ne 1 ]; then
1943294c433Smrg        eval LASTARG="\${$#}"
1953294c433Smrg	case "$LASTARG" in
1963294c433Smrg	*.y)
1973294c433Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
1983294c433Smrg	    if [ -f "$SRCFILE" ]; then
1993294c433Smrg	         cp "$SRCFILE" y.tab.c
2003294c433Smrg	    fi
2013294c433Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2023294c433Smrg	    if [ -f "$SRCFILE" ]; then
2033294c433Smrg	         cp "$SRCFILE" y.tab.h
2043294c433Smrg	    fi
2053294c433Smrg	  ;;
2063294c433Smrg	esac
2073294c433Smrg    fi
2083294c433Smrg    if [ ! -f y.tab.h ]; then
2093294c433Smrg	echo >y.tab.h
2103294c433Smrg    fi
2113294c433Smrg    if [ ! -f y.tab.c ]; then
2123294c433Smrg	echo 'main() { return 0; }' >y.tab.c
2133294c433Smrg    fi
2143294c433Smrg    ;;
2153294c433Smrg
2163294c433Smrg  lex|flex)
2173294c433Smrg    echo 1>&2 "\
2183294c433SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2193294c433Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2203294c433Smrg         in order for those modifications to take effect.  You can get
2213294c433Smrg         \`Flex' from any GNU archive site."
2223294c433Smrg    rm -f lex.yy.c
2233294c433Smrg    if [ $# -ne 1 ]; then
2243294c433Smrg        eval LASTARG="\${$#}"
2253294c433Smrg	case "$LASTARG" in
2263294c433Smrg	*.l)
2273294c433Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2283294c433Smrg	    if [ -f "$SRCFILE" ]; then
2293294c433Smrg	         cp "$SRCFILE" lex.yy.c
2303294c433Smrg	    fi
2313294c433Smrg	  ;;
2323294c433Smrg	esac
2333294c433Smrg    fi
2343294c433Smrg    if [ ! -f lex.yy.c ]; then
2353294c433Smrg	echo 'main() { return 0; }' >lex.yy.c
2363294c433Smrg    fi
2373294c433Smrg    ;;
2383294c433Smrg
2393294c433Smrg  help2man)
2403294c433Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
2413294c433Smrg       # We have it, but it failed.
2423294c433Smrg       exit 1
2433294c433Smrg    fi
2443294c433Smrg
2453294c433Smrg    echo 1>&2 "\
2463294c433SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2473294c433Smrg	 you modified a dependency of a manual page.  You may need the
2483294c433Smrg	 \`Help2man' package in order for those modifications to take
2493294c433Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2503294c433Smrg
2513294c433Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2523294c433Smrg    if test -z "$file"; then
2533294c433Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2543294c433Smrg    fi
2553294c433Smrg    if [ -f "$file" ]; then
2563294c433Smrg	touch $file
2573294c433Smrg    else
2583294c433Smrg	test -z "$file" || exec >$file
2593294c433Smrg	echo ".ab help2man is required to generate this page"
2603294c433Smrg	exit 1
2613294c433Smrg    fi
2623294c433Smrg    ;;
2633294c433Smrg
2643294c433Smrg  makeinfo)
2653294c433Smrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
2663294c433Smrg       # We have makeinfo, but it failed.
2673294c433Smrg       exit 1
2683294c433Smrg    fi
2693294c433Smrg
2703294c433Smrg    echo 1>&2 "\
2713294c433SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2723294c433Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2733294c433Smrg         indirectly affecting the aspect of the manual.  The spurious
2743294c433Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2753294c433Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2763294c433Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2773294c433Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2783294c433Smrg    if test -z "$file"; then
2793294c433Smrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2803294c433Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
2813294c433Smrg    fi
2823294c433Smrg    touch $file
2833294c433Smrg    ;;
2843294c433Smrg
2853294c433Smrg  tar)
2863294c433Smrg    shift
2873294c433Smrg    if test -n "$run"; then
2883294c433Smrg      echo 1>&2 "ERROR: \`tar' requires --run"
2893294c433Smrg      exit 1
2903294c433Smrg    fi
2913294c433Smrg
2923294c433Smrg    # We have already tried tar in the generic part.
2933294c433Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
2943294c433Smrg    # messages.
2953294c433Smrg    if (gnutar --version > /dev/null 2>&1); then
2963294c433Smrg       gnutar "$@" && exit 0
2973294c433Smrg    fi
2983294c433Smrg    if (gtar --version > /dev/null 2>&1); then
2993294c433Smrg       gtar "$@" && exit 0
3003294c433Smrg    fi
3013294c433Smrg    firstarg="$1"
3023294c433Smrg    if shift; then
3033294c433Smrg	case "$firstarg" in
3043294c433Smrg	*o*)
3053294c433Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3063294c433Smrg	    tar "$firstarg" "$@" && exit 0
3073294c433Smrg	    ;;
3083294c433Smrg	esac
3093294c433Smrg	case "$firstarg" in
3103294c433Smrg	*h*)
3113294c433Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3123294c433Smrg	    tar "$firstarg" "$@" && exit 0
3133294c433Smrg	    ;;
3143294c433Smrg	esac
3153294c433Smrg    fi
3163294c433Smrg
3173294c433Smrg    echo 1>&2 "\
3183294c433SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3193294c433Smrg         You may want to install GNU tar or Free paxutils, or check the
3203294c433Smrg         command line arguments."
3213294c433Smrg    exit 1
3223294c433Smrg    ;;
3233294c433Smrg
3243294c433Smrg  *)
3253294c433Smrg    echo 1>&2 "\
3263294c433SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
3273294c433Smrg         system.  You might have modified some files without having the
3283294c433Smrg         proper tools for further handling them.  Check the \`README' file,
3293294c433Smrg         it often tells you about the needed prerequisites for installing
3303294c433Smrg         this package.  You may also peek at any GNU archive site, in case
3313294c433Smrg         some other package would contain this missing \`$1' program."
3323294c433Smrg    exit 1
3333294c433Smrg    ;;
3343294c433Smrgesac
3353294c433Smrg
3363294c433Smrgexit 0
337