missing revision 7104f784
109885543Smrg#! /bin/sh
209885543Smrg# Common stub for a few missing GNU programs while installing.
309885543Smrg
47104f784Smrgscriptversion=2006-05-10.23
509885543Smrg
67104f784Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
709885543Smrg#   Free Software Foundation, Inc.
809885543Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
909885543Smrg
1009885543Smrg# This program is free software; you can redistribute it and/or modify
1109885543Smrg# it under the terms of the GNU General Public License as published by
1209885543Smrg# the Free Software Foundation; either version 2, or (at your option)
1309885543Smrg# any later version.
1409885543Smrg
1509885543Smrg# This program is distributed in the hope that it will be useful,
1609885543Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1709885543Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1809885543Smrg# GNU General Public License for more details.
1909885543Smrg
2009885543Smrg# You should have received a copy of the GNU General Public License
2109885543Smrg# along with this program; if not, write to the Free Software
2209885543Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2309885543Smrg# 02110-1301, USA.
2409885543Smrg
2509885543Smrg# As a special exception to the GNU General Public License, if you
2609885543Smrg# distribute this file as part of a program that contains a
2709885543Smrg# configuration script generated by Autoconf, you may include it under
2809885543Smrg# the same distribution terms that you use for the rest of that program.
2909885543Smrg
3009885543Smrgif test $# -eq 0; then
3109885543Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3209885543Smrg  exit 1
3309885543Smrgfi
3409885543Smrg
3509885543Smrgrun=:
367104f784Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
377104f784Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3809885543Smrg
3909885543Smrg# In the cases where this matters, `missing' is being run in the
4009885543Smrg# srcdir already.
4109885543Smrgif test -f configure.ac; then
4209885543Smrg  configure_ac=configure.ac
4309885543Smrgelse
4409885543Smrg  configure_ac=configure.in
4509885543Smrgfi
4609885543Smrg
4709885543Smrgmsg="missing on your system"
4809885543Smrg
497104f784Smrgcase $1 in
5009885543Smrg--run)
5109885543Smrg  # Try to run requested program, and just exit if it succeeds.
5209885543Smrg  run=
5309885543Smrg  shift
5409885543Smrg  "$@" && exit 0
5509885543Smrg  # Exit code 63 means version mismatch.  This often happens
5609885543Smrg  # when the user try to use an ancient version of a tool on
5709885543Smrg  # a file that requires a minimum version.  In this case we
5809885543Smrg  # we should proceed has if the program had been absent, or
5909885543Smrg  # if --run hadn't been passed.
6009885543Smrg  if test $? = 63; then
6109885543Smrg    run=:
6209885543Smrg    msg="probably too old"
6309885543Smrg  fi
6409885543Smrg  ;;
6509885543Smrg
6609885543Smrg  -h|--h|--he|--hel|--help)
6709885543Smrg    echo "\
6809885543Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6909885543Smrg
7009885543SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7109885543Smrgerror status if there is no known handling for PROGRAM.
7209885543Smrg
7309885543SmrgOptions:
7409885543Smrg  -h, --help      display this help and exit
7509885543Smrg  -v, --version   output version information and exit
7609885543Smrg  --run           try to run the given command, and emulate it if it fails
7709885543Smrg
7809885543SmrgSupported PROGRAM values:
7909885543Smrg  aclocal      touch file \`aclocal.m4'
8009885543Smrg  autoconf     touch file \`configure'
8109885543Smrg  autoheader   touch file \`config.h.in'
827104f784Smrg  autom4te     touch the output file, or create a stub one
8309885543Smrg  automake     touch all \`Makefile.in' files
8409885543Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8509885543Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8609885543Smrg  help2man     touch the output file
8709885543Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8809885543Smrg  makeinfo     touch the output file
8909885543Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
9009885543Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
9109885543Smrg
9209885543SmrgSend bug reports to <bug-automake@gnu.org>."
9309885543Smrg    exit $?
9409885543Smrg    ;;
9509885543Smrg
9609885543Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9709885543Smrg    echo "missing $scriptversion (GNU Automake)"
9809885543Smrg    exit $?
9909885543Smrg    ;;
10009885543Smrg
10109885543Smrg  -*)
10209885543Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10309885543Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10409885543Smrg    exit 1
10509885543Smrg    ;;
10609885543Smrg
10709885543Smrgesac
10809885543Smrg
10909885543Smrg# Now exit if we have it, but it failed.  Also exit now if we
11009885543Smrg# don't have it and --version was passed (most likely to detect
11109885543Smrg# the program).
1127104f784Smrgcase $1 in
11309885543Smrg  lex|yacc)
11409885543Smrg    # Not GNU programs, they don't have --version.
11509885543Smrg    ;;
11609885543Smrg
11709885543Smrg  tar)
11809885543Smrg    if test -n "$run"; then
11909885543Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12009885543Smrg       exit 1
12109885543Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12209885543Smrg       exit 1
12309885543Smrg    fi
12409885543Smrg    ;;
12509885543Smrg
12609885543Smrg  *)
12709885543Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12809885543Smrg       # We have it, but it failed.
12909885543Smrg       exit 1
13009885543Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13109885543Smrg       # Could not run --version or --help.  This is probably someone
13209885543Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13309885543Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13409885543Smrg       exit 1
13509885543Smrg    fi
13609885543Smrg    ;;
13709885543Smrgesac
13809885543Smrg
13909885543Smrg# If it does not exist, or fails to run (possibly an outdated version),
14009885543Smrg# try to emulate it.
1417104f784Smrgcase $1 in
14209885543Smrg  aclocal*)
14309885543Smrg    echo 1>&2 "\
14409885543SmrgWARNING: \`$1' is $msg.  You should only need it if
14509885543Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14609885543Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14709885543Smrg         any GNU archive site."
14809885543Smrg    touch aclocal.m4
14909885543Smrg    ;;
15009885543Smrg
15109885543Smrg  autoconf)
15209885543Smrg    echo 1>&2 "\
15309885543SmrgWARNING: \`$1' is $msg.  You should only need it if
15409885543Smrg         you modified \`${configure_ac}'.  You might want to install the
15509885543Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15609885543Smrg         archive site."
15709885543Smrg    touch configure
15809885543Smrg    ;;
15909885543Smrg
16009885543Smrg  autoheader)
16109885543Smrg    echo 1>&2 "\
16209885543SmrgWARNING: \`$1' is $msg.  You should only need it if
16309885543Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16409885543Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16509885543Smrg         from any GNU archive site."
16609885543Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16709885543Smrg    test -z "$files" && files="config.h"
16809885543Smrg    touch_files=
16909885543Smrg    for f in $files; do
1707104f784Smrg      case $f in
17109885543Smrg      *:*) touch_files="$touch_files "`echo "$f" |
17209885543Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17309885543Smrg      *) touch_files="$touch_files $f.in";;
17409885543Smrg      esac
17509885543Smrg    done
17609885543Smrg    touch $touch_files
17709885543Smrg    ;;
17809885543Smrg
17909885543Smrg  automake*)
18009885543Smrg    echo 1>&2 "\
18109885543SmrgWARNING: \`$1' is $msg.  You should only need it if
18209885543Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18309885543Smrg         You might want to install the \`Automake' and \`Perl' packages.
18409885543Smrg         Grab them from any GNU archive site."
18509885543Smrg    find . -type f -name Makefile.am -print |
18609885543Smrg	   sed 's/\.am$/.in/' |
18709885543Smrg	   while read f; do touch "$f"; done
18809885543Smrg    ;;
18909885543Smrg
19009885543Smrg  autom4te)
19109885543Smrg    echo 1>&2 "\
19209885543SmrgWARNING: \`$1' is needed, but is $msg.
19309885543Smrg         You might have modified some files without having the
19409885543Smrg         proper tools for further handling them.
19509885543Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19609885543Smrg         archive site."
19709885543Smrg
1987104f784Smrg    file=`echo "$*" | sed -n "$sed_output"`
1997104f784Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20009885543Smrg    if test -f "$file"; then
20109885543Smrg	touch $file
20209885543Smrg    else
20309885543Smrg	test -z "$file" || exec >$file
20409885543Smrg	echo "#! /bin/sh"
20509885543Smrg	echo "# Created by GNU Automake missing as a replacement of"
20609885543Smrg	echo "#  $ $@"
20709885543Smrg	echo "exit 0"
20809885543Smrg	chmod +x $file
20909885543Smrg	exit 1
21009885543Smrg    fi
21109885543Smrg    ;;
21209885543Smrg
21309885543Smrg  bison|yacc)
21409885543Smrg    echo 1>&2 "\
21509885543SmrgWARNING: \`$1' $msg.  You should only need it if
21609885543Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21709885543Smrg         in order for those modifications to take effect.  You can get
21809885543Smrg         \`Bison' from any GNU archive site."
21909885543Smrg    rm -f y.tab.c y.tab.h
2207104f784Smrg    if test $# -ne 1; then
22109885543Smrg        eval LASTARG="\${$#}"
2227104f784Smrg	case $LASTARG in
22309885543Smrg	*.y)
22409885543Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2257104f784Smrg	    if test -f "$SRCFILE"; then
22609885543Smrg	         cp "$SRCFILE" y.tab.c
22709885543Smrg	    fi
22809885543Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2297104f784Smrg	    if test -f "$SRCFILE"; then
23009885543Smrg	         cp "$SRCFILE" y.tab.h
23109885543Smrg	    fi
23209885543Smrg	  ;;
23309885543Smrg	esac
23409885543Smrg    fi
2357104f784Smrg    if test ! -f y.tab.h; then
23609885543Smrg	echo >y.tab.h
23709885543Smrg    fi
2387104f784Smrg    if test ! -f y.tab.c; then
23909885543Smrg	echo 'main() { return 0; }' >y.tab.c
24009885543Smrg    fi
24109885543Smrg    ;;
24209885543Smrg
24309885543Smrg  lex|flex)
24409885543Smrg    echo 1>&2 "\
24509885543SmrgWARNING: \`$1' is $msg.  You should only need it if
24609885543Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24709885543Smrg         in order for those modifications to take effect.  You can get
24809885543Smrg         \`Flex' from any GNU archive site."
24909885543Smrg    rm -f lex.yy.c
2507104f784Smrg    if test $# -ne 1; then
25109885543Smrg        eval LASTARG="\${$#}"
2527104f784Smrg	case $LASTARG in
25309885543Smrg	*.l)
25409885543Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2557104f784Smrg	    if test -f "$SRCFILE"; then
25609885543Smrg	         cp "$SRCFILE" lex.yy.c
25709885543Smrg	    fi
25809885543Smrg	  ;;
25909885543Smrg	esac
26009885543Smrg    fi
2617104f784Smrg    if test ! -f lex.yy.c; then
26209885543Smrg	echo 'main() { return 0; }' >lex.yy.c
26309885543Smrg    fi
26409885543Smrg    ;;
26509885543Smrg
26609885543Smrg  help2man)
26709885543Smrg    echo 1>&2 "\
26809885543SmrgWARNING: \`$1' is $msg.  You should only need it if
26909885543Smrg	 you modified a dependency of a manual page.  You may need the
27009885543Smrg	 \`Help2man' package in order for those modifications to take
27109885543Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
27209885543Smrg
2737104f784Smrg    file=`echo "$*" | sed -n "$sed_output"`
2747104f784Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2757104f784Smrg    if test -f "$file"; then
27609885543Smrg	touch $file
27709885543Smrg    else
27809885543Smrg	test -z "$file" || exec >$file
27909885543Smrg	echo ".ab help2man is required to generate this page"
28009885543Smrg	exit 1
28109885543Smrg    fi
28209885543Smrg    ;;
28309885543Smrg
28409885543Smrg  makeinfo)
28509885543Smrg    echo 1>&2 "\
28609885543SmrgWARNING: \`$1' is $msg.  You should only need it if
28709885543Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28809885543Smrg         indirectly affecting the aspect of the manual.  The spurious
28909885543Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29009885543Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29109885543Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29209885543Smrg    # The file to touch is that specified with -o ...
2937104f784Smrg    file=`echo "$*" | sed -n "$sed_output"`
2947104f784Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29509885543Smrg    if test -z "$file"; then
29609885543Smrg      # ... or it is the one specified with @setfilename ...
29709885543Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2987104f784Smrg      file=`sed -n '
2997104f784Smrg	/^@setfilename/{
3007104f784Smrg	  s/.* \([^ ]*\) *$/\1/
3017104f784Smrg	  p
3027104f784Smrg	  q
3037104f784Smrg	}' $infile`
30409885543Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30509885543Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30609885543Smrg    fi
30709885543Smrg    # If the file does not exist, the user really needs makeinfo;
30809885543Smrg    # let's fail without touching anything.
30909885543Smrg    test -f $file || exit 1
31009885543Smrg    touch $file
31109885543Smrg    ;;
31209885543Smrg
31309885543Smrg  tar)
31409885543Smrg    shift
31509885543Smrg
31609885543Smrg    # We have already tried tar in the generic part.
31709885543Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31809885543Smrg    # messages.
31909885543Smrg    if (gnutar --version > /dev/null 2>&1); then
32009885543Smrg       gnutar "$@" && exit 0
32109885543Smrg    fi
32209885543Smrg    if (gtar --version > /dev/null 2>&1); then
32309885543Smrg       gtar "$@" && exit 0
32409885543Smrg    fi
32509885543Smrg    firstarg="$1"
32609885543Smrg    if shift; then
3277104f784Smrg	case $firstarg in
32809885543Smrg	*o*)
32909885543Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33009885543Smrg	    tar "$firstarg" "$@" && exit 0
33109885543Smrg	    ;;
33209885543Smrg	esac
3337104f784Smrg	case $firstarg in
33409885543Smrg	*h*)
33509885543Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
33609885543Smrg	    tar "$firstarg" "$@" && exit 0
33709885543Smrg	    ;;
33809885543Smrg	esac
33909885543Smrg    fi
34009885543Smrg
34109885543Smrg    echo 1>&2 "\
34209885543SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
34309885543Smrg         You may want to install GNU tar or Free paxutils, or check the
34409885543Smrg         command line arguments."
34509885543Smrg    exit 1
34609885543Smrg    ;;
34709885543Smrg
34809885543Smrg  *)
34909885543Smrg    echo 1>&2 "\
35009885543SmrgWARNING: \`$1' is needed, and is $msg.
35109885543Smrg         You might have modified some files without having the
35209885543Smrg         proper tools for further handling them.  Check the \`README' file,
35309885543Smrg         it often tells you about the needed prerequisites for installing
35409885543Smrg         this package.  You may also peek at any GNU archive site, in case
35509885543Smrg         some other package would contain this missing \`$1' program."
35609885543Smrg    exit 1
35709885543Smrg    ;;
35809885543Smrgesac
35909885543Smrg
36009885543Smrgexit 0
36109885543Smrg
36209885543Smrg# Local variables:
36309885543Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
36409885543Smrg# time-stamp-start: "scriptversion="
36509885543Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
36609885543Smrg# time-stamp-end: "$"
36709885543Smrg# End:
368