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