missing revision 74c14cd6
172b676d7Smrg#! /bin/sh
272b676d7Smrg# Common stub for a few missing GNU programs while installing.
372b676d7Smrg
474c14cd6Smrgscriptversion=2012-01-06.13; # UTC
572b676d7Smrg
674c14cd6Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
774c14cd6Smrg# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
872b676d7Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
972b676d7Smrg
1072b676d7Smrg# This program is free software; you can redistribute it and/or modify
1172b676d7Smrg# it under the terms of the GNU General Public License as published by
1272b676d7Smrg# the Free Software Foundation; either version 2, or (at your option)
1372b676d7Smrg# any later version.
1472b676d7Smrg
1572b676d7Smrg# This program is distributed in the hope that it will be useful,
1672b676d7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1772b676d7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1872b676d7Smrg# GNU General Public License for more details.
1972b676d7Smrg
2072b676d7Smrg# You should have received a copy of the GNU General Public License
2174c14cd6Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2272b676d7Smrg
2372b676d7Smrg# As a special exception to the GNU General Public License, if you
2472b676d7Smrg# distribute this file as part of a program that contains a
2572b676d7Smrg# configuration script generated by Autoconf, you may include it under
2672b676d7Smrg# the same distribution terms that you use for the rest of that program.
2772b676d7Smrg
2872b676d7Smrgif test $# -eq 0; then
2972b676d7Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3072b676d7Smrg  exit 1
3172b676d7Smrgfi
3272b676d7Smrg
3372b676d7Smrgrun=:
341fd23544Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
351fd23544Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3672b676d7Smrg
3772b676d7Smrg# In the cases where this matters, `missing' is being run in the
3872b676d7Smrg# srcdir already.
3972b676d7Smrgif test -f configure.ac; then
4072b676d7Smrg  configure_ac=configure.ac
4172b676d7Smrgelse
4272b676d7Smrg  configure_ac=configure.in
4372b676d7Smrgfi
4472b676d7Smrg
4572b676d7Smrgmsg="missing on your system"
4672b676d7Smrg
471fd23544Smrgcase $1 in
4872b676d7Smrg--run)
4972b676d7Smrg  # Try to run requested program, and just exit if it succeeds.
5072b676d7Smrg  run=
5172b676d7Smrg  shift
5272b676d7Smrg  "$@" && exit 0
5372b676d7Smrg  # Exit code 63 means version mismatch.  This often happens
5472b676d7Smrg  # when the user try to use an ancient version of a tool on
5572b676d7Smrg  # a file that requires a minimum version.  In this case we
5672b676d7Smrg  # we should proceed has if the program had been absent, or
5772b676d7Smrg  # if --run hadn't been passed.
5872b676d7Smrg  if test $? = 63; then
5972b676d7Smrg    run=:
6072b676d7Smrg    msg="probably too old"
6172b676d7Smrg  fi
6272b676d7Smrg  ;;
6372b676d7Smrg
6472b676d7Smrg  -h|--h|--he|--hel|--help)
6572b676d7Smrg    echo "\
6672b676d7Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6772b676d7Smrg
6872b676d7SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6972b676d7Smrgerror status if there is no known handling for PROGRAM.
7072b676d7Smrg
7172b676d7SmrgOptions:
7272b676d7Smrg  -h, --help      display this help and exit
7372b676d7Smrg  -v, --version   output version information and exit
7472b676d7Smrg  --run           try to run the given command, and emulate it if it fails
7572b676d7Smrg
7672b676d7SmrgSupported PROGRAM values:
7772b676d7Smrg  aclocal      touch file \`aclocal.m4'
7872b676d7Smrg  autoconf     touch file \`configure'
7972b676d7Smrg  autoheader   touch file \`config.h.in'
801fd23544Smrg  autom4te     touch the output file, or create a stub one
8172b676d7Smrg  automake     touch all \`Makefile.in' files
8272b676d7Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8372b676d7Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8472b676d7Smrg  help2man     touch the output file
8572b676d7Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8672b676d7Smrg  makeinfo     touch the output file
8772b676d7Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8872b676d7Smrg
8974c14cd6SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
9074c14cd6Smrg\`g' are ignored when checking the name.
9174c14cd6Smrg
9272b676d7SmrgSend bug reports to <bug-automake@gnu.org>."
9372b676d7Smrg    exit $?
9472b676d7Smrg    ;;
9572b676d7Smrg
9672b676d7Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9772b676d7Smrg    echo "missing $scriptversion (GNU Automake)"
9872b676d7Smrg    exit $?
9972b676d7Smrg    ;;
10072b676d7Smrg
10172b676d7Smrg  -*)
10272b676d7Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10372b676d7Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10472b676d7Smrg    exit 1
10572b676d7Smrg    ;;
10672b676d7Smrg
10772b676d7Smrgesac
10872b676d7Smrg
10974c14cd6Smrg# normalize program name to check for.
11074c14cd6Smrgprogram=`echo "$1" | sed '
11174c14cd6Smrg  s/^gnu-//; t
11274c14cd6Smrg  s/^gnu//; t
11374c14cd6Smrg  s/^g//; t'`
11474c14cd6Smrg
11572b676d7Smrg# Now exit if we have it, but it failed.  Also exit now if we
11672b676d7Smrg# don't have it and --version was passed (most likely to detect
11774c14cd6Smrg# the program).  This is about non-GNU programs, so use $1 not
11874c14cd6Smrg# $program.
1191fd23544Smrgcase $1 in
12074c14cd6Smrg  lex*|yacc*)
12172b676d7Smrg    # Not GNU programs, they don't have --version.
12272b676d7Smrg    ;;
12372b676d7Smrg
12472b676d7Smrg  *)
12572b676d7Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12672b676d7Smrg       # We have it, but it failed.
12772b676d7Smrg       exit 1
12872b676d7Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12972b676d7Smrg       # Could not run --version or --help.  This is probably someone
13072b676d7Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13172b676d7Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13272b676d7Smrg       exit 1
13372b676d7Smrg    fi
13472b676d7Smrg    ;;
13572b676d7Smrgesac
13672b676d7Smrg
13772b676d7Smrg# If it does not exist, or fails to run (possibly an outdated version),
13872b676d7Smrg# try to emulate it.
13974c14cd6Smrgcase $program in
14072b676d7Smrg  aclocal*)
14172b676d7Smrg    echo 1>&2 "\
14272b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
14372b676d7Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14472b676d7Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14572b676d7Smrg         any GNU archive site."
14672b676d7Smrg    touch aclocal.m4
14772b676d7Smrg    ;;
14872b676d7Smrg
14974c14cd6Smrg  autoconf*)
15072b676d7Smrg    echo 1>&2 "\
15172b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
15272b676d7Smrg         you modified \`${configure_ac}'.  You might want to install the
15372b676d7Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15472b676d7Smrg         archive site."
15572b676d7Smrg    touch configure
15672b676d7Smrg    ;;
15772b676d7Smrg
15874c14cd6Smrg  autoheader*)
15972b676d7Smrg    echo 1>&2 "\
16072b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
16172b676d7Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16272b676d7Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16372b676d7Smrg         from any GNU archive site."
16472b676d7Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16572b676d7Smrg    test -z "$files" && files="config.h"
16672b676d7Smrg    touch_files=
16772b676d7Smrg    for f in $files; do
1681fd23544Smrg      case $f in
16972b676d7Smrg      *:*) touch_files="$touch_files "`echo "$f" |
17072b676d7Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17172b676d7Smrg      *) touch_files="$touch_files $f.in";;
17272b676d7Smrg      esac
17372b676d7Smrg    done
17472b676d7Smrg    touch $touch_files
17572b676d7Smrg    ;;
17672b676d7Smrg
17772b676d7Smrg  automake*)
17872b676d7Smrg    echo 1>&2 "\
17972b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
18072b676d7Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18172b676d7Smrg         You might want to install the \`Automake' and \`Perl' packages.
18272b676d7Smrg         Grab them from any GNU archive site."
18372b676d7Smrg    find . -type f -name Makefile.am -print |
18472b676d7Smrg	   sed 's/\.am$/.in/' |
18572b676d7Smrg	   while read f; do touch "$f"; done
18672b676d7Smrg    ;;
18772b676d7Smrg
18874c14cd6Smrg  autom4te*)
18972b676d7Smrg    echo 1>&2 "\
19072b676d7SmrgWARNING: \`$1' is needed, but is $msg.
19172b676d7Smrg         You might have modified some files without having the
19272b676d7Smrg         proper tools for further handling them.
19372b676d7Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19472b676d7Smrg         archive site."
19572b676d7Smrg
1961fd23544Smrg    file=`echo "$*" | sed -n "$sed_output"`
1971fd23544Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
19872b676d7Smrg    if test -f "$file"; then
19972b676d7Smrg	touch $file
20072b676d7Smrg    else
20172b676d7Smrg	test -z "$file" || exec >$file
20272b676d7Smrg	echo "#! /bin/sh"
20372b676d7Smrg	echo "# Created by GNU Automake missing as a replacement of"
20472b676d7Smrg	echo "#  $ $@"
20572b676d7Smrg	echo "exit 0"
20672b676d7Smrg	chmod +x $file
20772b676d7Smrg	exit 1
20872b676d7Smrg    fi
20972b676d7Smrg    ;;
21072b676d7Smrg
21174c14cd6Smrg  bison*|yacc*)
21272b676d7Smrg    echo 1>&2 "\
21372b676d7SmrgWARNING: \`$1' $msg.  You should only need it if
21472b676d7Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21572b676d7Smrg         in order for those modifications to take effect.  You can get
21672b676d7Smrg         \`Bison' from any GNU archive site."
21772b676d7Smrg    rm -f y.tab.c y.tab.h
2181fd23544Smrg    if test $# -ne 1; then
21974c14cd6Smrg        eval LASTARG=\${$#}
2201fd23544Smrg	case $LASTARG in
22172b676d7Smrg	*.y)
22272b676d7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2231fd23544Smrg	    if test -f "$SRCFILE"; then
22472b676d7Smrg	         cp "$SRCFILE" y.tab.c
22572b676d7Smrg	    fi
22672b676d7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2271fd23544Smrg	    if test -f "$SRCFILE"; then
22872b676d7Smrg	         cp "$SRCFILE" y.tab.h
22972b676d7Smrg	    fi
23072b676d7Smrg	  ;;
23172b676d7Smrg	esac
23272b676d7Smrg    fi
2331fd23544Smrg    if test ! -f y.tab.h; then
23472b676d7Smrg	echo >y.tab.h
23572b676d7Smrg    fi
2361fd23544Smrg    if test ! -f y.tab.c; then
23772b676d7Smrg	echo 'main() { return 0; }' >y.tab.c
23872b676d7Smrg    fi
23972b676d7Smrg    ;;
24072b676d7Smrg
24174c14cd6Smrg  lex*|flex*)
24272b676d7Smrg    echo 1>&2 "\
24372b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
24472b676d7Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24572b676d7Smrg         in order for those modifications to take effect.  You can get
24672b676d7Smrg         \`Flex' from any GNU archive site."
24772b676d7Smrg    rm -f lex.yy.c
2481fd23544Smrg    if test $# -ne 1; then
24974c14cd6Smrg        eval LASTARG=\${$#}
2501fd23544Smrg	case $LASTARG in
25172b676d7Smrg	*.l)
25272b676d7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2531fd23544Smrg	    if test -f "$SRCFILE"; then
25472b676d7Smrg	         cp "$SRCFILE" lex.yy.c
25572b676d7Smrg	    fi
25672b676d7Smrg	  ;;
25772b676d7Smrg	esac
25872b676d7Smrg    fi
2591fd23544Smrg    if test ! -f lex.yy.c; then
26072b676d7Smrg	echo 'main() { return 0; }' >lex.yy.c
26172b676d7Smrg    fi
26272b676d7Smrg    ;;
26372b676d7Smrg
26474c14cd6Smrg  help2man*)
26572b676d7Smrg    echo 1>&2 "\
26672b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
26772b676d7Smrg	 you modified a dependency of a manual page.  You may need the
26872b676d7Smrg	 \`Help2man' package in order for those modifications to take
26972b676d7Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
27072b676d7Smrg
2711fd23544Smrg    file=`echo "$*" | sed -n "$sed_output"`
2721fd23544Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2731fd23544Smrg    if test -f "$file"; then
27472b676d7Smrg	touch $file
27572b676d7Smrg    else
27672b676d7Smrg	test -z "$file" || exec >$file
27772b676d7Smrg	echo ".ab help2man is required to generate this page"
27874c14cd6Smrg	exit $?
27972b676d7Smrg    fi
28072b676d7Smrg    ;;
28172b676d7Smrg
28274c14cd6Smrg  makeinfo*)
28372b676d7Smrg    echo 1>&2 "\
28472b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
28572b676d7Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28672b676d7Smrg         indirectly affecting the aspect of the manual.  The spurious
28772b676d7Smrg         call might also be the consequence of using a buggy \`make' (AIX,
28872b676d7Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
28972b676d7Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29072b676d7Smrg    # The file to touch is that specified with -o ...
2911fd23544Smrg    file=`echo "$*" | sed -n "$sed_output"`
2921fd23544Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29372b676d7Smrg    if test -z "$file"; then
29472b676d7Smrg      # ... or it is the one specified with @setfilename ...
29572b676d7Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2961fd23544Smrg      file=`sed -n '
2971fd23544Smrg	/^@setfilename/{
2981fd23544Smrg	  s/.* \([^ ]*\) *$/\1/
2991fd23544Smrg	  p
3001fd23544Smrg	  q
3011fd23544Smrg	}' $infile`
30272b676d7Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30372b676d7Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30472b676d7Smrg    fi
30572b676d7Smrg    # If the file does not exist, the user really needs makeinfo;
30672b676d7Smrg    # let's fail without touching anything.
30772b676d7Smrg    test -f $file || exit 1
30872b676d7Smrg    touch $file
30972b676d7Smrg    ;;
31072b676d7Smrg
31172b676d7Smrg  *)
31272b676d7Smrg    echo 1>&2 "\
31372b676d7SmrgWARNING: \`$1' is needed, and is $msg.
31472b676d7Smrg         You might have modified some files without having the
31572b676d7Smrg         proper tools for further handling them.  Check the \`README' file,
31672b676d7Smrg         it often tells you about the needed prerequisites for installing
31772b676d7Smrg         this package.  You may also peek at any GNU archive site, in case
31872b676d7Smrg         some other package would contain this missing \`$1' program."
31972b676d7Smrg    exit 1
32072b676d7Smrg    ;;
32172b676d7Smrgesac
32272b676d7Smrg
32372b676d7Smrgexit 0
32472b676d7Smrg
32572b676d7Smrg# Local variables:
32672b676d7Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
32772b676d7Smrg# time-stamp-start: "scriptversion="
32872b676d7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
32974c14cd6Smrg# time-stamp-time-zone: "UTC"
33074c14cd6Smrg# time-stamp-end: "; # UTC"
33172b676d7Smrg# End:
332