missing revision 8108eb18
18108eb18Smrg#! /bin/sh
28108eb18Smrg# Common stub for a few missing GNU programs while installing.
38108eb18Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
48108eb18Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
58108eb18Smrg
68108eb18Smrg# This program is free software; you can redistribute it and/or modify
78108eb18Smrg# it under the terms of the GNU General Public License as published by
88108eb18Smrg# the Free Software Foundation; either version 2, or (at your option)
98108eb18Smrg# any later version.
108108eb18Smrg
118108eb18Smrg# This program is distributed in the hope that it will be useful,
128108eb18Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
138108eb18Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
148108eb18Smrg# GNU General Public License for more details.
158108eb18Smrg
168108eb18Smrg# You should have received a copy of the GNU General Public License
178108eb18Smrg# along with this program; if not, write to the Free Software
188108eb18Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
198108eb18Smrg# 02111-1307, USA.
208108eb18Smrg
218108eb18Smrg# As a special exception to the GNU General Public License, if you
228108eb18Smrg# distribute this file as part of a program that contains a
238108eb18Smrg# configuration script generated by Autoconf, you may include it under
248108eb18Smrg# the same distribution terms that you use for the rest of that program.
258108eb18Smrg
268108eb18Smrgif test $# -eq 0; then
278108eb18Smrg  echo 1>&2 "Try \`$0 --help' for more information"
288108eb18Smrg  exit 1
298108eb18Smrgfi
308108eb18Smrg
318108eb18Smrgrun=:
328108eb18Smrg
338108eb18Smrg# In the cases where this matters, `missing' is being run in the
348108eb18Smrg# srcdir already.
358108eb18Smrgif test -f configure.ac; then
368108eb18Smrg  configure_ac=configure.ac
378108eb18Smrgelse
388108eb18Smrg  configure_ac=configure.in
398108eb18Smrgfi
408108eb18Smrg
418108eb18Smrgcase "$1" in
428108eb18Smrg--run)
438108eb18Smrg  # Try to run requested program, and just exit if it succeeds.
448108eb18Smrg  run=
458108eb18Smrg  shift
468108eb18Smrg  "$@" && exit 0
478108eb18Smrg  ;;
488108eb18Smrgesac
498108eb18Smrg
508108eb18Smrg# If it does not exist, or fails to run (possibly an outdated version),
518108eb18Smrg# try to emulate it.
528108eb18Smrgcase "$1" in
538108eb18Smrg
548108eb18Smrg  -h|--h|--he|--hel|--help)
558108eb18Smrg    echo "\
568108eb18Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
578108eb18Smrg
588108eb18SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
598108eb18Smrgerror status if there is no known handling for PROGRAM.
608108eb18Smrg
618108eb18SmrgOptions:
628108eb18Smrg  -h, --help      display this help and exit
638108eb18Smrg  -v, --version   output version information and exit
648108eb18Smrg  --run           try to run the given command, and emulate it if it fails
658108eb18Smrg
668108eb18SmrgSupported PROGRAM values:
678108eb18Smrg  aclocal      touch file \`aclocal.m4'
688108eb18Smrg  autoconf     touch file \`configure'
698108eb18Smrg  autoheader   touch file \`config.h.in'
708108eb18Smrg  automake     touch all \`Makefile.in' files
718108eb18Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
728108eb18Smrg  flex         create \`lex.yy.c', if possible, from existing .c
738108eb18Smrg  help2man     touch the output file
748108eb18Smrg  lex          create \`lex.yy.c', if possible, from existing .c
758108eb18Smrg  makeinfo     touch the output file
768108eb18Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
778108eb18Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
788108eb18Smrg    ;;
798108eb18Smrg
808108eb18Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
818108eb18Smrg    echo "missing 0.4 - GNU automake"
828108eb18Smrg    ;;
838108eb18Smrg
848108eb18Smrg  -*)
858108eb18Smrg    echo 1>&2 "$0: Unknown \`$1' option"
868108eb18Smrg    echo 1>&2 "Try \`$0 --help' for more information"
878108eb18Smrg    exit 1
888108eb18Smrg    ;;
898108eb18Smrg
908108eb18Smrg  aclocal*)
918108eb18Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
928108eb18Smrg       # We have it, but it failed.
938108eb18Smrg       exit 1
948108eb18Smrg    fi
958108eb18Smrg
968108eb18Smrg    echo 1>&2 "\
978108eb18SmrgWARNING: \`$1' is missing on your system.  You should only need it if
988108eb18Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
998108eb18Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1008108eb18Smrg         any GNU archive site."
1018108eb18Smrg    touch aclocal.m4
1028108eb18Smrg    ;;
1038108eb18Smrg
1048108eb18Smrg  autoconf)
1058108eb18Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1068108eb18Smrg       # We have it, but it failed.
1078108eb18Smrg       exit 1
1088108eb18Smrg    fi
1098108eb18Smrg
1108108eb18Smrg    echo 1>&2 "\
1118108eb18SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1128108eb18Smrg         you modified \`${configure_ac}'.  You might want to install the
1138108eb18Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1148108eb18Smrg         archive site."
1158108eb18Smrg    touch configure
1168108eb18Smrg    ;;
1178108eb18Smrg
1188108eb18Smrg  autoheader)
1198108eb18Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1208108eb18Smrg       # We have it, but it failed.
1218108eb18Smrg       exit 1
1228108eb18Smrg    fi
1238108eb18Smrg
1248108eb18Smrg    echo 1>&2 "\
1258108eb18SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1268108eb18Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1278108eb18Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1288108eb18Smrg         from any GNU archive site."
1298108eb18Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1308108eb18Smrg    test -z "$files" && files="config.h"
1318108eb18Smrg    touch_files=
1328108eb18Smrg    for f in $files; do
1338108eb18Smrg      case "$f" in
1348108eb18Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1358108eb18Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1368108eb18Smrg      *) touch_files="$touch_files $f.in";;
1378108eb18Smrg      esac
1388108eb18Smrg    done
1398108eb18Smrg    touch $touch_files
1408108eb18Smrg    ;;
1418108eb18Smrg
1428108eb18Smrg  automake*)
1438108eb18Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1448108eb18Smrg       # We have it, but it failed.
1458108eb18Smrg       exit 1
1468108eb18Smrg    fi
1478108eb18Smrg
1488108eb18Smrg    echo 1>&2 "\
1498108eb18SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1508108eb18Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1518108eb18Smrg         You might want to install the \`Automake' and \`Perl' packages.
1528108eb18Smrg         Grab them from any GNU archive site."
1538108eb18Smrg    find . -type f -name Makefile.am -print |
1548108eb18Smrg	   sed 's/\.am$/.in/' |
1558108eb18Smrg	   while read f; do touch "$f"; done
1568108eb18Smrg    ;;
1578108eb18Smrg
1588108eb18Smrg  autom4te)
1598108eb18Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1608108eb18Smrg       # We have it, but it failed.
1618108eb18Smrg       exit 1
1628108eb18Smrg    fi
1638108eb18Smrg
1648108eb18Smrg    echo 1>&2 "\
1658108eb18SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
1668108eb18Smrg         system.  You might have modified some files without having the
1678108eb18Smrg         proper tools for further handling them.
1688108eb18Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1698108eb18Smrg         archive site."
1708108eb18Smrg
1718108eb18Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
1728108eb18Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
1738108eb18Smrg    if test -f "$file"; then
1748108eb18Smrg	touch $file
1758108eb18Smrg    else
1768108eb18Smrg	test -z "$file" || exec >$file
1778108eb18Smrg	echo "#! /bin/sh"
1788108eb18Smrg	echo "# Created by GNU Automake missing as a replacement of"
1798108eb18Smrg	echo "#  $ $@"
1808108eb18Smrg	echo "exit 0"
1818108eb18Smrg	chmod +x $file
1828108eb18Smrg	exit 1
1838108eb18Smrg    fi
1848108eb18Smrg    ;;
1858108eb18Smrg
1868108eb18Smrg  bison|yacc)
1878108eb18Smrg    echo 1>&2 "\
1888108eb18SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1898108eb18Smrg         you modified a \`.y' file.  You may need the \`Bison' package
1908108eb18Smrg         in order for those modifications to take effect.  You can get
1918108eb18Smrg         \`Bison' from any GNU archive site."
1928108eb18Smrg    rm -f y.tab.c y.tab.h
1938108eb18Smrg    if [ $# -ne 1 ]; then
1948108eb18Smrg        eval LASTARG="\${$#}"
1958108eb18Smrg	case "$LASTARG" in
1968108eb18Smrg	*.y)
1978108eb18Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
1988108eb18Smrg	    if [ -f "$SRCFILE" ]; then
1998108eb18Smrg	         cp "$SRCFILE" y.tab.c
2008108eb18Smrg	    fi
2018108eb18Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2028108eb18Smrg	    if [ -f "$SRCFILE" ]; then
2038108eb18Smrg	         cp "$SRCFILE" y.tab.h
2048108eb18Smrg	    fi
2058108eb18Smrg	  ;;
2068108eb18Smrg	esac
2078108eb18Smrg    fi
2088108eb18Smrg    if [ ! -f y.tab.h ]; then
2098108eb18Smrg	echo >y.tab.h
2108108eb18Smrg    fi
2118108eb18Smrg    if [ ! -f y.tab.c ]; then
2128108eb18Smrg	echo 'main() { return 0; }' >y.tab.c
2138108eb18Smrg    fi
2148108eb18Smrg    ;;
2158108eb18Smrg
2168108eb18Smrg  lex|flex)
2178108eb18Smrg    echo 1>&2 "\
2188108eb18SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2198108eb18Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2208108eb18Smrg         in order for those modifications to take effect.  You can get
2218108eb18Smrg         \`Flex' from any GNU archive site."
2228108eb18Smrg    rm -f lex.yy.c
2238108eb18Smrg    if [ $# -ne 1 ]; then
2248108eb18Smrg        eval LASTARG="\${$#}"
2258108eb18Smrg	case "$LASTARG" in
2268108eb18Smrg	*.l)
2278108eb18Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2288108eb18Smrg	    if [ -f "$SRCFILE" ]; then
2298108eb18Smrg	         cp "$SRCFILE" lex.yy.c
2308108eb18Smrg	    fi
2318108eb18Smrg	  ;;
2328108eb18Smrg	esac
2338108eb18Smrg    fi
2348108eb18Smrg    if [ ! -f lex.yy.c ]; then
2358108eb18Smrg	echo 'main() { return 0; }' >lex.yy.c
2368108eb18Smrg    fi
2378108eb18Smrg    ;;
2388108eb18Smrg
2398108eb18Smrg  help2man)
2408108eb18Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
2418108eb18Smrg       # We have it, but it failed.
2428108eb18Smrg       exit 1
2438108eb18Smrg    fi
2448108eb18Smrg
2458108eb18Smrg    echo 1>&2 "\
2468108eb18SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2478108eb18Smrg	 you modified a dependency of a manual page.  You may need the
2488108eb18Smrg	 \`Help2man' package in order for those modifications to take
2498108eb18Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2508108eb18Smrg
2518108eb18Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2528108eb18Smrg    if test -z "$file"; then
2538108eb18Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2548108eb18Smrg    fi
2558108eb18Smrg    if [ -f "$file" ]; then
2568108eb18Smrg	touch $file
2578108eb18Smrg    else
2588108eb18Smrg	test -z "$file" || exec >$file
2598108eb18Smrg	echo ".ab help2man is required to generate this page"
2608108eb18Smrg	exit 1
2618108eb18Smrg    fi
2628108eb18Smrg    ;;
2638108eb18Smrg
2648108eb18Smrg  makeinfo)
2658108eb18Smrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
2668108eb18Smrg       # We have makeinfo, but it failed.
2678108eb18Smrg       exit 1
2688108eb18Smrg    fi
2698108eb18Smrg
2708108eb18Smrg    echo 1>&2 "\
2718108eb18SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2728108eb18Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2738108eb18Smrg         indirectly affecting the aspect of the manual.  The spurious
2748108eb18Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2758108eb18Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2768108eb18Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2778108eb18Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2788108eb18Smrg    if test -z "$file"; then
2798108eb18Smrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2808108eb18Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
2818108eb18Smrg    fi
2828108eb18Smrg    touch $file
2838108eb18Smrg    ;;
2848108eb18Smrg
2858108eb18Smrg  tar)
2868108eb18Smrg    shift
2878108eb18Smrg    if test -n "$run"; then
2888108eb18Smrg      echo 1>&2 "ERROR: \`tar' requires --run"
2898108eb18Smrg      exit 1
2908108eb18Smrg    fi
2918108eb18Smrg
2928108eb18Smrg    # We have already tried tar in the generic part.
2938108eb18Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
2948108eb18Smrg    # messages.
2958108eb18Smrg    if (gnutar --version > /dev/null 2>&1); then
2968108eb18Smrg       gnutar "$@" && exit 0
2978108eb18Smrg    fi
2988108eb18Smrg    if (gtar --version > /dev/null 2>&1); then
2998108eb18Smrg       gtar "$@" && exit 0
3008108eb18Smrg    fi
3018108eb18Smrg    firstarg="$1"
3028108eb18Smrg    if shift; then
3038108eb18Smrg	case "$firstarg" in
3048108eb18Smrg	*o*)
3058108eb18Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3068108eb18Smrg	    tar "$firstarg" "$@" && exit 0
3078108eb18Smrg	    ;;
3088108eb18Smrg	esac
3098108eb18Smrg	case "$firstarg" in
3108108eb18Smrg	*h*)
3118108eb18Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3128108eb18Smrg	    tar "$firstarg" "$@" && exit 0
3138108eb18Smrg	    ;;
3148108eb18Smrg	esac
3158108eb18Smrg    fi
3168108eb18Smrg
3178108eb18Smrg    echo 1>&2 "\
3188108eb18SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3198108eb18Smrg         You may want to install GNU tar or Free paxutils, or check the
3208108eb18Smrg         command line arguments."
3218108eb18Smrg    exit 1
3228108eb18Smrg    ;;
3238108eb18Smrg
3248108eb18Smrg  *)
3258108eb18Smrg    echo 1>&2 "\
3268108eb18SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
3278108eb18Smrg         system.  You might have modified some files without having the
3288108eb18Smrg         proper tools for further handling them.  Check the \`README' file,
3298108eb18Smrg         it often tells you about the needed prerequisites for installing
3308108eb18Smrg         this package.  You may also peek at any GNU archive site, in case
3318108eb18Smrg         some other package would contain this missing \`$1' program."
3328108eb18Smrg    exit 1
3338108eb18Smrg    ;;
3348108eb18Smrgesac
3358108eb18Smrg
3368108eb18Smrgexit 0
337