14963b7b6Smrg#! /bin/sh
24963b7b6Smrg# Common stub for a few missing GNU programs while installing.
34963b7b6Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
44963b7b6Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
54963b7b6Smrg
64963b7b6Smrg# This program is free software; you can redistribute it and/or modify
74963b7b6Smrg# it under the terms of the GNU General Public License as published by
84963b7b6Smrg# the Free Software Foundation; either version 2, or (at your option)
94963b7b6Smrg# any later version.
104963b7b6Smrg
114963b7b6Smrg# This program is distributed in the hope that it will be useful,
124963b7b6Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
134963b7b6Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
144963b7b6Smrg# GNU General Public License for more details.
154963b7b6Smrg
164963b7b6Smrg# You should have received a copy of the GNU General Public License
174963b7b6Smrg# along with this program; if not, write to the Free Software
184963b7b6Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
194963b7b6Smrg# 02111-1307, USA.
204963b7b6Smrg
214963b7b6Smrg# As a special exception to the GNU General Public License, if you
224963b7b6Smrg# distribute this file as part of a program that contains a
234963b7b6Smrg# configuration script generated by Autoconf, you may include it under
244963b7b6Smrg# the same distribution terms that you use for the rest of that program.
254963b7b6Smrg
264963b7b6Smrgif test $# -eq 0; then
274963b7b6Smrg  echo 1>&2 "Try \`$0 --help' for more information"
284963b7b6Smrg  exit 1
294963b7b6Smrgfi
304963b7b6Smrg
314963b7b6Smrgrun=:
324963b7b6Smrg
334963b7b6Smrg# In the cases where this matters, `missing' is being run in the
344963b7b6Smrg# srcdir already.
354963b7b6Smrgif test -f configure.ac; then
364963b7b6Smrg  configure_ac=configure.ac
374963b7b6Smrgelse
384963b7b6Smrg  configure_ac=configure.in
394963b7b6Smrgfi
404963b7b6Smrg
414963b7b6Smrgcase "$1" in
424963b7b6Smrg--run)
434963b7b6Smrg  # Try to run requested program, and just exit if it succeeds.
444963b7b6Smrg  run=
454963b7b6Smrg  shift
464963b7b6Smrg  "$@" && exit 0
474963b7b6Smrg  ;;
484963b7b6Smrgesac
494963b7b6Smrg
504963b7b6Smrg# If it does not exist, or fails to run (possibly an outdated version),
514963b7b6Smrg# try to emulate it.
524963b7b6Smrgcase "$1" in
534963b7b6Smrg
544963b7b6Smrg  -h|--h|--he|--hel|--help)
554963b7b6Smrg    echo "\
564963b7b6Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
574963b7b6Smrg
584963b7b6SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
594963b7b6Smrgerror status if there is no known handling for PROGRAM.
604963b7b6Smrg
614963b7b6SmrgOptions:
624963b7b6Smrg  -h, --help      display this help and exit
634963b7b6Smrg  -v, --version   output version information and exit
644963b7b6Smrg  --run           try to run the given command, and emulate it if it fails
654963b7b6Smrg
664963b7b6SmrgSupported PROGRAM values:
674963b7b6Smrg  aclocal      touch file \`aclocal.m4'
684963b7b6Smrg  autoconf     touch file \`configure'
694963b7b6Smrg  autoheader   touch file \`config.h.in'
704963b7b6Smrg  automake     touch all \`Makefile.in' files
714963b7b6Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
724963b7b6Smrg  flex         create \`lex.yy.c', if possible, from existing .c
734963b7b6Smrg  help2man     touch the output file
744963b7b6Smrg  lex          create \`lex.yy.c', if possible, from existing .c
754963b7b6Smrg  makeinfo     touch the output file
764963b7b6Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
774963b7b6Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
784963b7b6Smrg    ;;
794963b7b6Smrg
804963b7b6Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
814963b7b6Smrg    echo "missing 0.4 - GNU automake"
824963b7b6Smrg    ;;
834963b7b6Smrg
844963b7b6Smrg  -*)
854963b7b6Smrg    echo 1>&2 "$0: Unknown \`$1' option"
864963b7b6Smrg    echo 1>&2 "Try \`$0 --help' for more information"
874963b7b6Smrg    exit 1
884963b7b6Smrg    ;;
894963b7b6Smrg
904963b7b6Smrg  aclocal*)
914963b7b6Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
924963b7b6Smrg       # We have it, but it failed.
934963b7b6Smrg       exit 1
944963b7b6Smrg    fi
954963b7b6Smrg
964963b7b6Smrg    echo 1>&2 "\
974963b7b6SmrgWARNING: \`$1' is missing on your system.  You should only need it if
984963b7b6Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
994963b7b6Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1004963b7b6Smrg         any GNU archive site."
1014963b7b6Smrg    touch aclocal.m4
1024963b7b6Smrg    ;;
1034963b7b6Smrg
1044963b7b6Smrg  autoconf)
1054963b7b6Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1064963b7b6Smrg       # We have it, but it failed.
1074963b7b6Smrg       exit 1
1084963b7b6Smrg    fi
1094963b7b6Smrg
1104963b7b6Smrg    echo 1>&2 "\
1114963b7b6SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1124963b7b6Smrg         you modified \`${configure_ac}'.  You might want to install the
1134963b7b6Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1144963b7b6Smrg         archive site."
1154963b7b6Smrg    touch configure
1164963b7b6Smrg    ;;
1174963b7b6Smrg
1184963b7b6Smrg  autoheader)
1194963b7b6Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1204963b7b6Smrg       # We have it, but it failed.
1214963b7b6Smrg       exit 1
1224963b7b6Smrg    fi
1234963b7b6Smrg
1244963b7b6Smrg    echo 1>&2 "\
1254963b7b6SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1264963b7b6Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1274963b7b6Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1284963b7b6Smrg         from any GNU archive site."
1294963b7b6Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1304963b7b6Smrg    test -z "$files" && files="config.h"
1314963b7b6Smrg    touch_files=
1324963b7b6Smrg    for f in $files; do
1334963b7b6Smrg      case "$f" in
1344963b7b6Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1354963b7b6Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1364963b7b6Smrg      *) touch_files="$touch_files $f.in";;
1374963b7b6Smrg      esac
1384963b7b6Smrg    done
1394963b7b6Smrg    touch $touch_files
1404963b7b6Smrg    ;;
1414963b7b6Smrg
1424963b7b6Smrg  automake*)
1434963b7b6Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1444963b7b6Smrg       # We have it, but it failed.
1454963b7b6Smrg       exit 1
1464963b7b6Smrg    fi
1474963b7b6Smrg
1484963b7b6Smrg    echo 1>&2 "\
1494963b7b6SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1504963b7b6Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1514963b7b6Smrg         You might want to install the \`Automake' and \`Perl' packages.
1524963b7b6Smrg         Grab them from any GNU archive site."
1534963b7b6Smrg    find . -type f -name Makefile.am -print |
1544963b7b6Smrg	   sed 's/\.am$/.in/' |
1554963b7b6Smrg	   while read f; do touch "$f"; done
1564963b7b6Smrg    ;;
1574963b7b6Smrg
1584963b7b6Smrg  autom4te)
1594963b7b6Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1604963b7b6Smrg       # We have it, but it failed.
1614963b7b6Smrg       exit 1
1624963b7b6Smrg    fi
1634963b7b6Smrg
1644963b7b6Smrg    echo 1>&2 "\
1654963b7b6SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
1664963b7b6Smrg         system.  You might have modified some files without having the
1674963b7b6Smrg         proper tools for further handling them.
1684963b7b6Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1694963b7b6Smrg         archive site."
1704963b7b6Smrg
1714963b7b6Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
1724963b7b6Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
1734963b7b6Smrg    if test -f "$file"; then
1744963b7b6Smrg	touch $file
1754963b7b6Smrg    else
1764963b7b6Smrg	test -z "$file" || exec >$file
1774963b7b6Smrg	echo "#! /bin/sh"
1784963b7b6Smrg	echo "# Created by GNU Automake missing as a replacement of"
1794963b7b6Smrg	echo "#  $ $@"
1804963b7b6Smrg	echo "exit 0"
1814963b7b6Smrg	chmod +x $file
1824963b7b6Smrg	exit 1
1834963b7b6Smrg    fi
1844963b7b6Smrg    ;;
1854963b7b6Smrg
1864963b7b6Smrg  bison|yacc)
1874963b7b6Smrg    echo 1>&2 "\
1884963b7b6SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1894963b7b6Smrg         you modified a \`.y' file.  You may need the \`Bison' package
1904963b7b6Smrg         in order for those modifications to take effect.  You can get
1914963b7b6Smrg         \`Bison' from any GNU archive site."
1924963b7b6Smrg    rm -f y.tab.c y.tab.h
1934963b7b6Smrg    if [ $# -ne 1 ]; then
1944963b7b6Smrg        eval LASTARG="\${$#}"
1954963b7b6Smrg	case "$LASTARG" in
1964963b7b6Smrg	*.y)
1974963b7b6Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
1984963b7b6Smrg	    if [ -f "$SRCFILE" ]; then
1994963b7b6Smrg	         cp "$SRCFILE" y.tab.c
2004963b7b6Smrg	    fi
2014963b7b6Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2024963b7b6Smrg	    if [ -f "$SRCFILE" ]; then
2034963b7b6Smrg	         cp "$SRCFILE" y.tab.h
2044963b7b6Smrg	    fi
2054963b7b6Smrg	  ;;
2064963b7b6Smrg	esac
2074963b7b6Smrg    fi
2084963b7b6Smrg    if [ ! -f y.tab.h ]; then
2094963b7b6Smrg	echo >y.tab.h
2104963b7b6Smrg    fi
2114963b7b6Smrg    if [ ! -f y.tab.c ]; then
2124963b7b6Smrg	echo 'main() { return 0; }' >y.tab.c
2134963b7b6Smrg    fi
2144963b7b6Smrg    ;;
2154963b7b6Smrg
2164963b7b6Smrg  lex|flex)
2174963b7b6Smrg    echo 1>&2 "\
2184963b7b6SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2194963b7b6Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2204963b7b6Smrg         in order for those modifications to take effect.  You can get
2214963b7b6Smrg         \`Flex' from any GNU archive site."
2224963b7b6Smrg    rm -f lex.yy.c
2234963b7b6Smrg    if [ $# -ne 1 ]; then
2244963b7b6Smrg        eval LASTARG="\${$#}"
2254963b7b6Smrg	case "$LASTARG" in
2264963b7b6Smrg	*.l)
2274963b7b6Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2284963b7b6Smrg	    if [ -f "$SRCFILE" ]; then
2294963b7b6Smrg	         cp "$SRCFILE" lex.yy.c
2304963b7b6Smrg	    fi
2314963b7b6Smrg	  ;;
2324963b7b6Smrg	esac
2334963b7b6Smrg    fi
2344963b7b6Smrg    if [ ! -f lex.yy.c ]; then
2354963b7b6Smrg	echo 'main() { return 0; }' >lex.yy.c
2364963b7b6Smrg    fi
2374963b7b6Smrg    ;;
2384963b7b6Smrg
2394963b7b6Smrg  help2man)
2404963b7b6Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
2414963b7b6Smrg       # We have it, but it failed.
2424963b7b6Smrg       exit 1
2434963b7b6Smrg    fi
2444963b7b6Smrg
2454963b7b6Smrg    echo 1>&2 "\
2464963b7b6SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2474963b7b6Smrg	 you modified a dependency of a manual page.  You may need the
2484963b7b6Smrg	 \`Help2man' package in order for those modifications to take
2494963b7b6Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2504963b7b6Smrg
2514963b7b6Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2524963b7b6Smrg    if test -z "$file"; then
2534963b7b6Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2544963b7b6Smrg    fi
2554963b7b6Smrg    if [ -f "$file" ]; then
2564963b7b6Smrg	touch $file
2574963b7b6Smrg    else
2584963b7b6Smrg	test -z "$file" || exec >$file
2594963b7b6Smrg	echo ".ab help2man is required to generate this page"
2604963b7b6Smrg	exit 1
2614963b7b6Smrg    fi
2624963b7b6Smrg    ;;
2634963b7b6Smrg
2644963b7b6Smrg  makeinfo)
2654963b7b6Smrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
2664963b7b6Smrg       # We have makeinfo, but it failed.
2674963b7b6Smrg       exit 1
2684963b7b6Smrg    fi
2694963b7b6Smrg
2704963b7b6Smrg    echo 1>&2 "\
2714963b7b6SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2724963b7b6Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2734963b7b6Smrg         indirectly affecting the aspect of the manual.  The spurious
2744963b7b6Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2754963b7b6Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2764963b7b6Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2774963b7b6Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2784963b7b6Smrg    if test -z "$file"; then
2794963b7b6Smrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2804963b7b6Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
2814963b7b6Smrg    fi
2824963b7b6Smrg    touch $file
2834963b7b6Smrg    ;;
2844963b7b6Smrg
2854963b7b6Smrg  tar)
2864963b7b6Smrg    shift
2874963b7b6Smrg    if test -n "$run"; then
2884963b7b6Smrg      echo 1>&2 "ERROR: \`tar' requires --run"
2894963b7b6Smrg      exit 1
2904963b7b6Smrg    fi
2914963b7b6Smrg
2924963b7b6Smrg    # We have already tried tar in the generic part.
2934963b7b6Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
2944963b7b6Smrg    # messages.
2954963b7b6Smrg    if (gnutar --version > /dev/null 2>&1); then
2964963b7b6Smrg       gnutar "$@" && exit 0
2974963b7b6Smrg    fi
2984963b7b6Smrg    if (gtar --version > /dev/null 2>&1); then
2994963b7b6Smrg       gtar "$@" && exit 0
3004963b7b6Smrg    fi
3014963b7b6Smrg    firstarg="$1"
3024963b7b6Smrg    if shift; then
3034963b7b6Smrg	case "$firstarg" in
3044963b7b6Smrg	*o*)
3054963b7b6Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3064963b7b6Smrg	    tar "$firstarg" "$@" && exit 0
3074963b7b6Smrg	    ;;
3084963b7b6Smrg	esac
3094963b7b6Smrg	case "$firstarg" in
3104963b7b6Smrg	*h*)
3114963b7b6Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3124963b7b6Smrg	    tar "$firstarg" "$@" && exit 0
3134963b7b6Smrg	    ;;
3144963b7b6Smrg	esac
3154963b7b6Smrg    fi
3164963b7b6Smrg
3174963b7b6Smrg    echo 1>&2 "\
3184963b7b6SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3194963b7b6Smrg         You may want to install GNU tar or Free paxutils, or check the
3204963b7b6Smrg         command line arguments."
3214963b7b6Smrg    exit 1
3224963b7b6Smrg    ;;
3234963b7b6Smrg
3244963b7b6Smrg  *)
3254963b7b6Smrg    echo 1>&2 "\
3264963b7b6SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
3274963b7b6Smrg         system.  You might have modified some files without having the
3284963b7b6Smrg         proper tools for further handling them.  Check the \`README' file,
3294963b7b6Smrg         it often tells you about the needed prerequisites for installing
3304963b7b6Smrg         this package.  You may also peek at any GNU archive site, in case
3314963b7b6Smrg         some other package would contain this missing \`$1' program."
3324963b7b6Smrg    exit 1
3334963b7b6Smrg    ;;
3344963b7b6Smrgesac
3354963b7b6Smrg
3364963b7b6Smrgexit 0
337