missing revision ca08ab68
12c393a42Smrg#! /bin/sh
22c393a42Smrg# Common stub for a few missing GNU programs while installing.
32c393a42Smrg
4ca08ab68Smrgscriptversion=2012-01-06.13; # UTC
52c393a42Smrg
6a6844aabSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7ca08ab68Smrg# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
82c393a42Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
92c393a42Smrg
102c393a42Smrg# This program is free software; you can redistribute it and/or modify
112c393a42Smrg# it under the terms of the GNU General Public License as published by
122c393a42Smrg# the Free Software Foundation; either version 2, or (at your option)
132c393a42Smrg# any later version.
142c393a42Smrg
152c393a42Smrg# This program is distributed in the hope that it will be useful,
162c393a42Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
172c393a42Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
182c393a42Smrg# GNU General Public License for more details.
192c393a42Smrg
202c393a42Smrg# You should have received a copy of the GNU General Public License
21a6844aabSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
222c393a42Smrg
232c393a42Smrg# As a special exception to the GNU General Public License, if you
242c393a42Smrg# distribute this file as part of a program that contains a
252c393a42Smrg# configuration script generated by Autoconf, you may include it under
262c393a42Smrg# the same distribution terms that you use for the rest of that program.
272c393a42Smrg
282c393a42Smrgif test $# -eq 0; then
292c393a42Smrg  echo 1>&2 "Try \`$0 --help' for more information"
302c393a42Smrg  exit 1
312c393a42Smrgfi
322c393a42Smrg
332c393a42Smrgrun=:
34a6844aabSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35a6844aabSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
362c393a42Smrg
372c393a42Smrg# In the cases where this matters, `missing' is being run in the
382c393a42Smrg# srcdir already.
392c393a42Smrgif test -f configure.ac; then
402c393a42Smrg  configure_ac=configure.ac
412c393a42Smrgelse
422c393a42Smrg  configure_ac=configure.in
432c393a42Smrgfi
442c393a42Smrg
452c393a42Smrgmsg="missing on your system"
462c393a42Smrg
47a6844aabSmrgcase $1 in
482c393a42Smrg--run)
492c393a42Smrg  # Try to run requested program, and just exit if it succeeds.
502c393a42Smrg  run=
512c393a42Smrg  shift
522c393a42Smrg  "$@" && exit 0
532c393a42Smrg  # Exit code 63 means version mismatch.  This often happens
542c393a42Smrg  # when the user try to use an ancient version of a tool on
552c393a42Smrg  # a file that requires a minimum version.  In this case we
562c393a42Smrg  # we should proceed has if the program had been absent, or
572c393a42Smrg  # if --run hadn't been passed.
582c393a42Smrg  if test $? = 63; then
592c393a42Smrg    run=:
602c393a42Smrg    msg="probably too old"
612c393a42Smrg  fi
622c393a42Smrg  ;;
632c393a42Smrg
642c393a42Smrg  -h|--h|--he|--hel|--help)
652c393a42Smrg    echo "\
662c393a42Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
672c393a42Smrg
682c393a42SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
692c393a42Smrgerror status if there is no known handling for PROGRAM.
702c393a42Smrg
712c393a42SmrgOptions:
722c393a42Smrg  -h, --help      display this help and exit
732c393a42Smrg  -v, --version   output version information and exit
742c393a42Smrg  --run           try to run the given command, and emulate it if it fails
752c393a42Smrg
762c393a42SmrgSupported PROGRAM values:
772c393a42Smrg  aclocal      touch file \`aclocal.m4'
782c393a42Smrg  autoconf     touch file \`configure'
792c393a42Smrg  autoheader   touch file \`config.h.in'
80a6844aabSmrg  autom4te     touch the output file, or create a stub one
812c393a42Smrg  automake     touch all \`Makefile.in' files
822c393a42Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
832c393a42Smrg  flex         create \`lex.yy.c', if possible, from existing .c
842c393a42Smrg  help2man     touch the output file
852c393a42Smrg  lex          create \`lex.yy.c', if possible, from existing .c
862c393a42Smrg  makeinfo     touch the output file
872c393a42Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
882c393a42Smrg
89a6844aabSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
90a6844aabSmrg\`g' are ignored when checking the name.
91a6844aabSmrg
922c393a42SmrgSend bug reports to <bug-automake@gnu.org>."
932c393a42Smrg    exit $?
942c393a42Smrg    ;;
952c393a42Smrg
962c393a42Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
972c393a42Smrg    echo "missing $scriptversion (GNU Automake)"
982c393a42Smrg    exit $?
992c393a42Smrg    ;;
1002c393a42Smrg
1012c393a42Smrg  -*)
1022c393a42Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1032c393a42Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1042c393a42Smrg    exit 1
1052c393a42Smrg    ;;
1062c393a42Smrg
1072c393a42Smrgesac
1082c393a42Smrg
109a6844aabSmrg# normalize program name to check for.
110a6844aabSmrgprogram=`echo "$1" | sed '
111a6844aabSmrg  s/^gnu-//; t
112a6844aabSmrg  s/^gnu//; t
113a6844aabSmrg  s/^g//; t'`
114a6844aabSmrg
1152c393a42Smrg# Now exit if we have it, but it failed.  Also exit now if we
1162c393a42Smrg# don't have it and --version was passed (most likely to detect
117a6844aabSmrg# the program).  This is about non-GNU programs, so use $1 not
118a6844aabSmrg# $program.
119a6844aabSmrgcase $1 in
120a6844aabSmrg  lex*|yacc*)
1212c393a42Smrg    # Not GNU programs, they don't have --version.
1222c393a42Smrg    ;;
1232c393a42Smrg
1242c393a42Smrg  *)
1252c393a42Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1262c393a42Smrg       # We have it, but it failed.
1272c393a42Smrg       exit 1
1282c393a42Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1292c393a42Smrg       # Could not run --version or --help.  This is probably someone
1302c393a42Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1312c393a42Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1322c393a42Smrg       exit 1
1332c393a42Smrg    fi
1342c393a42Smrg    ;;
1352c393a42Smrgesac
1362c393a42Smrg
1372c393a42Smrg# If it does not exist, or fails to run (possibly an outdated version),
1382c393a42Smrg# try to emulate it.
139a6844aabSmrgcase $program in
1402c393a42Smrg  aclocal*)
1412c393a42Smrg    echo 1>&2 "\
1422c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
1432c393a42Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1442c393a42Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1452c393a42Smrg         any GNU archive site."
1462c393a42Smrg    touch aclocal.m4
1472c393a42Smrg    ;;
1482c393a42Smrg
149a6844aabSmrg  autoconf*)
1502c393a42Smrg    echo 1>&2 "\
1512c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
1522c393a42Smrg         you modified \`${configure_ac}'.  You might want to install the
1532c393a42Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1542c393a42Smrg         archive site."
1552c393a42Smrg    touch configure
1562c393a42Smrg    ;;
1572c393a42Smrg
158a6844aabSmrg  autoheader*)
1592c393a42Smrg    echo 1>&2 "\
1602c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
1612c393a42Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1622c393a42Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1632c393a42Smrg         from any GNU archive site."
1642c393a42Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1652c393a42Smrg    test -z "$files" && files="config.h"
1662c393a42Smrg    touch_files=
1672c393a42Smrg    for f in $files; do
168a6844aabSmrg      case $f in
1692c393a42Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1702c393a42Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1712c393a42Smrg      *) touch_files="$touch_files $f.in";;
1722c393a42Smrg      esac
1732c393a42Smrg    done
1742c393a42Smrg    touch $touch_files
1752c393a42Smrg    ;;
1762c393a42Smrg
1772c393a42Smrg  automake*)
1782c393a42Smrg    echo 1>&2 "\
1792c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
1802c393a42Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1812c393a42Smrg         You might want to install the \`Automake' and \`Perl' packages.
1822c393a42Smrg         Grab them from any GNU archive site."
1832c393a42Smrg    find . -type f -name Makefile.am -print |
1842c393a42Smrg	   sed 's/\.am$/.in/' |
1852c393a42Smrg	   while read f; do touch "$f"; done
1862c393a42Smrg    ;;
1872c393a42Smrg
188a6844aabSmrg  autom4te*)
1892c393a42Smrg    echo 1>&2 "\
1902c393a42SmrgWARNING: \`$1' is needed, but is $msg.
1912c393a42Smrg         You might have modified some files without having the
1922c393a42Smrg         proper tools for further handling them.
1932c393a42Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
1942c393a42Smrg         archive site."
1952c393a42Smrg
196a6844aabSmrg    file=`echo "$*" | sed -n "$sed_output"`
197a6844aabSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
1982c393a42Smrg    if test -f "$file"; then
1992c393a42Smrg	touch $file
2002c393a42Smrg    else
2012c393a42Smrg	test -z "$file" || exec >$file
2022c393a42Smrg	echo "#! /bin/sh"
2032c393a42Smrg	echo "# Created by GNU Automake missing as a replacement of"
2042c393a42Smrg	echo "#  $ $@"
2052c393a42Smrg	echo "exit 0"
2062c393a42Smrg	chmod +x $file
2072c393a42Smrg	exit 1
2082c393a42Smrg    fi
2092c393a42Smrg    ;;
2102c393a42Smrg
211a6844aabSmrg  bison*|yacc*)
2122c393a42Smrg    echo 1>&2 "\
2132c393a42SmrgWARNING: \`$1' $msg.  You should only need it if
2142c393a42Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2152c393a42Smrg         in order for those modifications to take effect.  You can get
2162c393a42Smrg         \`Bison' from any GNU archive site."
2172c393a42Smrg    rm -f y.tab.c y.tab.h
218a6844aabSmrg    if test $# -ne 1; then
219ca08ab68Smrg        eval LASTARG=\${$#}
220a6844aabSmrg	case $LASTARG in
2212c393a42Smrg	*.y)
2222c393a42Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
223a6844aabSmrg	    if test -f "$SRCFILE"; then
2242c393a42Smrg	         cp "$SRCFILE" y.tab.c
2252c393a42Smrg	    fi
2262c393a42Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
227a6844aabSmrg	    if test -f "$SRCFILE"; then
2282c393a42Smrg	         cp "$SRCFILE" y.tab.h
2292c393a42Smrg	    fi
2302c393a42Smrg	  ;;
2312c393a42Smrg	esac
2322c393a42Smrg    fi
233a6844aabSmrg    if test ! -f y.tab.h; then
2342c393a42Smrg	echo >y.tab.h
2352c393a42Smrg    fi
236a6844aabSmrg    if test ! -f y.tab.c; then
2372c393a42Smrg	echo 'main() { return 0; }' >y.tab.c
2382c393a42Smrg    fi
2392c393a42Smrg    ;;
2402c393a42Smrg
241a6844aabSmrg  lex*|flex*)
2422c393a42Smrg    echo 1>&2 "\
2432c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
2442c393a42Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2452c393a42Smrg         in order for those modifications to take effect.  You can get
2462c393a42Smrg         \`Flex' from any GNU archive site."
2472c393a42Smrg    rm -f lex.yy.c
248a6844aabSmrg    if test $# -ne 1; then
249ca08ab68Smrg        eval LASTARG=\${$#}
250a6844aabSmrg	case $LASTARG in
2512c393a42Smrg	*.l)
2522c393a42Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
253a6844aabSmrg	    if test -f "$SRCFILE"; then
2542c393a42Smrg	         cp "$SRCFILE" lex.yy.c
2552c393a42Smrg	    fi
2562c393a42Smrg	  ;;
2572c393a42Smrg	esac
2582c393a42Smrg    fi
259a6844aabSmrg    if test ! -f lex.yy.c; then
2602c393a42Smrg	echo 'main() { return 0; }' >lex.yy.c
2612c393a42Smrg    fi
2622c393a42Smrg    ;;
2632c393a42Smrg
264a6844aabSmrg  help2man*)
2652c393a42Smrg    echo 1>&2 "\
2662c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
2672c393a42Smrg	 you modified a dependency of a manual page.  You may need the
2682c393a42Smrg	 \`Help2man' package in order for those modifications to take
2692c393a42Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2702c393a42Smrg
271a6844aabSmrg    file=`echo "$*" | sed -n "$sed_output"`
272a6844aabSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
273a6844aabSmrg    if test -f "$file"; then
2742c393a42Smrg	touch $file
2752c393a42Smrg    else
2762c393a42Smrg	test -z "$file" || exec >$file
2772c393a42Smrg	echo ".ab help2man is required to generate this page"
278a6844aabSmrg	exit $?
2792c393a42Smrg    fi
2802c393a42Smrg    ;;
2812c393a42Smrg
282a6844aabSmrg  makeinfo*)
2832c393a42Smrg    echo 1>&2 "\
2842c393a42SmrgWARNING: \`$1' is $msg.  You should only need it if
2852c393a42Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2862c393a42Smrg         indirectly affecting the aspect of the manual.  The spurious
2872c393a42Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2882c393a42Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2892c393a42Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
2902c393a42Smrg    # The file to touch is that specified with -o ...
291a6844aabSmrg    file=`echo "$*" | sed -n "$sed_output"`
292a6844aabSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2932c393a42Smrg    if test -z "$file"; then
2942c393a42Smrg      # ... or it is the one specified with @setfilename ...
2952c393a42Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296a6844aabSmrg      file=`sed -n '
297a6844aabSmrg	/^@setfilename/{
298a6844aabSmrg	  s/.* \([^ ]*\) *$/\1/
299a6844aabSmrg	  p
300a6844aabSmrg	  q
301a6844aabSmrg	}' $infile`
3022c393a42Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3032c393a42Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3042c393a42Smrg    fi
3052c393a42Smrg    # If the file does not exist, the user really needs makeinfo;
3062c393a42Smrg    # let's fail without touching anything.
3072c393a42Smrg    test -f $file || exit 1
3082c393a42Smrg    touch $file
3092c393a42Smrg    ;;
3102c393a42Smrg
3112c393a42Smrg  *)
3122c393a42Smrg    echo 1>&2 "\
3132c393a42SmrgWARNING: \`$1' is needed, and is $msg.
3142c393a42Smrg         You might have modified some files without having the
3152c393a42Smrg         proper tools for further handling them.  Check the \`README' file,
3162c393a42Smrg         it often tells you about the needed prerequisites for installing
3172c393a42Smrg         this package.  You may also peek at any GNU archive site, in case
3182c393a42Smrg         some other package would contain this missing \`$1' program."
3192c393a42Smrg    exit 1
3202c393a42Smrg    ;;
3212c393a42Smrgesac
3222c393a42Smrg
3232c393a42Smrgexit 0
3242c393a42Smrg
3252c393a42Smrg# Local variables:
3262c393a42Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3272c393a42Smrg# time-stamp-start: "scriptversion="
3282c393a42Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
329a6844aabSmrg# time-stamp-time-zone: "UTC"
330a6844aabSmrg# time-stamp-end: "; # UTC"
3312c393a42Smrg# End:
332