missing revision 6ea72052
16ea72052Smrg#! /bin/sh
26ea72052Smrg# Common stub for a few missing GNU programs while installing.
36ea72052Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
46ea72052Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
56ea72052Smrg
66ea72052Smrg# This program is free software; you can redistribute it and/or modify
76ea72052Smrg# it under the terms of the GNU General Public License as published by
86ea72052Smrg# the Free Software Foundation; either version 2, or (at your option)
96ea72052Smrg# any later version.
106ea72052Smrg
116ea72052Smrg# This program is distributed in the hope that it will be useful,
126ea72052Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
136ea72052Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
146ea72052Smrg# GNU General Public License for more details.
156ea72052Smrg
166ea72052Smrg# You should have received a copy of the GNU General Public License
176ea72052Smrg# along with this program; if not, write to the Free Software
186ea72052Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
196ea72052Smrg# 02111-1307, USA.
206ea72052Smrg
216ea72052Smrg# As a special exception to the GNU General Public License, if you
226ea72052Smrg# distribute this file as part of a program that contains a
236ea72052Smrg# configuration script generated by Autoconf, you may include it under
246ea72052Smrg# the same distribution terms that you use for the rest of that program.
256ea72052Smrg
266ea72052Smrgif test $# -eq 0; then
276ea72052Smrg  echo 1>&2 "Try \`$0 --help' for more information"
286ea72052Smrg  exit 1
296ea72052Smrgfi
306ea72052Smrg
316ea72052Smrgrun=:
326ea72052Smrg
336ea72052Smrg# In the cases where this matters, `missing' is being run in the
346ea72052Smrg# srcdir already.
356ea72052Smrgif test -f configure.ac; then
366ea72052Smrg  configure_ac=configure.ac
376ea72052Smrgelse
386ea72052Smrg  configure_ac=configure.in
396ea72052Smrgfi
406ea72052Smrg
416ea72052Smrgcase "$1" in
426ea72052Smrg--run)
436ea72052Smrg  # Try to run requested program, and just exit if it succeeds.
446ea72052Smrg  run=
456ea72052Smrg  shift
466ea72052Smrg  "$@" && exit 0
476ea72052Smrg  ;;
486ea72052Smrgesac
496ea72052Smrg
506ea72052Smrg# If it does not exist, or fails to run (possibly an outdated version),
516ea72052Smrg# try to emulate it.
526ea72052Smrgcase "$1" in
536ea72052Smrg
546ea72052Smrg  -h|--h|--he|--hel|--help)
556ea72052Smrg    echo "\
566ea72052Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
576ea72052Smrg
586ea72052SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
596ea72052Smrgerror status if there is no known handling for PROGRAM.
606ea72052Smrg
616ea72052SmrgOptions:
626ea72052Smrg  -h, --help      display this help and exit
636ea72052Smrg  -v, --version   output version information and exit
646ea72052Smrg  --run           try to run the given command, and emulate it if it fails
656ea72052Smrg
666ea72052SmrgSupported PROGRAM values:
676ea72052Smrg  aclocal      touch file \`aclocal.m4'
686ea72052Smrg  autoconf     touch file \`configure'
696ea72052Smrg  autoheader   touch file \`config.h.in'
706ea72052Smrg  automake     touch all \`Makefile.in' files
716ea72052Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
726ea72052Smrg  flex         create \`lex.yy.c', if possible, from existing .c
736ea72052Smrg  help2man     touch the output file
746ea72052Smrg  lex          create \`lex.yy.c', if possible, from existing .c
756ea72052Smrg  makeinfo     touch the output file
766ea72052Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
776ea72052Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
786ea72052Smrg    ;;
796ea72052Smrg
806ea72052Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
816ea72052Smrg    echo "missing 0.4 - GNU automake"
826ea72052Smrg    ;;
836ea72052Smrg
846ea72052Smrg  -*)
856ea72052Smrg    echo 1>&2 "$0: Unknown \`$1' option"
866ea72052Smrg    echo 1>&2 "Try \`$0 --help' for more information"
876ea72052Smrg    exit 1
886ea72052Smrg    ;;
896ea72052Smrg
906ea72052Smrg  aclocal*)
916ea72052Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
926ea72052Smrg       # We have it, but it failed.
936ea72052Smrg       exit 1
946ea72052Smrg    fi
956ea72052Smrg
966ea72052Smrg    echo 1>&2 "\
976ea72052SmrgWARNING: \`$1' is missing on your system.  You should only need it if
986ea72052Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
996ea72052Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1006ea72052Smrg         any GNU archive site."
1016ea72052Smrg    touch aclocal.m4
1026ea72052Smrg    ;;
1036ea72052Smrg
1046ea72052Smrg  autoconf)
1056ea72052Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1066ea72052Smrg       # We have it, but it failed.
1076ea72052Smrg       exit 1
1086ea72052Smrg    fi
1096ea72052Smrg
1106ea72052Smrg    echo 1>&2 "\
1116ea72052SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1126ea72052Smrg         you modified \`${configure_ac}'.  You might want to install the
1136ea72052Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1146ea72052Smrg         archive site."
1156ea72052Smrg    touch configure
1166ea72052Smrg    ;;
1176ea72052Smrg
1186ea72052Smrg  autoheader)
1196ea72052Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1206ea72052Smrg       # We have it, but it failed.
1216ea72052Smrg       exit 1
1226ea72052Smrg    fi
1236ea72052Smrg
1246ea72052Smrg    echo 1>&2 "\
1256ea72052SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1266ea72052Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1276ea72052Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1286ea72052Smrg         from any GNU archive site."
1296ea72052Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1306ea72052Smrg    test -z "$files" && files="config.h"
1316ea72052Smrg    touch_files=
1326ea72052Smrg    for f in $files; do
1336ea72052Smrg      case "$f" in
1346ea72052Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1356ea72052Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1366ea72052Smrg      *) touch_files="$touch_files $f.in";;
1376ea72052Smrg      esac
1386ea72052Smrg    done
1396ea72052Smrg    touch $touch_files
1406ea72052Smrg    ;;
1416ea72052Smrg
1426ea72052Smrg  automake*)
1436ea72052Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1446ea72052Smrg       # We have it, but it failed.
1456ea72052Smrg       exit 1
1466ea72052Smrg    fi
1476ea72052Smrg
1486ea72052Smrg    echo 1>&2 "\
1496ea72052SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1506ea72052Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1516ea72052Smrg         You might want to install the \`Automake' and \`Perl' packages.
1526ea72052Smrg         Grab them from any GNU archive site."
1536ea72052Smrg    find . -type f -name Makefile.am -print |
1546ea72052Smrg	   sed 's/\.am$/.in/' |
1556ea72052Smrg	   while read f; do touch "$f"; done
1566ea72052Smrg    ;;
1576ea72052Smrg
1586ea72052Smrg  autom4te)
1596ea72052Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1606ea72052Smrg       # We have it, but it failed.
1616ea72052Smrg       exit 1
1626ea72052Smrg    fi
1636ea72052Smrg
1646ea72052Smrg    echo 1>&2 "\
1656ea72052SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
1666ea72052Smrg         system.  You might have modified some files without having the
1676ea72052Smrg         proper tools for further handling them.
1686ea72052Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1696ea72052Smrg         archive site."
1706ea72052Smrg
1716ea72052Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
1726ea72052Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
1736ea72052Smrg    if test -f "$file"; then
1746ea72052Smrg	touch $file
1756ea72052Smrg    else
1766ea72052Smrg	test -z "$file" || exec >$file
1776ea72052Smrg	echo "#! /bin/sh"
1786ea72052Smrg	echo "# Created by GNU Automake missing as a replacement of"
1796ea72052Smrg	echo "#  $ $@"
1806ea72052Smrg	echo "exit 0"
1816ea72052Smrg	chmod +x $file
1826ea72052Smrg	exit 1
1836ea72052Smrg    fi
1846ea72052Smrg    ;;
1856ea72052Smrg
1866ea72052Smrg  bison|yacc)
1876ea72052Smrg    echo 1>&2 "\
1886ea72052SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1896ea72052Smrg         you modified a \`.y' file.  You may need the \`Bison' package
1906ea72052Smrg         in order for those modifications to take effect.  You can get
1916ea72052Smrg         \`Bison' from any GNU archive site."
1926ea72052Smrg    rm -f y.tab.c y.tab.h
1936ea72052Smrg    if [ $# -ne 1 ]; then
1946ea72052Smrg        eval LASTARG="\${$#}"
1956ea72052Smrg	case "$LASTARG" in
1966ea72052Smrg	*.y)
1976ea72052Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
1986ea72052Smrg	    if [ -f "$SRCFILE" ]; then
1996ea72052Smrg	         cp "$SRCFILE" y.tab.c
2006ea72052Smrg	    fi
2016ea72052Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2026ea72052Smrg	    if [ -f "$SRCFILE" ]; then
2036ea72052Smrg	         cp "$SRCFILE" y.tab.h
2046ea72052Smrg	    fi
2056ea72052Smrg	  ;;
2066ea72052Smrg	esac
2076ea72052Smrg    fi
2086ea72052Smrg    if [ ! -f y.tab.h ]; then
2096ea72052Smrg	echo >y.tab.h
2106ea72052Smrg    fi
2116ea72052Smrg    if [ ! -f y.tab.c ]; then
2126ea72052Smrg	echo 'main() { return 0; }' >y.tab.c
2136ea72052Smrg    fi
2146ea72052Smrg    ;;
2156ea72052Smrg
2166ea72052Smrg  lex|flex)
2176ea72052Smrg    echo 1>&2 "\
2186ea72052SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2196ea72052Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2206ea72052Smrg         in order for those modifications to take effect.  You can get
2216ea72052Smrg         \`Flex' from any GNU archive site."
2226ea72052Smrg    rm -f lex.yy.c
2236ea72052Smrg    if [ $# -ne 1 ]; then
2246ea72052Smrg        eval LASTARG="\${$#}"
2256ea72052Smrg	case "$LASTARG" in
2266ea72052Smrg	*.l)
2276ea72052Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2286ea72052Smrg	    if [ -f "$SRCFILE" ]; then
2296ea72052Smrg	         cp "$SRCFILE" lex.yy.c
2306ea72052Smrg	    fi
2316ea72052Smrg	  ;;
2326ea72052Smrg	esac
2336ea72052Smrg    fi
2346ea72052Smrg    if [ ! -f lex.yy.c ]; then
2356ea72052Smrg	echo 'main() { return 0; }' >lex.yy.c
2366ea72052Smrg    fi
2376ea72052Smrg    ;;
2386ea72052Smrg
2396ea72052Smrg  help2man)
2406ea72052Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
2416ea72052Smrg       # We have it, but it failed.
2426ea72052Smrg       exit 1
2436ea72052Smrg    fi
2446ea72052Smrg
2456ea72052Smrg    echo 1>&2 "\
2466ea72052SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2476ea72052Smrg	 you modified a dependency of a manual page.  You may need the
2486ea72052Smrg	 \`Help2man' package in order for those modifications to take
2496ea72052Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2506ea72052Smrg
2516ea72052Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2526ea72052Smrg    if test -z "$file"; then
2536ea72052Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2546ea72052Smrg    fi
2556ea72052Smrg    if [ -f "$file" ]; then
2566ea72052Smrg	touch $file
2576ea72052Smrg    else
2586ea72052Smrg	test -z "$file" || exec >$file
2596ea72052Smrg	echo ".ab help2man is required to generate this page"
2606ea72052Smrg	exit 1
2616ea72052Smrg    fi
2626ea72052Smrg    ;;
2636ea72052Smrg
2646ea72052Smrg  makeinfo)
2656ea72052Smrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
2666ea72052Smrg       # We have makeinfo, but it failed.
2676ea72052Smrg       exit 1
2686ea72052Smrg    fi
2696ea72052Smrg
2706ea72052Smrg    echo 1>&2 "\
2716ea72052SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2726ea72052Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2736ea72052Smrg         indirectly affecting the aspect of the manual.  The spurious
2746ea72052Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2756ea72052Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2766ea72052Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2776ea72052Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2786ea72052Smrg    if test -z "$file"; then
2796ea72052Smrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2806ea72052Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
2816ea72052Smrg    fi
2826ea72052Smrg    touch $file
2836ea72052Smrg    ;;
2846ea72052Smrg
2856ea72052Smrg  tar)
2866ea72052Smrg    shift
2876ea72052Smrg    if test -n "$run"; then
2886ea72052Smrg      echo 1>&2 "ERROR: \`tar' requires --run"
2896ea72052Smrg      exit 1
2906ea72052Smrg    fi
2916ea72052Smrg
2926ea72052Smrg    # We have already tried tar in the generic part.
2936ea72052Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
2946ea72052Smrg    # messages.
2956ea72052Smrg    if (gnutar --version > /dev/null 2>&1); then
2966ea72052Smrg       gnutar "$@" && exit 0
2976ea72052Smrg    fi
2986ea72052Smrg    if (gtar --version > /dev/null 2>&1); then
2996ea72052Smrg       gtar "$@" && exit 0
3006ea72052Smrg    fi
3016ea72052Smrg    firstarg="$1"
3026ea72052Smrg    if shift; then
3036ea72052Smrg	case "$firstarg" in
3046ea72052Smrg	*o*)
3056ea72052Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3066ea72052Smrg	    tar "$firstarg" "$@" && exit 0
3076ea72052Smrg	    ;;
3086ea72052Smrg	esac
3096ea72052Smrg	case "$firstarg" in
3106ea72052Smrg	*h*)
3116ea72052Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3126ea72052Smrg	    tar "$firstarg" "$@" && exit 0
3136ea72052Smrg	    ;;
3146ea72052Smrg	esac
3156ea72052Smrg    fi
3166ea72052Smrg
3176ea72052Smrg    echo 1>&2 "\
3186ea72052SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3196ea72052Smrg         You may want to install GNU tar or Free paxutils, or check the
3206ea72052Smrg         command line arguments."
3216ea72052Smrg    exit 1
3226ea72052Smrg    ;;
3236ea72052Smrg
3246ea72052Smrg  *)
3256ea72052Smrg    echo 1>&2 "\
3266ea72052SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
3276ea72052Smrg         system.  You might have modified some files without having the
3286ea72052Smrg         proper tools for further handling them.  Check the \`README' file,
3296ea72052Smrg         it often tells you about the needed prerequisites for installing
3306ea72052Smrg         this package.  You may also peek at any GNU archive site, in case
3316ea72052Smrg         some other package would contain this missing \`$1' program."
3326ea72052Smrg    exit 1
3336ea72052Smrg    ;;
3346ea72052Smrgesac
3356ea72052Smrg
3366ea72052Smrgexit 0
337