missing revision 9c125d91
116910e25Smrg#! /bin/sh
216910e25Smrg# Common stub for a few missing GNU programs while installing.
39c125d91Smrg
49c125d91Smrgscriptversion=2009-04-28.21; # UTC
59c125d91Smrg
69c125d91Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
79c125d91Smrg# 2008, 2009 Free Software Foundation, Inc.
816910e25Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
916910e25Smrg
1016910e25Smrg# This program is free software; you can redistribute it and/or modify
1116910e25Smrg# it under the terms of the GNU General Public License as published by
1216910e25Smrg# the Free Software Foundation; either version 2, or (at your option)
1316910e25Smrg# any later version.
1416910e25Smrg
1516910e25Smrg# This program is distributed in the hope that it will be useful,
1616910e25Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1716910e25Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1816910e25Smrg# GNU General Public License for more details.
1916910e25Smrg
2016910e25Smrg# You should have received a copy of the GNU General Public License
219c125d91Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2216910e25Smrg
2316910e25Smrg# As a special exception to the GNU General Public License, if you
2416910e25Smrg# distribute this file as part of a program that contains a
2516910e25Smrg# configuration script generated by Autoconf, you may include it under
2616910e25Smrg# the same distribution terms that you use for the rest of that program.
2716910e25Smrg
2816910e25Smrgif test $# -eq 0; then
2916910e25Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3016910e25Smrg  exit 1
3116910e25Smrgfi
3216910e25Smrg
3316910e25Smrgrun=:
349c125d91Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
359c125d91Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3616910e25Smrg
3716910e25Smrg# In the cases where this matters, `missing' is being run in the
3816910e25Smrg# srcdir already.
3916910e25Smrgif test -f configure.ac; then
4016910e25Smrg  configure_ac=configure.ac
4116910e25Smrgelse
4216910e25Smrg  configure_ac=configure.in
4316910e25Smrgfi
4416910e25Smrg
459c125d91Smrgmsg="missing on your system"
469c125d91Smrg
479c125d91Smrgcase $1 in
4816910e25Smrg--run)
4916910e25Smrg  # Try to run requested program, and just exit if it succeeds.
5016910e25Smrg  run=
5116910e25Smrg  shift
5216910e25Smrg  "$@" && exit 0
539c125d91Smrg  # Exit code 63 means version mismatch.  This often happens
549c125d91Smrg  # when the user try to use an ancient version of a tool on
559c125d91Smrg  # a file that requires a minimum version.  In this case we
569c125d91Smrg  # we should proceed has if the program had been absent, or
579c125d91Smrg  # if --run hadn't been passed.
589c125d91Smrg  if test $? = 63; then
599c125d91Smrg    run=:
609c125d91Smrg    msg="probably too old"
619c125d91Smrg  fi
6216910e25Smrg  ;;
6316910e25Smrg
6416910e25Smrg  -h|--h|--he|--hel|--help)
6516910e25Smrg    echo "\
6616910e25Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6716910e25Smrg
6816910e25SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6916910e25Smrgerror status if there is no known handling for PROGRAM.
7016910e25Smrg
7116910e25SmrgOptions:
7216910e25Smrg  -h, --help      display this help and exit
7316910e25Smrg  -v, --version   output version information and exit
7416910e25Smrg  --run           try to run the given command, and emulate it if it fails
7516910e25Smrg
7616910e25SmrgSupported PROGRAM values:
7716910e25Smrg  aclocal      touch file \`aclocal.m4'
7816910e25Smrg  autoconf     touch file \`configure'
7916910e25Smrg  autoheader   touch file \`config.h.in'
809c125d91Smrg  autom4te     touch the output file, or create a stub one
8116910e25Smrg  automake     touch all \`Makefile.in' files
8216910e25Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8316910e25Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8416910e25Smrg  help2man     touch the output file
8516910e25Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8616910e25Smrg  makeinfo     touch the output file
8716910e25Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
889c125d91Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
899c125d91Smrg
909c125d91SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
919c125d91Smrg\`g' are ignored when checking the name.
929c125d91Smrg
939c125d91SmrgSend bug reports to <bug-automake@gnu.org>."
949c125d91Smrg    exit $?
9516910e25Smrg    ;;
9616910e25Smrg
9716910e25Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
989c125d91Smrg    echo "missing $scriptversion (GNU Automake)"
999c125d91Smrg    exit $?
10016910e25Smrg    ;;
10116910e25Smrg
10216910e25Smrg  -*)
10316910e25Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10416910e25Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10516910e25Smrg    exit 1
10616910e25Smrg    ;;
10716910e25Smrg
1089c125d91Smrgesac
1099c125d91Smrg
1109c125d91Smrg# normalize program name to check for.
1119c125d91Smrgprogram=`echo "$1" | sed '
1129c125d91Smrg  s/^gnu-//; t
1139c125d91Smrg  s/^gnu//; t
1149c125d91Smrg  s/^g//; t'`
1159c125d91Smrg
1169c125d91Smrg# Now exit if we have it, but it failed.  Also exit now if we
1179c125d91Smrg# don't have it and --version was passed (most likely to detect
1189c125d91Smrg# the program).  This is about non-GNU programs, so use $1 not
1199c125d91Smrg# $program.
1209c125d91Smrgcase $1 in
1219c125d91Smrg  lex*|yacc*)
1229c125d91Smrg    # Not GNU programs, they don't have --version.
1239c125d91Smrg    ;;
1249c125d91Smrg
1259c125d91Smrg  tar*)
1269c125d91Smrg    if test -n "$run"; then
1279c125d91Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1289c125d91Smrg       exit 1
1299c125d91Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1309c125d91Smrg       exit 1
1319c125d91Smrg    fi
1329c125d91Smrg    ;;
1339c125d91Smrg
1349c125d91Smrg  *)
13516910e25Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
13616910e25Smrg       # We have it, but it failed.
13716910e25Smrg       exit 1
1389c125d91Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1399c125d91Smrg       # Could not run --version or --help.  This is probably someone
1409c125d91Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1419c125d91Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1429c125d91Smrg       exit 1
14316910e25Smrg    fi
1449c125d91Smrg    ;;
1459c125d91Smrgesac
14616910e25Smrg
1479c125d91Smrg# If it does not exist, or fails to run (possibly an outdated version),
1489c125d91Smrg# try to emulate it.
1499c125d91Smrgcase $program in
1509c125d91Smrg  aclocal*)
15116910e25Smrg    echo 1>&2 "\
1529c125d91SmrgWARNING: \`$1' is $msg.  You should only need it if
15316910e25Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
15416910e25Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
15516910e25Smrg         any GNU archive site."
15616910e25Smrg    touch aclocal.m4
15716910e25Smrg    ;;
15816910e25Smrg
1599c125d91Smrg  autoconf*)
16016910e25Smrg    echo 1>&2 "\
1619c125d91SmrgWARNING: \`$1' is $msg.  You should only need it if
16216910e25Smrg         you modified \`${configure_ac}'.  You might want to install the
16316910e25Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
16416910e25Smrg         archive site."
16516910e25Smrg    touch configure
16616910e25Smrg    ;;
16716910e25Smrg
1689c125d91Smrg  autoheader*)
16916910e25Smrg    echo 1>&2 "\
1709c125d91SmrgWARNING: \`$1' is $msg.  You should only need it if
17116910e25Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
17216910e25Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
17316910e25Smrg         from any GNU archive site."
17416910e25Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
17516910e25Smrg    test -z "$files" && files="config.h"
17616910e25Smrg    touch_files=
17716910e25Smrg    for f in $files; do
1789c125d91Smrg      case $f in
17916910e25Smrg      *:*) touch_files="$touch_files "`echo "$f" |
18016910e25Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
18116910e25Smrg      *) touch_files="$touch_files $f.in";;
18216910e25Smrg      esac
18316910e25Smrg    done
18416910e25Smrg    touch $touch_files
18516910e25Smrg    ;;
18616910e25Smrg
18716910e25Smrg  automake*)
18816910e25Smrg    echo 1>&2 "\
1899c125d91SmrgWARNING: \`$1' is $msg.  You should only need it if
19016910e25Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
19116910e25Smrg         You might want to install the \`Automake' and \`Perl' packages.
19216910e25Smrg         Grab them from any GNU archive site."
19316910e25Smrg    find . -type f -name Makefile.am -print |
19416910e25Smrg	   sed 's/\.am$/.in/' |
19516910e25Smrg	   while read f; do touch "$f"; done
19616910e25Smrg    ;;
19716910e25Smrg
1989c125d91Smrg  autom4te*)
19916910e25Smrg    echo 1>&2 "\
2009c125d91SmrgWARNING: \`$1' is needed, but is $msg.
2019c125d91Smrg         You might have modified some files without having the
20216910e25Smrg         proper tools for further handling them.
20316910e25Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
20416910e25Smrg         archive site."
20516910e25Smrg
2069c125d91Smrg    file=`echo "$*" | sed -n "$sed_output"`
2079c125d91Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20816910e25Smrg    if test -f "$file"; then
20916910e25Smrg	touch $file
21016910e25Smrg    else
21116910e25Smrg	test -z "$file" || exec >$file
21216910e25Smrg	echo "#! /bin/sh"
21316910e25Smrg	echo "# Created by GNU Automake missing as a replacement of"
21416910e25Smrg	echo "#  $ $@"
21516910e25Smrg	echo "exit 0"
21616910e25Smrg	chmod +x $file
21716910e25Smrg	exit 1
21816910e25Smrg    fi
21916910e25Smrg    ;;
22016910e25Smrg
2219c125d91Smrg  bison*|yacc*)
22216910e25Smrg    echo 1>&2 "\
2239c125d91SmrgWARNING: \`$1' $msg.  You should only need it if
22416910e25Smrg         you modified a \`.y' file.  You may need the \`Bison' package
22516910e25Smrg         in order for those modifications to take effect.  You can get
22616910e25Smrg         \`Bison' from any GNU archive site."
22716910e25Smrg    rm -f y.tab.c y.tab.h
2289c125d91Smrg    if test $# -ne 1; then
22916910e25Smrg        eval LASTARG="\${$#}"
2309c125d91Smrg	case $LASTARG in
23116910e25Smrg	*.y)
23216910e25Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2339c125d91Smrg	    if test -f "$SRCFILE"; then
23416910e25Smrg	         cp "$SRCFILE" y.tab.c
23516910e25Smrg	    fi
23616910e25Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2379c125d91Smrg	    if test -f "$SRCFILE"; then
23816910e25Smrg	         cp "$SRCFILE" y.tab.h
23916910e25Smrg	    fi
24016910e25Smrg	  ;;
24116910e25Smrg	esac
24216910e25Smrg    fi
2439c125d91Smrg    if test ! -f y.tab.h; then
24416910e25Smrg	echo >y.tab.h
24516910e25Smrg    fi
2469c125d91Smrg    if test ! -f y.tab.c; then
24716910e25Smrg	echo 'main() { return 0; }' >y.tab.c
24816910e25Smrg    fi
24916910e25Smrg    ;;
25016910e25Smrg
2519c125d91Smrg  lex*|flex*)
25216910e25Smrg    echo 1>&2 "\
2539c125d91SmrgWARNING: \`$1' is $msg.  You should only need it if
25416910e25Smrg         you modified a \`.l' file.  You may need the \`Flex' package
25516910e25Smrg         in order for those modifications to take effect.  You can get
25616910e25Smrg         \`Flex' from any GNU archive site."
25716910e25Smrg    rm -f lex.yy.c
2589c125d91Smrg    if test $# -ne 1; then
25916910e25Smrg        eval LASTARG="\${$#}"
2609c125d91Smrg	case $LASTARG in
26116910e25Smrg	*.l)
26216910e25Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2639c125d91Smrg	    if test -f "$SRCFILE"; then
26416910e25Smrg	         cp "$SRCFILE" lex.yy.c
26516910e25Smrg	    fi
26616910e25Smrg	  ;;
26716910e25Smrg	esac
26816910e25Smrg    fi
2699c125d91Smrg    if test ! -f lex.yy.c; then
27016910e25Smrg	echo 'main() { return 0; }' >lex.yy.c
27116910e25Smrg    fi
27216910e25Smrg    ;;
27316910e25Smrg
2749c125d91Smrg  help2man*)
27516910e25Smrg    echo 1>&2 "\
2769c125d91SmrgWARNING: \`$1' is $msg.  You should only need it if
27716910e25Smrg	 you modified a dependency of a manual page.  You may need the
27816910e25Smrg	 \`Help2man' package in order for those modifications to take
27916910e25Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
28016910e25Smrg
2819c125d91Smrg    file=`echo "$*" | sed -n "$sed_output"`
2829c125d91Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2839c125d91Smrg    if test -f "$file"; then
28416910e25Smrg	touch $file
28516910e25Smrg    else
28616910e25Smrg	test -z "$file" || exec >$file
28716910e25Smrg	echo ".ab help2man is required to generate this page"
2889c125d91Smrg	exit $?
28916910e25Smrg    fi
29016910e25Smrg    ;;
29116910e25Smrg
2929c125d91Smrg  makeinfo*)
29316910e25Smrg    echo 1>&2 "\
2949c125d91SmrgWARNING: \`$1' is $msg.  You should only need it if
29516910e25Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
29616910e25Smrg         indirectly affecting the aspect of the manual.  The spurious
29716910e25Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29816910e25Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29916910e25Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
3009c125d91Smrg    # The file to touch is that specified with -o ...
3019c125d91Smrg    file=`echo "$*" | sed -n "$sed_output"`
3029c125d91Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
30316910e25Smrg    if test -z "$file"; then
3049c125d91Smrg      # ... or it is the one specified with @setfilename ...
3059c125d91Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3069c125d91Smrg      file=`sed -n '
3079c125d91Smrg	/^@setfilename/{
3089c125d91Smrg	  s/.* \([^ ]*\) *$/\1/
3099c125d91Smrg	  p
3109c125d91Smrg	  q
3119c125d91Smrg	}' $infile`
3129c125d91Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3139c125d91Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
31416910e25Smrg    fi
3159c125d91Smrg    # If the file does not exist, the user really needs makeinfo;
3169c125d91Smrg    # let's fail without touching anything.
3179c125d91Smrg    test -f $file || exit 1
31816910e25Smrg    touch $file
31916910e25Smrg    ;;
32016910e25Smrg
3219c125d91Smrg  tar*)
32216910e25Smrg    shift
32316910e25Smrg
32416910e25Smrg    # We have already tried tar in the generic part.
32516910e25Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
32616910e25Smrg    # messages.
32716910e25Smrg    if (gnutar --version > /dev/null 2>&1); then
32816910e25Smrg       gnutar "$@" && exit 0
32916910e25Smrg    fi
33016910e25Smrg    if (gtar --version > /dev/null 2>&1); then
33116910e25Smrg       gtar "$@" && exit 0
33216910e25Smrg    fi
33316910e25Smrg    firstarg="$1"
33416910e25Smrg    if shift; then
3359c125d91Smrg	case $firstarg in
33616910e25Smrg	*o*)
33716910e25Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33816910e25Smrg	    tar "$firstarg" "$@" && exit 0
33916910e25Smrg	    ;;
34016910e25Smrg	esac
3419c125d91Smrg	case $firstarg in
34216910e25Smrg	*h*)
34316910e25Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
34416910e25Smrg	    tar "$firstarg" "$@" && exit 0
34516910e25Smrg	    ;;
34616910e25Smrg	esac
34716910e25Smrg    fi
34816910e25Smrg
34916910e25Smrg    echo 1>&2 "\
35016910e25SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
35116910e25Smrg         You may want to install GNU tar or Free paxutils, or check the
35216910e25Smrg         command line arguments."
35316910e25Smrg    exit 1
35416910e25Smrg    ;;
35516910e25Smrg
35616910e25Smrg  *)
35716910e25Smrg    echo 1>&2 "\
3589c125d91SmrgWARNING: \`$1' is needed, and is $msg.
3599c125d91Smrg         You might have modified some files without having the
36016910e25Smrg         proper tools for further handling them.  Check the \`README' file,
36116910e25Smrg         it often tells you about the needed prerequisites for installing
36216910e25Smrg         this package.  You may also peek at any GNU archive site, in case
36316910e25Smrg         some other package would contain this missing \`$1' program."
36416910e25Smrg    exit 1
36516910e25Smrg    ;;
36616910e25Smrgesac
36716910e25Smrg
36816910e25Smrgexit 0
3699c125d91Smrg
3709c125d91Smrg# Local variables:
3719c125d91Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3729c125d91Smrg# time-stamp-start: "scriptversion="
3739c125d91Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3749c125d91Smrg# time-stamp-time-zone: "UTC"
3759c125d91Smrg# time-stamp-end: "; # UTC"
3769c125d91Smrg# End:
377