missing revision b4d38c65
115fb4814Smrg#! /bin/sh
215fb4814Smrg# Common stub for a few missing GNU programs while installing.
315fb4814Smrg
4b4d38c65Smrgscriptversion=2012-01-06.13; # UTC
515fb4814Smrg
6b4d38c65Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7b4d38c65Smrg# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
815fb4814Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
915fb4814Smrg
1015fb4814Smrg# This program is free software; you can redistribute it and/or modify
1115fb4814Smrg# it under the terms of the GNU General Public License as published by
1215fb4814Smrg# the Free Software Foundation; either version 2, or (at your option)
1315fb4814Smrg# any later version.
1415fb4814Smrg
1515fb4814Smrg# This program is distributed in the hope that it will be useful,
1615fb4814Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1715fb4814Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1815fb4814Smrg# GNU General Public License for more details.
1915fb4814Smrg
2015fb4814Smrg# You should have received a copy of the GNU General Public License
21b4d38c65Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2215fb4814Smrg
2315fb4814Smrg# As a special exception to the GNU General Public License, if you
2415fb4814Smrg# distribute this file as part of a program that contains a
2515fb4814Smrg# configuration script generated by Autoconf, you may include it under
2615fb4814Smrg# the same distribution terms that you use for the rest of that program.
2715fb4814Smrg
2815fb4814Smrgif test $# -eq 0; then
2915fb4814Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3015fb4814Smrg  exit 1
3115fb4814Smrgfi
3215fb4814Smrg
3315fb4814Smrgrun=:
34de78e416Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35de78e416Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3615fb4814Smrg
3715fb4814Smrg# In the cases where this matters, `missing' is being run in the
3815fb4814Smrg# srcdir already.
3915fb4814Smrgif test -f configure.ac; then
4015fb4814Smrg  configure_ac=configure.ac
4115fb4814Smrgelse
4215fb4814Smrg  configure_ac=configure.in
4315fb4814Smrgfi
4415fb4814Smrg
4515fb4814Smrgmsg="missing on your system"
4615fb4814Smrg
47de78e416Smrgcase $1 in
4815fb4814Smrg--run)
4915fb4814Smrg  # Try to run requested program, and just exit if it succeeds.
5015fb4814Smrg  run=
5115fb4814Smrg  shift
5215fb4814Smrg  "$@" && exit 0
5315fb4814Smrg  # Exit code 63 means version mismatch.  This often happens
5415fb4814Smrg  # when the user try to use an ancient version of a tool on
5515fb4814Smrg  # a file that requires a minimum version.  In this case we
5615fb4814Smrg  # we should proceed has if the program had been absent, or
5715fb4814Smrg  # if --run hadn't been passed.
5815fb4814Smrg  if test $? = 63; then
5915fb4814Smrg    run=:
6015fb4814Smrg    msg="probably too old"
6115fb4814Smrg  fi
6215fb4814Smrg  ;;
6315fb4814Smrg
6415fb4814Smrg  -h|--h|--he|--hel|--help)
6515fb4814Smrg    echo "\
6615fb4814Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6715fb4814Smrg
6815fb4814SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6915fb4814Smrgerror status if there is no known handling for PROGRAM.
7015fb4814Smrg
7115fb4814SmrgOptions:
7215fb4814Smrg  -h, --help      display this help and exit
7315fb4814Smrg  -v, --version   output version information and exit
7415fb4814Smrg  --run           try to run the given command, and emulate it if it fails
7515fb4814Smrg
7615fb4814SmrgSupported PROGRAM values:
7715fb4814Smrg  aclocal      touch file \`aclocal.m4'
7815fb4814Smrg  autoconf     touch file \`configure'
7915fb4814Smrg  autoheader   touch file \`config.h.in'
80de78e416Smrg  autom4te     touch the output file, or create a stub one
8115fb4814Smrg  automake     touch all \`Makefile.in' files
8215fb4814Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8315fb4814Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8415fb4814Smrg  help2man     touch the output file
8515fb4814Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8615fb4814Smrg  makeinfo     touch the output file
8715fb4814Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8815fb4814Smrg
89b4d38c65SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
90b4d38c65Smrg\`g' are ignored when checking the name.
91b4d38c65Smrg
9215fb4814SmrgSend bug reports to <bug-automake@gnu.org>."
9315fb4814Smrg    exit $?
9415fb4814Smrg    ;;
9515fb4814Smrg
9615fb4814Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9715fb4814Smrg    echo "missing $scriptversion (GNU Automake)"
9815fb4814Smrg    exit $?
9915fb4814Smrg    ;;
10015fb4814Smrg
10115fb4814Smrg  -*)
10215fb4814Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10315fb4814Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10415fb4814Smrg    exit 1
10515fb4814Smrg    ;;
10615fb4814Smrg
10715fb4814Smrgesac
10815fb4814Smrg
109b4d38c65Smrg# normalize program name to check for.
110b4d38c65Smrgprogram=`echo "$1" | sed '
111b4d38c65Smrg  s/^gnu-//; t
112b4d38c65Smrg  s/^gnu//; t
113b4d38c65Smrg  s/^g//; t'`
114b4d38c65Smrg
11515fb4814Smrg# Now exit if we have it, but it failed.  Also exit now if we
11615fb4814Smrg# don't have it and --version was passed (most likely to detect
117b4d38c65Smrg# the program).  This is about non-GNU programs, so use $1 not
118b4d38c65Smrg# $program.
119de78e416Smrgcase $1 in
120b4d38c65Smrg  lex*|yacc*)
12115fb4814Smrg    # Not GNU programs, they don't have --version.
12215fb4814Smrg    ;;
12315fb4814Smrg
12415fb4814Smrg  *)
12515fb4814Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12615fb4814Smrg       # We have it, but it failed.
12715fb4814Smrg       exit 1
12815fb4814Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12915fb4814Smrg       # Could not run --version or --help.  This is probably someone
13015fb4814Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13115fb4814Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13215fb4814Smrg       exit 1
13315fb4814Smrg    fi
13415fb4814Smrg    ;;
13515fb4814Smrgesac
13615fb4814Smrg
13715fb4814Smrg# If it does not exist, or fails to run (possibly an outdated version),
13815fb4814Smrg# try to emulate it.
139b4d38c65Smrgcase $program in
14015fb4814Smrg  aclocal*)
14115fb4814Smrg    echo 1>&2 "\
14215fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
14315fb4814Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14415fb4814Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14515fb4814Smrg         any GNU archive site."
14615fb4814Smrg    touch aclocal.m4
14715fb4814Smrg    ;;
14815fb4814Smrg
149b4d38c65Smrg  autoconf*)
15015fb4814Smrg    echo 1>&2 "\
15115fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
15215fb4814Smrg         you modified \`${configure_ac}'.  You might want to install the
15315fb4814Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15415fb4814Smrg         archive site."
15515fb4814Smrg    touch configure
15615fb4814Smrg    ;;
15715fb4814Smrg
158b4d38c65Smrg  autoheader*)
15915fb4814Smrg    echo 1>&2 "\
16015fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
16115fb4814Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16215fb4814Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16315fb4814Smrg         from any GNU archive site."
16415fb4814Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16515fb4814Smrg    test -z "$files" && files="config.h"
16615fb4814Smrg    touch_files=
16715fb4814Smrg    for f in $files; do
168de78e416Smrg      case $f in
16915fb4814Smrg      *:*) touch_files="$touch_files "`echo "$f" |
17015fb4814Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17115fb4814Smrg      *) touch_files="$touch_files $f.in";;
17215fb4814Smrg      esac
17315fb4814Smrg    done
17415fb4814Smrg    touch $touch_files
17515fb4814Smrg    ;;
17615fb4814Smrg
17715fb4814Smrg  automake*)
17815fb4814Smrg    echo 1>&2 "\
17915fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
18015fb4814Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18115fb4814Smrg         You might want to install the \`Automake' and \`Perl' packages.
18215fb4814Smrg         Grab them from any GNU archive site."
18315fb4814Smrg    find . -type f -name Makefile.am -print |
18415fb4814Smrg	   sed 's/\.am$/.in/' |
18515fb4814Smrg	   while read f; do touch "$f"; done
18615fb4814Smrg    ;;
18715fb4814Smrg
188b4d38c65Smrg  autom4te*)
18915fb4814Smrg    echo 1>&2 "\
19015fb4814SmrgWARNING: \`$1' is needed, but is $msg.
19115fb4814Smrg         You might have modified some files without having the
19215fb4814Smrg         proper tools for further handling them.
19315fb4814Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19415fb4814Smrg         archive site."
19515fb4814Smrg
196de78e416Smrg    file=`echo "$*" | sed -n "$sed_output"`
197de78e416Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
19815fb4814Smrg    if test -f "$file"; then
19915fb4814Smrg	touch $file
20015fb4814Smrg    else
20115fb4814Smrg	test -z "$file" || exec >$file
20215fb4814Smrg	echo "#! /bin/sh"
20315fb4814Smrg	echo "# Created by GNU Automake missing as a replacement of"
20415fb4814Smrg	echo "#  $ $@"
20515fb4814Smrg	echo "exit 0"
20615fb4814Smrg	chmod +x $file
20715fb4814Smrg	exit 1
20815fb4814Smrg    fi
20915fb4814Smrg    ;;
21015fb4814Smrg
211b4d38c65Smrg  bison*|yacc*)
21215fb4814Smrg    echo 1>&2 "\
21315fb4814SmrgWARNING: \`$1' $msg.  You should only need it if
21415fb4814Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21515fb4814Smrg         in order for those modifications to take effect.  You can get
21615fb4814Smrg         \`Bison' from any GNU archive site."
21715fb4814Smrg    rm -f y.tab.c y.tab.h
218de78e416Smrg    if test $# -ne 1; then
219b4d38c65Smrg        eval LASTARG=\${$#}
220de78e416Smrg	case $LASTARG in
22115fb4814Smrg	*.y)
22215fb4814Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
223de78e416Smrg	    if test -f "$SRCFILE"; then
22415fb4814Smrg	         cp "$SRCFILE" y.tab.c
22515fb4814Smrg	    fi
22615fb4814Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
227de78e416Smrg	    if test -f "$SRCFILE"; then
22815fb4814Smrg	         cp "$SRCFILE" y.tab.h
22915fb4814Smrg	    fi
23015fb4814Smrg	  ;;
23115fb4814Smrg	esac
23215fb4814Smrg    fi
233de78e416Smrg    if test ! -f y.tab.h; then
23415fb4814Smrg	echo >y.tab.h
23515fb4814Smrg    fi
236de78e416Smrg    if test ! -f y.tab.c; then
23715fb4814Smrg	echo 'main() { return 0; }' >y.tab.c
23815fb4814Smrg    fi
23915fb4814Smrg    ;;
24015fb4814Smrg
241b4d38c65Smrg  lex*|flex*)
24215fb4814Smrg    echo 1>&2 "\
24315fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
24415fb4814Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24515fb4814Smrg         in order for those modifications to take effect.  You can get
24615fb4814Smrg         \`Flex' from any GNU archive site."
24715fb4814Smrg    rm -f lex.yy.c
248de78e416Smrg    if test $# -ne 1; then
249b4d38c65Smrg        eval LASTARG=\${$#}
250de78e416Smrg	case $LASTARG in
25115fb4814Smrg	*.l)
25215fb4814Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
253de78e416Smrg	    if test -f "$SRCFILE"; then
25415fb4814Smrg	         cp "$SRCFILE" lex.yy.c
25515fb4814Smrg	    fi
25615fb4814Smrg	  ;;
25715fb4814Smrg	esac
25815fb4814Smrg    fi
259de78e416Smrg    if test ! -f lex.yy.c; then
26015fb4814Smrg	echo 'main() { return 0; }' >lex.yy.c
26115fb4814Smrg    fi
26215fb4814Smrg    ;;
26315fb4814Smrg
264b4d38c65Smrg  help2man*)
26515fb4814Smrg    echo 1>&2 "\
26615fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
26715fb4814Smrg	 you modified a dependency of a manual page.  You may need the
26815fb4814Smrg	 \`Help2man' package in order for those modifications to take
26915fb4814Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
27015fb4814Smrg
271de78e416Smrg    file=`echo "$*" | sed -n "$sed_output"`
272de78e416Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
273de78e416Smrg    if test -f "$file"; then
27415fb4814Smrg	touch $file
27515fb4814Smrg    else
27615fb4814Smrg	test -z "$file" || exec >$file
27715fb4814Smrg	echo ".ab help2man is required to generate this page"
278b4d38c65Smrg	exit $?
27915fb4814Smrg    fi
28015fb4814Smrg    ;;
28115fb4814Smrg
282b4d38c65Smrg  makeinfo*)
28315fb4814Smrg    echo 1>&2 "\
28415fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
28515fb4814Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28615fb4814Smrg         indirectly affecting the aspect of the manual.  The spurious
28715fb4814Smrg         call might also be the consequence of using a buggy \`make' (AIX,
28815fb4814Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
28915fb4814Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29015fb4814Smrg    # The file to touch is that specified with -o ...
291de78e416Smrg    file=`echo "$*" | sed -n "$sed_output"`
292de78e416Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29315fb4814Smrg    if test -z "$file"; then
29415fb4814Smrg      # ... or it is the one specified with @setfilename ...
29515fb4814Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296de78e416Smrg      file=`sed -n '
297de78e416Smrg	/^@setfilename/{
298de78e416Smrg	  s/.* \([^ ]*\) *$/\1/
299de78e416Smrg	  p
300de78e416Smrg	  q
301de78e416Smrg	}' $infile`
30215fb4814Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30315fb4814Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30415fb4814Smrg    fi
30515fb4814Smrg    # If the file does not exist, the user really needs makeinfo;
30615fb4814Smrg    # let's fail without touching anything.
30715fb4814Smrg    test -f $file || exit 1
30815fb4814Smrg    touch $file
30915fb4814Smrg    ;;
31015fb4814Smrg
31115fb4814Smrg  *)
31215fb4814Smrg    echo 1>&2 "\
31315fb4814SmrgWARNING: \`$1' is needed, and is $msg.
31415fb4814Smrg         You might have modified some files without having the
31515fb4814Smrg         proper tools for further handling them.  Check the \`README' file,
31615fb4814Smrg         it often tells you about the needed prerequisites for installing
31715fb4814Smrg         this package.  You may also peek at any GNU archive site, in case
31815fb4814Smrg         some other package would contain this missing \`$1' program."
31915fb4814Smrg    exit 1
32015fb4814Smrg    ;;
32115fb4814Smrgesac
32215fb4814Smrg
32315fb4814Smrgexit 0
32415fb4814Smrg
32515fb4814Smrg# Local variables:
32615fb4814Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
32715fb4814Smrg# time-stamp-start: "scriptversion="
32815fb4814Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
329b4d38c65Smrg# time-stamp-time-zone: "UTC"
330b4d38c65Smrg# time-stamp-end: "; # UTC"
33115fb4814Smrg# End:
332