missing revision 0bd0e222
10bd0e222Smrg#! /bin/sh
20bd0e222Smrg# Common stub for a few missing GNU programs while installing.
30bd0e222Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
40bd0e222Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
50bd0e222Smrg
60bd0e222Smrg# This program is free software; you can redistribute it and/or modify
70bd0e222Smrg# it under the terms of the GNU General Public License as published by
80bd0e222Smrg# the Free Software Foundation; either version 2, or (at your option)
90bd0e222Smrg# any later version.
100bd0e222Smrg
110bd0e222Smrg# This program is distributed in the hope that it will be useful,
120bd0e222Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
130bd0e222Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
140bd0e222Smrg# GNU General Public License for more details.
150bd0e222Smrg
160bd0e222Smrg# You should have received a copy of the GNU General Public License
170bd0e222Smrg# along with this program; if not, write to the Free Software
180bd0e222Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
190bd0e222Smrg# 02111-1307, USA.
200bd0e222Smrg
210bd0e222Smrg# As a special exception to the GNU General Public License, if you
220bd0e222Smrg# distribute this file as part of a program that contains a
230bd0e222Smrg# configuration script generated by Autoconf, you may include it under
240bd0e222Smrg# the same distribution terms that you use for the rest of that program.
250bd0e222Smrg
260bd0e222Smrgif test $# -eq 0; then
270bd0e222Smrg  echo 1>&2 "Try \`$0 --help' for more information"
280bd0e222Smrg  exit 1
290bd0e222Smrgfi
300bd0e222Smrg
310bd0e222Smrgrun=:
320bd0e222Smrg
330bd0e222Smrg# In the cases where this matters, `missing' is being run in the
340bd0e222Smrg# srcdir already.
350bd0e222Smrgif test -f configure.ac; then
360bd0e222Smrg  configure_ac=configure.ac
370bd0e222Smrgelse
380bd0e222Smrg  configure_ac=configure.in
390bd0e222Smrgfi
400bd0e222Smrg
410bd0e222Smrgcase "$1" in
420bd0e222Smrg--run)
430bd0e222Smrg  # Try to run requested program, and just exit if it succeeds.
440bd0e222Smrg  run=
450bd0e222Smrg  shift
460bd0e222Smrg  "$@" && exit 0
470bd0e222Smrg  ;;
480bd0e222Smrgesac
490bd0e222Smrg
500bd0e222Smrg# If it does not exist, or fails to run (possibly an outdated version),
510bd0e222Smrg# try to emulate it.
520bd0e222Smrgcase "$1" in
530bd0e222Smrg
540bd0e222Smrg  -h|--h|--he|--hel|--help)
550bd0e222Smrg    echo "\
560bd0e222Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
570bd0e222Smrg
580bd0e222SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
590bd0e222Smrgerror status if there is no known handling for PROGRAM.
600bd0e222Smrg
610bd0e222SmrgOptions:
620bd0e222Smrg  -h, --help      display this help and exit
630bd0e222Smrg  -v, --version   output version information and exit
640bd0e222Smrg  --run           try to run the given command, and emulate it if it fails
650bd0e222Smrg
660bd0e222SmrgSupported PROGRAM values:
670bd0e222Smrg  aclocal      touch file \`aclocal.m4'
680bd0e222Smrg  autoconf     touch file \`configure'
690bd0e222Smrg  autoheader   touch file \`config.h.in'
700bd0e222Smrg  automake     touch all \`Makefile.in' files
710bd0e222Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
720bd0e222Smrg  flex         create \`lex.yy.c', if possible, from existing .c
730bd0e222Smrg  help2man     touch the output file
740bd0e222Smrg  lex          create \`lex.yy.c', if possible, from existing .c
750bd0e222Smrg  makeinfo     touch the output file
760bd0e222Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
770bd0e222Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
780bd0e222Smrg    ;;
790bd0e222Smrg
800bd0e222Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
810bd0e222Smrg    echo "missing 0.4 - GNU automake"
820bd0e222Smrg    ;;
830bd0e222Smrg
840bd0e222Smrg  -*)
850bd0e222Smrg    echo 1>&2 "$0: Unknown \`$1' option"
860bd0e222Smrg    echo 1>&2 "Try \`$0 --help' for more information"
870bd0e222Smrg    exit 1
880bd0e222Smrg    ;;
890bd0e222Smrg
900bd0e222Smrg  aclocal*)
910bd0e222Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
920bd0e222Smrg       # We have it, but it failed.
930bd0e222Smrg       exit 1
940bd0e222Smrg    fi
950bd0e222Smrg
960bd0e222Smrg    echo 1>&2 "\
970bd0e222SmrgWARNING: \`$1' is missing on your system.  You should only need it if
980bd0e222Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
990bd0e222Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1000bd0e222Smrg         any GNU archive site."
1010bd0e222Smrg    touch aclocal.m4
1020bd0e222Smrg    ;;
1030bd0e222Smrg
1040bd0e222Smrg  autoconf)
1050bd0e222Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1060bd0e222Smrg       # We have it, but it failed.
1070bd0e222Smrg       exit 1
1080bd0e222Smrg    fi
1090bd0e222Smrg
1100bd0e222Smrg    echo 1>&2 "\
1110bd0e222SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1120bd0e222Smrg         you modified \`${configure_ac}'.  You might want to install the
1130bd0e222Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1140bd0e222Smrg         archive site."
1150bd0e222Smrg    touch configure
1160bd0e222Smrg    ;;
1170bd0e222Smrg
1180bd0e222Smrg  autoheader)
1190bd0e222Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1200bd0e222Smrg       # We have it, but it failed.
1210bd0e222Smrg       exit 1
1220bd0e222Smrg    fi
1230bd0e222Smrg
1240bd0e222Smrg    echo 1>&2 "\
1250bd0e222SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1260bd0e222Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1270bd0e222Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1280bd0e222Smrg         from any GNU archive site."
1290bd0e222Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1300bd0e222Smrg    test -z "$files" && files="config.h"
1310bd0e222Smrg    touch_files=
1320bd0e222Smrg    for f in $files; do
1330bd0e222Smrg      case "$f" in
1340bd0e222Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1350bd0e222Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1360bd0e222Smrg      *) touch_files="$touch_files $f.in";;
1370bd0e222Smrg      esac
1380bd0e222Smrg    done
1390bd0e222Smrg    touch $touch_files
1400bd0e222Smrg    ;;
1410bd0e222Smrg
1420bd0e222Smrg  automake*)
1430bd0e222Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1440bd0e222Smrg       # We have it, but it failed.
1450bd0e222Smrg       exit 1
1460bd0e222Smrg    fi
1470bd0e222Smrg
1480bd0e222Smrg    echo 1>&2 "\
1490bd0e222SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1500bd0e222Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1510bd0e222Smrg         You might want to install the \`Automake' and \`Perl' packages.
1520bd0e222Smrg         Grab them from any GNU archive site."
1530bd0e222Smrg    find . -type f -name Makefile.am -print |
1540bd0e222Smrg	   sed 's/\.am$/.in/' |
1550bd0e222Smrg	   while read f; do touch "$f"; done
1560bd0e222Smrg    ;;
1570bd0e222Smrg
1580bd0e222Smrg  autom4te)
1590bd0e222Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1600bd0e222Smrg       # We have it, but it failed.
1610bd0e222Smrg       exit 1
1620bd0e222Smrg    fi
1630bd0e222Smrg
1640bd0e222Smrg    echo 1>&2 "\
1650bd0e222SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
1660bd0e222Smrg         system.  You might have modified some files without having the
1670bd0e222Smrg         proper tools for further handling them.
1680bd0e222Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1690bd0e222Smrg         archive site."
1700bd0e222Smrg
1710bd0e222Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
1720bd0e222Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
1730bd0e222Smrg    if test -f "$file"; then
1740bd0e222Smrg	touch $file
1750bd0e222Smrg    else
1760bd0e222Smrg	test -z "$file" || exec >$file
1770bd0e222Smrg	echo "#! /bin/sh"
1780bd0e222Smrg	echo "# Created by GNU Automake missing as a replacement of"
1790bd0e222Smrg	echo "#  $ $@"
1800bd0e222Smrg	echo "exit 0"
1810bd0e222Smrg	chmod +x $file
1820bd0e222Smrg	exit 1
1830bd0e222Smrg    fi
1840bd0e222Smrg    ;;
1850bd0e222Smrg
1860bd0e222Smrg  bison|yacc)
1870bd0e222Smrg    echo 1>&2 "\
1880bd0e222SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1890bd0e222Smrg         you modified a \`.y' file.  You may need the \`Bison' package
1900bd0e222Smrg         in order for those modifications to take effect.  You can get
1910bd0e222Smrg         \`Bison' from any GNU archive site."
1920bd0e222Smrg    rm -f y.tab.c y.tab.h
1930bd0e222Smrg    if [ $# -ne 1 ]; then
1940bd0e222Smrg        eval LASTARG="\${$#}"
1950bd0e222Smrg	case "$LASTARG" in
1960bd0e222Smrg	*.y)
1970bd0e222Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
1980bd0e222Smrg	    if [ -f "$SRCFILE" ]; then
1990bd0e222Smrg	         cp "$SRCFILE" y.tab.c
2000bd0e222Smrg	    fi
2010bd0e222Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2020bd0e222Smrg	    if [ -f "$SRCFILE" ]; then
2030bd0e222Smrg	         cp "$SRCFILE" y.tab.h
2040bd0e222Smrg	    fi
2050bd0e222Smrg	  ;;
2060bd0e222Smrg	esac
2070bd0e222Smrg    fi
2080bd0e222Smrg    if [ ! -f y.tab.h ]; then
2090bd0e222Smrg	echo >y.tab.h
2100bd0e222Smrg    fi
2110bd0e222Smrg    if [ ! -f y.tab.c ]; then
2120bd0e222Smrg	echo 'main() { return 0; }' >y.tab.c
2130bd0e222Smrg    fi
2140bd0e222Smrg    ;;
2150bd0e222Smrg
2160bd0e222Smrg  lex|flex)
2170bd0e222Smrg    echo 1>&2 "\
2180bd0e222SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2190bd0e222Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2200bd0e222Smrg         in order for those modifications to take effect.  You can get
2210bd0e222Smrg         \`Flex' from any GNU archive site."
2220bd0e222Smrg    rm -f lex.yy.c
2230bd0e222Smrg    if [ $# -ne 1 ]; then
2240bd0e222Smrg        eval LASTARG="\${$#}"
2250bd0e222Smrg	case "$LASTARG" in
2260bd0e222Smrg	*.l)
2270bd0e222Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2280bd0e222Smrg	    if [ -f "$SRCFILE" ]; then
2290bd0e222Smrg	         cp "$SRCFILE" lex.yy.c
2300bd0e222Smrg	    fi
2310bd0e222Smrg	  ;;
2320bd0e222Smrg	esac
2330bd0e222Smrg    fi
2340bd0e222Smrg    if [ ! -f lex.yy.c ]; then
2350bd0e222Smrg	echo 'main() { return 0; }' >lex.yy.c
2360bd0e222Smrg    fi
2370bd0e222Smrg    ;;
2380bd0e222Smrg
2390bd0e222Smrg  help2man)
2400bd0e222Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
2410bd0e222Smrg       # We have it, but it failed.
2420bd0e222Smrg       exit 1
2430bd0e222Smrg    fi
2440bd0e222Smrg
2450bd0e222Smrg    echo 1>&2 "\
2460bd0e222SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2470bd0e222Smrg	 you modified a dependency of a manual page.  You may need the
2480bd0e222Smrg	 \`Help2man' package in order for those modifications to take
2490bd0e222Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2500bd0e222Smrg
2510bd0e222Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2520bd0e222Smrg    if test -z "$file"; then
2530bd0e222Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2540bd0e222Smrg    fi
2550bd0e222Smrg    if [ -f "$file" ]; then
2560bd0e222Smrg	touch $file
2570bd0e222Smrg    else
2580bd0e222Smrg	test -z "$file" || exec >$file
2590bd0e222Smrg	echo ".ab help2man is required to generate this page"
2600bd0e222Smrg	exit 1
2610bd0e222Smrg    fi
2620bd0e222Smrg    ;;
2630bd0e222Smrg
2640bd0e222Smrg  makeinfo)
2650bd0e222Smrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
2660bd0e222Smrg       # We have makeinfo, but it failed.
2670bd0e222Smrg       exit 1
2680bd0e222Smrg    fi
2690bd0e222Smrg
2700bd0e222Smrg    echo 1>&2 "\
2710bd0e222SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2720bd0e222Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2730bd0e222Smrg         indirectly affecting the aspect of the manual.  The spurious
2740bd0e222Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2750bd0e222Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2760bd0e222Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2770bd0e222Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2780bd0e222Smrg    if test -z "$file"; then
2790bd0e222Smrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2800bd0e222Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
2810bd0e222Smrg    fi
2820bd0e222Smrg    touch $file
2830bd0e222Smrg    ;;
2840bd0e222Smrg
2850bd0e222Smrg  tar)
2860bd0e222Smrg    shift
2870bd0e222Smrg    if test -n "$run"; then
2880bd0e222Smrg      echo 1>&2 "ERROR: \`tar' requires --run"
2890bd0e222Smrg      exit 1
2900bd0e222Smrg    fi
2910bd0e222Smrg
2920bd0e222Smrg    # We have already tried tar in the generic part.
2930bd0e222Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
2940bd0e222Smrg    # messages.
2950bd0e222Smrg    if (gnutar --version > /dev/null 2>&1); then
2960bd0e222Smrg       gnutar "$@" && exit 0
2970bd0e222Smrg    fi
2980bd0e222Smrg    if (gtar --version > /dev/null 2>&1); then
2990bd0e222Smrg       gtar "$@" && exit 0
3000bd0e222Smrg    fi
3010bd0e222Smrg    firstarg="$1"
3020bd0e222Smrg    if shift; then
3030bd0e222Smrg	case "$firstarg" in
3040bd0e222Smrg	*o*)
3050bd0e222Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3060bd0e222Smrg	    tar "$firstarg" "$@" && exit 0
3070bd0e222Smrg	    ;;
3080bd0e222Smrg	esac
3090bd0e222Smrg	case "$firstarg" in
3100bd0e222Smrg	*h*)
3110bd0e222Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3120bd0e222Smrg	    tar "$firstarg" "$@" && exit 0
3130bd0e222Smrg	    ;;
3140bd0e222Smrg	esac
3150bd0e222Smrg    fi
3160bd0e222Smrg
3170bd0e222Smrg    echo 1>&2 "\
3180bd0e222SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3190bd0e222Smrg         You may want to install GNU tar or Free paxutils, or check the
3200bd0e222Smrg         command line arguments."
3210bd0e222Smrg    exit 1
3220bd0e222Smrg    ;;
3230bd0e222Smrg
3240bd0e222Smrg  *)
3250bd0e222Smrg    echo 1>&2 "\
3260bd0e222SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
3270bd0e222Smrg         system.  You might have modified some files without having the
3280bd0e222Smrg         proper tools for further handling them.  Check the \`README' file,
3290bd0e222Smrg         it often tells you about the needed prerequisites for installing
3300bd0e222Smrg         this package.  You may also peek at any GNU archive site, in case
3310bd0e222Smrg         some other package would contain this missing \`$1' program."
3320bd0e222Smrg    exit 1
3330bd0e222Smrg    ;;
3340bd0e222Smrgesac
3350bd0e222Smrg
3360bd0e222Smrgexit 0
337