missing revision 4fb28925
14fb28925Smrg#! /bin/sh
24fb28925Smrg# Common stub for a few missing GNU programs while installing.
34fb28925Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
44fb28925Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
54fb28925Smrg
64fb28925Smrg# This program is free software; you can redistribute it and/or modify
74fb28925Smrg# it under the terms of the GNU General Public License as published by
84fb28925Smrg# the Free Software Foundation; either version 2, or (at your option)
94fb28925Smrg# any later version.
104fb28925Smrg
114fb28925Smrg# This program is distributed in the hope that it will be useful,
124fb28925Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
134fb28925Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
144fb28925Smrg# GNU General Public License for more details.
154fb28925Smrg
164fb28925Smrg# You should have received a copy of the GNU General Public License
174fb28925Smrg# along with this program; if not, write to the Free Software
184fb28925Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
194fb28925Smrg# 02111-1307, USA.
204fb28925Smrg
214fb28925Smrg# As a special exception to the GNU General Public License, if you
224fb28925Smrg# distribute this file as part of a program that contains a
234fb28925Smrg# configuration script generated by Autoconf, you may include it under
244fb28925Smrg# the same distribution terms that you use for the rest of that program.
254fb28925Smrg
264fb28925Smrgif test $# -eq 0; then
274fb28925Smrg  echo 1>&2 "Try \`$0 --help' for more information"
284fb28925Smrg  exit 1
294fb28925Smrgfi
304fb28925Smrg
314fb28925Smrgrun=:
324fb28925Smrg
334fb28925Smrg# In the cases where this matters, `missing' is being run in the
344fb28925Smrg# srcdir already.
354fb28925Smrgif test -f configure.ac; then
364fb28925Smrg  configure_ac=configure.ac
374fb28925Smrgelse
384fb28925Smrg  configure_ac=configure.in
394fb28925Smrgfi
404fb28925Smrg
414fb28925Smrgcase "$1" in
424fb28925Smrg--run)
434fb28925Smrg  # Try to run requested program, and just exit if it succeeds.
444fb28925Smrg  run=
454fb28925Smrg  shift
464fb28925Smrg  "$@" && exit 0
474fb28925Smrg  ;;
484fb28925Smrgesac
494fb28925Smrg
504fb28925Smrg# If it does not exist, or fails to run (possibly an outdated version),
514fb28925Smrg# try to emulate it.
524fb28925Smrgcase "$1" in
534fb28925Smrg
544fb28925Smrg  -h|--h|--he|--hel|--help)
554fb28925Smrg    echo "\
564fb28925Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
574fb28925Smrg
584fb28925SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
594fb28925Smrgerror status if there is no known handling for PROGRAM.
604fb28925Smrg
614fb28925SmrgOptions:
624fb28925Smrg  -h, --help      display this help and exit
634fb28925Smrg  -v, --version   output version information and exit
644fb28925Smrg  --run           try to run the given command, and emulate it if it fails
654fb28925Smrg
664fb28925SmrgSupported PROGRAM values:
674fb28925Smrg  aclocal      touch file \`aclocal.m4'
684fb28925Smrg  autoconf     touch file \`configure'
694fb28925Smrg  autoheader   touch file \`config.h.in'
704fb28925Smrg  automake     touch all \`Makefile.in' files
714fb28925Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
724fb28925Smrg  flex         create \`lex.yy.c', if possible, from existing .c
734fb28925Smrg  help2man     touch the output file
744fb28925Smrg  lex          create \`lex.yy.c', if possible, from existing .c
754fb28925Smrg  makeinfo     touch the output file
764fb28925Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
774fb28925Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
784fb28925Smrg    ;;
794fb28925Smrg
804fb28925Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
814fb28925Smrg    echo "missing 0.4 - GNU automake"
824fb28925Smrg    ;;
834fb28925Smrg
844fb28925Smrg  -*)
854fb28925Smrg    echo 1>&2 "$0: Unknown \`$1' option"
864fb28925Smrg    echo 1>&2 "Try \`$0 --help' for more information"
874fb28925Smrg    exit 1
884fb28925Smrg    ;;
894fb28925Smrg
904fb28925Smrg  aclocal*)
914fb28925Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
924fb28925Smrg       # We have it, but it failed.
934fb28925Smrg       exit 1
944fb28925Smrg    fi
954fb28925Smrg
964fb28925Smrg    echo 1>&2 "\
974fb28925SmrgWARNING: \`$1' is missing on your system.  You should only need it if
984fb28925Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
994fb28925Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1004fb28925Smrg         any GNU archive site."
1014fb28925Smrg    touch aclocal.m4
1024fb28925Smrg    ;;
1034fb28925Smrg
1044fb28925Smrg  autoconf)
1054fb28925Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1064fb28925Smrg       # We have it, but it failed.
1074fb28925Smrg       exit 1
1084fb28925Smrg    fi
1094fb28925Smrg
1104fb28925Smrg    echo 1>&2 "\
1114fb28925SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1124fb28925Smrg         you modified \`${configure_ac}'.  You might want to install the
1134fb28925Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1144fb28925Smrg         archive site."
1154fb28925Smrg    touch configure
1164fb28925Smrg    ;;
1174fb28925Smrg
1184fb28925Smrg  autoheader)
1194fb28925Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1204fb28925Smrg       # We have it, but it failed.
1214fb28925Smrg       exit 1
1224fb28925Smrg    fi
1234fb28925Smrg
1244fb28925Smrg    echo 1>&2 "\
1254fb28925SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1264fb28925Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1274fb28925Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1284fb28925Smrg         from any GNU archive site."
1294fb28925Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1304fb28925Smrg    test -z "$files" && files="config.h"
1314fb28925Smrg    touch_files=
1324fb28925Smrg    for f in $files; do
1334fb28925Smrg      case "$f" in
1344fb28925Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1354fb28925Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1364fb28925Smrg      *) touch_files="$touch_files $f.in";;
1374fb28925Smrg      esac
1384fb28925Smrg    done
1394fb28925Smrg    touch $touch_files
1404fb28925Smrg    ;;
1414fb28925Smrg
1424fb28925Smrg  automake*)
1434fb28925Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1444fb28925Smrg       # We have it, but it failed.
1454fb28925Smrg       exit 1
1464fb28925Smrg    fi
1474fb28925Smrg
1484fb28925Smrg    echo 1>&2 "\
1494fb28925SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1504fb28925Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1514fb28925Smrg         You might want to install the \`Automake' and \`Perl' packages.
1524fb28925Smrg         Grab them from any GNU archive site."
1534fb28925Smrg    find . -type f -name Makefile.am -print |
1544fb28925Smrg	   sed 's/\.am$/.in/' |
1554fb28925Smrg	   while read f; do touch "$f"; done
1564fb28925Smrg    ;;
1574fb28925Smrg
1584fb28925Smrg  autom4te)
1594fb28925Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1604fb28925Smrg       # We have it, but it failed.
1614fb28925Smrg       exit 1
1624fb28925Smrg    fi
1634fb28925Smrg
1644fb28925Smrg    echo 1>&2 "\
1654fb28925SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
1664fb28925Smrg         system.  You might have modified some files without having the
1674fb28925Smrg         proper tools for further handling them.
1684fb28925Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1694fb28925Smrg         archive site."
1704fb28925Smrg
1714fb28925Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
1724fb28925Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
1734fb28925Smrg    if test -f "$file"; then
1744fb28925Smrg	touch $file
1754fb28925Smrg    else
1764fb28925Smrg	test -z "$file" || exec >$file
1774fb28925Smrg	echo "#! /bin/sh"
1784fb28925Smrg	echo "# Created by GNU Automake missing as a replacement of"
1794fb28925Smrg	echo "#  $ $@"
1804fb28925Smrg	echo "exit 0"
1814fb28925Smrg	chmod +x $file
1824fb28925Smrg	exit 1
1834fb28925Smrg    fi
1844fb28925Smrg    ;;
1854fb28925Smrg
1864fb28925Smrg  bison|yacc)
1874fb28925Smrg    echo 1>&2 "\
1884fb28925SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1894fb28925Smrg         you modified a \`.y' file.  You may need the \`Bison' package
1904fb28925Smrg         in order for those modifications to take effect.  You can get
1914fb28925Smrg         \`Bison' from any GNU archive site."
1924fb28925Smrg    rm -f y.tab.c y.tab.h
1934fb28925Smrg    if [ $# -ne 1 ]; then
1944fb28925Smrg        eval LASTARG="\${$#}"
1954fb28925Smrg	case "$LASTARG" in
1964fb28925Smrg	*.y)
1974fb28925Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
1984fb28925Smrg	    if [ -f "$SRCFILE" ]; then
1994fb28925Smrg	         cp "$SRCFILE" y.tab.c
2004fb28925Smrg	    fi
2014fb28925Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2024fb28925Smrg	    if [ -f "$SRCFILE" ]; then
2034fb28925Smrg	         cp "$SRCFILE" y.tab.h
2044fb28925Smrg	    fi
2054fb28925Smrg	  ;;
2064fb28925Smrg	esac
2074fb28925Smrg    fi
2084fb28925Smrg    if [ ! -f y.tab.h ]; then
2094fb28925Smrg	echo >y.tab.h
2104fb28925Smrg    fi
2114fb28925Smrg    if [ ! -f y.tab.c ]; then
2124fb28925Smrg	echo 'main() { return 0; }' >y.tab.c
2134fb28925Smrg    fi
2144fb28925Smrg    ;;
2154fb28925Smrg
2164fb28925Smrg  lex|flex)
2174fb28925Smrg    echo 1>&2 "\
2184fb28925SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2194fb28925Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2204fb28925Smrg         in order for those modifications to take effect.  You can get
2214fb28925Smrg         \`Flex' from any GNU archive site."
2224fb28925Smrg    rm -f lex.yy.c
2234fb28925Smrg    if [ $# -ne 1 ]; then
2244fb28925Smrg        eval LASTARG="\${$#}"
2254fb28925Smrg	case "$LASTARG" in
2264fb28925Smrg	*.l)
2274fb28925Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2284fb28925Smrg	    if [ -f "$SRCFILE" ]; then
2294fb28925Smrg	         cp "$SRCFILE" lex.yy.c
2304fb28925Smrg	    fi
2314fb28925Smrg	  ;;
2324fb28925Smrg	esac
2334fb28925Smrg    fi
2344fb28925Smrg    if [ ! -f lex.yy.c ]; then
2354fb28925Smrg	echo 'main() { return 0; }' >lex.yy.c
2364fb28925Smrg    fi
2374fb28925Smrg    ;;
2384fb28925Smrg
2394fb28925Smrg  help2man)
2404fb28925Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
2414fb28925Smrg       # We have it, but it failed.
2424fb28925Smrg       exit 1
2434fb28925Smrg    fi
2444fb28925Smrg
2454fb28925Smrg    echo 1>&2 "\
2464fb28925SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2474fb28925Smrg	 you modified a dependency of a manual page.  You may need the
2484fb28925Smrg	 \`Help2man' package in order for those modifications to take
2494fb28925Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2504fb28925Smrg
2514fb28925Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2524fb28925Smrg    if test -z "$file"; then
2534fb28925Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2544fb28925Smrg    fi
2554fb28925Smrg    if [ -f "$file" ]; then
2564fb28925Smrg	touch $file
2574fb28925Smrg    else
2584fb28925Smrg	test -z "$file" || exec >$file
2594fb28925Smrg	echo ".ab help2man is required to generate this page"
2604fb28925Smrg	exit 1
2614fb28925Smrg    fi
2624fb28925Smrg    ;;
2634fb28925Smrg
2644fb28925Smrg  makeinfo)
2654fb28925Smrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
2664fb28925Smrg       # We have makeinfo, but it failed.
2674fb28925Smrg       exit 1
2684fb28925Smrg    fi
2694fb28925Smrg
2704fb28925Smrg    echo 1>&2 "\
2714fb28925SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2724fb28925Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2734fb28925Smrg         indirectly affecting the aspect of the manual.  The spurious
2744fb28925Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2754fb28925Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2764fb28925Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2774fb28925Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2784fb28925Smrg    if test -z "$file"; then
2794fb28925Smrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2804fb28925Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
2814fb28925Smrg    fi
2824fb28925Smrg    touch $file
2834fb28925Smrg    ;;
2844fb28925Smrg
2854fb28925Smrg  tar)
2864fb28925Smrg    shift
2874fb28925Smrg    if test -n "$run"; then
2884fb28925Smrg      echo 1>&2 "ERROR: \`tar' requires --run"
2894fb28925Smrg      exit 1
2904fb28925Smrg    fi
2914fb28925Smrg
2924fb28925Smrg    # We have already tried tar in the generic part.
2934fb28925Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
2944fb28925Smrg    # messages.
2954fb28925Smrg    if (gnutar --version > /dev/null 2>&1); then
2964fb28925Smrg       gnutar "$@" && exit 0
2974fb28925Smrg    fi
2984fb28925Smrg    if (gtar --version > /dev/null 2>&1); then
2994fb28925Smrg       gtar "$@" && exit 0
3004fb28925Smrg    fi
3014fb28925Smrg    firstarg="$1"
3024fb28925Smrg    if shift; then
3034fb28925Smrg	case "$firstarg" in
3044fb28925Smrg	*o*)
3054fb28925Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3064fb28925Smrg	    tar "$firstarg" "$@" && exit 0
3074fb28925Smrg	    ;;
3084fb28925Smrg	esac
3094fb28925Smrg	case "$firstarg" in
3104fb28925Smrg	*h*)
3114fb28925Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3124fb28925Smrg	    tar "$firstarg" "$@" && exit 0
3134fb28925Smrg	    ;;
3144fb28925Smrg	esac
3154fb28925Smrg    fi
3164fb28925Smrg
3174fb28925Smrg    echo 1>&2 "\
3184fb28925SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3194fb28925Smrg         You may want to install GNU tar or Free paxutils, or check the
3204fb28925Smrg         command line arguments."
3214fb28925Smrg    exit 1
3224fb28925Smrg    ;;
3234fb28925Smrg
3244fb28925Smrg  *)
3254fb28925Smrg    echo 1>&2 "\
3264fb28925SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
3274fb28925Smrg         system.  You might have modified some files without having the
3284fb28925Smrg         proper tools for further handling them.  Check the \`README' file,
3294fb28925Smrg         it often tells you about the needed prerequisites for installing
3304fb28925Smrg         this package.  You may also peek at any GNU archive site, in case
3314fb28925Smrg         some other package would contain this missing \`$1' program."
3324fb28925Smrg    exit 1
3334fb28925Smrg    ;;
3344fb28925Smrgesac
3354fb28925Smrg
3364fb28925Smrgexit 0
337