missing revision 8440cca4
18440cca4Smrg#! /bin/sh
28440cca4Smrg# Common stub for a few missing GNU programs while installing.
38440cca4Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
48440cca4Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
58440cca4Smrg
68440cca4Smrg# This program is free software; you can redistribute it and/or modify
78440cca4Smrg# it under the terms of the GNU General Public License as published by
88440cca4Smrg# the Free Software Foundation; either version 2, or (at your option)
98440cca4Smrg# any later version.
108440cca4Smrg
118440cca4Smrg# This program is distributed in the hope that it will be useful,
128440cca4Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
138440cca4Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
148440cca4Smrg# GNU General Public License for more details.
158440cca4Smrg
168440cca4Smrg# You should have received a copy of the GNU General Public License
178440cca4Smrg# along with this program; if not, write to the Free Software
188440cca4Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
198440cca4Smrg# 02111-1307, USA.
208440cca4Smrg
218440cca4Smrg# As a special exception to the GNU General Public License, if you
228440cca4Smrg# distribute this file as part of a program that contains a
238440cca4Smrg# configuration script generated by Autoconf, you may include it under
248440cca4Smrg# the same distribution terms that you use for the rest of that program.
258440cca4Smrg
268440cca4Smrgif test $# -eq 0; then
278440cca4Smrg  echo 1>&2 "Try \`$0 --help' for more information"
288440cca4Smrg  exit 1
298440cca4Smrgfi
308440cca4Smrg
318440cca4Smrgrun=:
328440cca4Smrg
338440cca4Smrg# In the cases where this matters, `missing' is being run in the
348440cca4Smrg# srcdir already.
358440cca4Smrgif test -f configure.ac; then
368440cca4Smrg  configure_ac=configure.ac
378440cca4Smrgelse
388440cca4Smrg  configure_ac=configure.in
398440cca4Smrgfi
408440cca4Smrg
418440cca4Smrgcase "$1" in
428440cca4Smrg--run)
438440cca4Smrg  # Try to run requested program, and just exit if it succeeds.
448440cca4Smrg  run=
458440cca4Smrg  shift
468440cca4Smrg  "$@" && exit 0
478440cca4Smrg  ;;
488440cca4Smrgesac
498440cca4Smrg
508440cca4Smrg# If it does not exist, or fails to run (possibly an outdated version),
518440cca4Smrg# try to emulate it.
528440cca4Smrgcase "$1" in
538440cca4Smrg
548440cca4Smrg  -h|--h|--he|--hel|--help)
558440cca4Smrg    echo "\
568440cca4Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
578440cca4Smrg
588440cca4SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
598440cca4Smrgerror status if there is no known handling for PROGRAM.
608440cca4Smrg
618440cca4SmrgOptions:
628440cca4Smrg  -h, --help      display this help and exit
638440cca4Smrg  -v, --version   output version information and exit
648440cca4Smrg  --run           try to run the given command, and emulate it if it fails
658440cca4Smrg
668440cca4SmrgSupported PROGRAM values:
678440cca4Smrg  aclocal      touch file \`aclocal.m4'
688440cca4Smrg  autoconf     touch file \`configure'
698440cca4Smrg  autoheader   touch file \`config.h.in'
708440cca4Smrg  automake     touch all \`Makefile.in' files
718440cca4Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
728440cca4Smrg  flex         create \`lex.yy.c', if possible, from existing .c
738440cca4Smrg  help2man     touch the output file
748440cca4Smrg  lex          create \`lex.yy.c', if possible, from existing .c
758440cca4Smrg  makeinfo     touch the output file
768440cca4Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
778440cca4Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
788440cca4Smrg    ;;
798440cca4Smrg
808440cca4Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
818440cca4Smrg    echo "missing 0.4 - GNU automake"
828440cca4Smrg    ;;
838440cca4Smrg
848440cca4Smrg  -*)
858440cca4Smrg    echo 1>&2 "$0: Unknown \`$1' option"
868440cca4Smrg    echo 1>&2 "Try \`$0 --help' for more information"
878440cca4Smrg    exit 1
888440cca4Smrg    ;;
898440cca4Smrg
908440cca4Smrg  aclocal*)
918440cca4Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
928440cca4Smrg       # We have it, but it failed.
938440cca4Smrg       exit 1
948440cca4Smrg    fi
958440cca4Smrg
968440cca4Smrg    echo 1>&2 "\
978440cca4SmrgWARNING: \`$1' is missing on your system.  You should only need it if
988440cca4Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
998440cca4Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1008440cca4Smrg         any GNU archive site."
1018440cca4Smrg    touch aclocal.m4
1028440cca4Smrg    ;;
1038440cca4Smrg
1048440cca4Smrg  autoconf)
1058440cca4Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1068440cca4Smrg       # We have it, but it failed.
1078440cca4Smrg       exit 1
1088440cca4Smrg    fi
1098440cca4Smrg
1108440cca4Smrg    echo 1>&2 "\
1118440cca4SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1128440cca4Smrg         you modified \`${configure_ac}'.  You might want to install the
1138440cca4Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1148440cca4Smrg         archive site."
1158440cca4Smrg    touch configure
1168440cca4Smrg    ;;
1178440cca4Smrg
1188440cca4Smrg  autoheader)
1198440cca4Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1208440cca4Smrg       # We have it, but it failed.
1218440cca4Smrg       exit 1
1228440cca4Smrg    fi
1238440cca4Smrg
1248440cca4Smrg    echo 1>&2 "\
1258440cca4SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1268440cca4Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1278440cca4Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1288440cca4Smrg         from any GNU archive site."
1298440cca4Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1308440cca4Smrg    test -z "$files" && files="config.h"
1318440cca4Smrg    touch_files=
1328440cca4Smrg    for f in $files; do
1338440cca4Smrg      case "$f" in
1348440cca4Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1358440cca4Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1368440cca4Smrg      *) touch_files="$touch_files $f.in";;
1378440cca4Smrg      esac
1388440cca4Smrg    done
1398440cca4Smrg    touch $touch_files
1408440cca4Smrg    ;;
1418440cca4Smrg
1428440cca4Smrg  automake*)
1438440cca4Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1448440cca4Smrg       # We have it, but it failed.
1458440cca4Smrg       exit 1
1468440cca4Smrg    fi
1478440cca4Smrg
1488440cca4Smrg    echo 1>&2 "\
1498440cca4SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1508440cca4Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1518440cca4Smrg         You might want to install the \`Automake' and \`Perl' packages.
1528440cca4Smrg         Grab them from any GNU archive site."
1538440cca4Smrg    find . -type f -name Makefile.am -print |
1548440cca4Smrg	   sed 's/\.am$/.in/' |
1558440cca4Smrg	   while read f; do touch "$f"; done
1568440cca4Smrg    ;;
1578440cca4Smrg
1588440cca4Smrg  autom4te)
1598440cca4Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1608440cca4Smrg       # We have it, but it failed.
1618440cca4Smrg       exit 1
1628440cca4Smrg    fi
1638440cca4Smrg
1648440cca4Smrg    echo 1>&2 "\
1658440cca4SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
1668440cca4Smrg         system.  You might have modified some files without having the
1678440cca4Smrg         proper tools for further handling them.
1688440cca4Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1698440cca4Smrg         archive site."
1708440cca4Smrg
1718440cca4Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
1728440cca4Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
1738440cca4Smrg    if test -f "$file"; then
1748440cca4Smrg	touch $file
1758440cca4Smrg    else
1768440cca4Smrg	test -z "$file" || exec >$file
1778440cca4Smrg	echo "#! /bin/sh"
1788440cca4Smrg	echo "# Created by GNU Automake missing as a replacement of"
1798440cca4Smrg	echo "#  $ $@"
1808440cca4Smrg	echo "exit 0"
1818440cca4Smrg	chmod +x $file
1828440cca4Smrg	exit 1
1838440cca4Smrg    fi
1848440cca4Smrg    ;;
1858440cca4Smrg
1868440cca4Smrg  bison|yacc)
1878440cca4Smrg    echo 1>&2 "\
1888440cca4SmrgWARNING: \`$1' is missing on your system.  You should only need it if
1898440cca4Smrg         you modified a \`.y' file.  You may need the \`Bison' package
1908440cca4Smrg         in order for those modifications to take effect.  You can get
1918440cca4Smrg         \`Bison' from any GNU archive site."
1928440cca4Smrg    rm -f y.tab.c y.tab.h
1938440cca4Smrg    if [ $# -ne 1 ]; then
1948440cca4Smrg        eval LASTARG="\${$#}"
1958440cca4Smrg	case "$LASTARG" in
1968440cca4Smrg	*.y)
1978440cca4Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
1988440cca4Smrg	    if [ -f "$SRCFILE" ]; then
1998440cca4Smrg	         cp "$SRCFILE" y.tab.c
2008440cca4Smrg	    fi
2018440cca4Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2028440cca4Smrg	    if [ -f "$SRCFILE" ]; then
2038440cca4Smrg	         cp "$SRCFILE" y.tab.h
2048440cca4Smrg	    fi
2058440cca4Smrg	  ;;
2068440cca4Smrg	esac
2078440cca4Smrg    fi
2088440cca4Smrg    if [ ! -f y.tab.h ]; then
2098440cca4Smrg	echo >y.tab.h
2108440cca4Smrg    fi
2118440cca4Smrg    if [ ! -f y.tab.c ]; then
2128440cca4Smrg	echo 'main() { return 0; }' >y.tab.c
2138440cca4Smrg    fi
2148440cca4Smrg    ;;
2158440cca4Smrg
2168440cca4Smrg  lex|flex)
2178440cca4Smrg    echo 1>&2 "\
2188440cca4SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2198440cca4Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2208440cca4Smrg         in order for those modifications to take effect.  You can get
2218440cca4Smrg         \`Flex' from any GNU archive site."
2228440cca4Smrg    rm -f lex.yy.c
2238440cca4Smrg    if [ $# -ne 1 ]; then
2248440cca4Smrg        eval LASTARG="\${$#}"
2258440cca4Smrg	case "$LASTARG" in
2268440cca4Smrg	*.l)
2278440cca4Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2288440cca4Smrg	    if [ -f "$SRCFILE" ]; then
2298440cca4Smrg	         cp "$SRCFILE" lex.yy.c
2308440cca4Smrg	    fi
2318440cca4Smrg	  ;;
2328440cca4Smrg	esac
2338440cca4Smrg    fi
2348440cca4Smrg    if [ ! -f lex.yy.c ]; then
2358440cca4Smrg	echo 'main() { return 0; }' >lex.yy.c
2368440cca4Smrg    fi
2378440cca4Smrg    ;;
2388440cca4Smrg
2398440cca4Smrg  help2man)
2408440cca4Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
2418440cca4Smrg       # We have it, but it failed.
2428440cca4Smrg       exit 1
2438440cca4Smrg    fi
2448440cca4Smrg
2458440cca4Smrg    echo 1>&2 "\
2468440cca4SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2478440cca4Smrg	 you modified a dependency of a manual page.  You may need the
2488440cca4Smrg	 \`Help2man' package in order for those modifications to take
2498440cca4Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2508440cca4Smrg
2518440cca4Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2528440cca4Smrg    if test -z "$file"; then
2538440cca4Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
2548440cca4Smrg    fi
2558440cca4Smrg    if [ -f "$file" ]; then
2568440cca4Smrg	touch $file
2578440cca4Smrg    else
2588440cca4Smrg	test -z "$file" || exec >$file
2598440cca4Smrg	echo ".ab help2man is required to generate this page"
2608440cca4Smrg	exit 1
2618440cca4Smrg    fi
2628440cca4Smrg    ;;
2638440cca4Smrg
2648440cca4Smrg  makeinfo)
2658440cca4Smrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
2668440cca4Smrg       # We have makeinfo, but it failed.
2678440cca4Smrg       exit 1
2688440cca4Smrg    fi
2698440cca4Smrg
2708440cca4Smrg    echo 1>&2 "\
2718440cca4SmrgWARNING: \`$1' is missing on your system.  You should only need it if
2728440cca4Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2738440cca4Smrg         indirectly affecting the aspect of the manual.  The spurious
2748440cca4Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2758440cca4Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2768440cca4Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2778440cca4Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
2788440cca4Smrg    if test -z "$file"; then
2798440cca4Smrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2808440cca4Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
2818440cca4Smrg    fi
2828440cca4Smrg    touch $file
2838440cca4Smrg    ;;
2848440cca4Smrg
2858440cca4Smrg  tar)
2868440cca4Smrg    shift
2878440cca4Smrg    if test -n "$run"; then
2888440cca4Smrg      echo 1>&2 "ERROR: \`tar' requires --run"
2898440cca4Smrg      exit 1
2908440cca4Smrg    fi
2918440cca4Smrg
2928440cca4Smrg    # We have already tried tar in the generic part.
2938440cca4Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
2948440cca4Smrg    # messages.
2958440cca4Smrg    if (gnutar --version > /dev/null 2>&1); then
2968440cca4Smrg       gnutar "$@" && exit 0
2978440cca4Smrg    fi
2988440cca4Smrg    if (gtar --version > /dev/null 2>&1); then
2998440cca4Smrg       gtar "$@" && exit 0
3008440cca4Smrg    fi
3018440cca4Smrg    firstarg="$1"
3028440cca4Smrg    if shift; then
3038440cca4Smrg	case "$firstarg" in
3048440cca4Smrg	*o*)
3058440cca4Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3068440cca4Smrg	    tar "$firstarg" "$@" && exit 0
3078440cca4Smrg	    ;;
3088440cca4Smrg	esac
3098440cca4Smrg	case "$firstarg" in
3108440cca4Smrg	*h*)
3118440cca4Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3128440cca4Smrg	    tar "$firstarg" "$@" && exit 0
3138440cca4Smrg	    ;;
3148440cca4Smrg	esac
3158440cca4Smrg    fi
3168440cca4Smrg
3178440cca4Smrg    echo 1>&2 "\
3188440cca4SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3198440cca4Smrg         You may want to install GNU tar or Free paxutils, or check the
3208440cca4Smrg         command line arguments."
3218440cca4Smrg    exit 1
3228440cca4Smrg    ;;
3238440cca4Smrg
3248440cca4Smrg  *)
3258440cca4Smrg    echo 1>&2 "\
3268440cca4SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
3278440cca4Smrg         system.  You might have modified some files without having the
3288440cca4Smrg         proper tools for further handling them.  Check the \`README' file,
3298440cca4Smrg         it often tells you about the needed prerequisites for installing
3308440cca4Smrg         this package.  You may also peek at any GNU archive site, in case
3318440cca4Smrg         some other package would contain this missing \`$1' program."
3328440cca4Smrg    exit 1
3338440cca4Smrg    ;;
3348440cca4Smrgesac
3358440cca4Smrg
3368440cca4Smrgexit 0
337