missing revision 47202d7b
129459361Smrg#! /bin/sh
229459361Smrg# Common stub for a few missing GNU programs while installing.
329459361Smrg
447202d7bSmrgscriptversion=2009-04-28.21; # UTC
529459361Smrg
647202d7bSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
747202d7bSmrg# 2008, 2009 Free Software Foundation, Inc.
829459361Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
929459361Smrg
1029459361Smrg# This program is free software; you can redistribute it and/or modify
1129459361Smrg# it under the terms of the GNU General Public License as published by
1229459361Smrg# the Free Software Foundation; either version 2, or (at your option)
1329459361Smrg# any later version.
1429459361Smrg
1529459361Smrg# This program is distributed in the hope that it will be useful,
1629459361Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1729459361Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1829459361Smrg# GNU General Public License for more details.
1929459361Smrg
2029459361Smrg# You should have received a copy of the GNU General Public License
2147202d7bSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2229459361Smrg
2329459361Smrg# As a special exception to the GNU General Public License, if you
2429459361Smrg# distribute this file as part of a program that contains a
2529459361Smrg# configuration script generated by Autoconf, you may include it under
2629459361Smrg# the same distribution terms that you use for the rest of that program.
2729459361Smrg
2829459361Smrgif test $# -eq 0; then
2929459361Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3029459361Smrg  exit 1
3129459361Smrgfi
3229459361Smrg
3329459361Smrgrun=:
3447202d7bSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3547202d7bSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3629459361Smrg
3729459361Smrg# In the cases where this matters, `missing' is being run in the
3829459361Smrg# srcdir already.
3929459361Smrgif test -f configure.ac; then
4029459361Smrg  configure_ac=configure.ac
4129459361Smrgelse
4229459361Smrg  configure_ac=configure.in
4329459361Smrgfi
4429459361Smrg
4529459361Smrgmsg="missing on your system"
4629459361Smrg
4747202d7bSmrgcase $1 in
4829459361Smrg--run)
4929459361Smrg  # Try to run requested program, and just exit if it succeeds.
5029459361Smrg  run=
5129459361Smrg  shift
5229459361Smrg  "$@" && exit 0
5329459361Smrg  # Exit code 63 means version mismatch.  This often happens
5429459361Smrg  # when the user try to use an ancient version of a tool on
5529459361Smrg  # a file that requires a minimum version.  In this case we
5629459361Smrg  # we should proceed has if the program had been absent, or
5729459361Smrg  # if --run hadn't been passed.
5829459361Smrg  if test $? = 63; then
5929459361Smrg    run=:
6029459361Smrg    msg="probably too old"
6129459361Smrg  fi
6229459361Smrg  ;;
6329459361Smrg
6429459361Smrg  -h|--h|--he|--hel|--help)
6529459361Smrg    echo "\
6629459361Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6729459361Smrg
6829459361SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6929459361Smrgerror status if there is no known handling for PROGRAM.
7029459361Smrg
7129459361SmrgOptions:
7229459361Smrg  -h, --help      display this help and exit
7329459361Smrg  -v, --version   output version information and exit
7429459361Smrg  --run           try to run the given command, and emulate it if it fails
7529459361Smrg
7629459361SmrgSupported PROGRAM values:
7729459361Smrg  aclocal      touch file \`aclocal.m4'
7829459361Smrg  autoconf     touch file \`configure'
7929459361Smrg  autoheader   touch file \`config.h.in'
8047202d7bSmrg  autom4te     touch the output file, or create a stub one
8129459361Smrg  automake     touch all \`Makefile.in' files
8229459361Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8329459361Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8429459361Smrg  help2man     touch the output file
8529459361Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8629459361Smrg  makeinfo     touch the output file
8729459361Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8829459361Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8929459361Smrg
9047202d7bSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
9147202d7bSmrg\`g' are ignored when checking the name.
9247202d7bSmrg
9329459361SmrgSend bug reports to <bug-automake@gnu.org>."
9429459361Smrg    exit $?
9529459361Smrg    ;;
9629459361Smrg
9729459361Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9829459361Smrg    echo "missing $scriptversion (GNU Automake)"
9929459361Smrg    exit $?
10029459361Smrg    ;;
10129459361Smrg
10229459361Smrg  -*)
10329459361Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10429459361Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10529459361Smrg    exit 1
10629459361Smrg    ;;
10729459361Smrg
10829459361Smrgesac
10929459361Smrg
11047202d7bSmrg# normalize program name to check for.
11147202d7bSmrgprogram=`echo "$1" | sed '
11247202d7bSmrg  s/^gnu-//; t
11347202d7bSmrg  s/^gnu//; t
11447202d7bSmrg  s/^g//; t'`
11547202d7bSmrg
11629459361Smrg# Now exit if we have it, but it failed.  Also exit now if we
11729459361Smrg# don't have it and --version was passed (most likely to detect
11847202d7bSmrg# the program).  This is about non-GNU programs, so use $1 not
11947202d7bSmrg# $program.
12047202d7bSmrgcase $1 in
12147202d7bSmrg  lex*|yacc*)
12229459361Smrg    # Not GNU programs, they don't have --version.
12329459361Smrg    ;;
12429459361Smrg
12547202d7bSmrg  tar*)
12629459361Smrg    if test -n "$run"; then
12729459361Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12829459361Smrg       exit 1
12929459361Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13029459361Smrg       exit 1
13129459361Smrg    fi
13229459361Smrg    ;;
13329459361Smrg
13429459361Smrg  *)
13529459361Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
13629459361Smrg       # We have it, but it failed.
13729459361Smrg       exit 1
13829459361Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13929459361Smrg       # Could not run --version or --help.  This is probably someone
14029459361Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
14129459361Smrg       # $TOOL exists and not knowing $TOOL uses missing.
14229459361Smrg       exit 1
14329459361Smrg    fi
14429459361Smrg    ;;
14529459361Smrgesac
14629459361Smrg
14729459361Smrg# If it does not exist, or fails to run (possibly an outdated version),
14829459361Smrg# try to emulate it.
14947202d7bSmrgcase $program in
15029459361Smrg  aclocal*)
15129459361Smrg    echo 1>&2 "\
15229459361SmrgWARNING: \`$1' is $msg.  You should only need it if
15329459361Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
15429459361Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
15529459361Smrg         any GNU archive site."
15629459361Smrg    touch aclocal.m4
15729459361Smrg    ;;
15829459361Smrg
15947202d7bSmrg  autoconf*)
16029459361Smrg    echo 1>&2 "\
16129459361SmrgWARNING: \`$1' is $msg.  You should only need it if
16229459361Smrg         you modified \`${configure_ac}'.  You might want to install the
16329459361Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
16429459361Smrg         archive site."
16529459361Smrg    touch configure
16629459361Smrg    ;;
16729459361Smrg
16847202d7bSmrg  autoheader*)
16929459361Smrg    echo 1>&2 "\
17029459361SmrgWARNING: \`$1' is $msg.  You should only need it if
17129459361Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
17229459361Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
17329459361Smrg         from any GNU archive site."
17429459361Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
17529459361Smrg    test -z "$files" && files="config.h"
17629459361Smrg    touch_files=
17729459361Smrg    for f in $files; do
17847202d7bSmrg      case $f in
17929459361Smrg      *:*) touch_files="$touch_files "`echo "$f" |
18029459361Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
18129459361Smrg      *) touch_files="$touch_files $f.in";;
18229459361Smrg      esac
18329459361Smrg    done
18429459361Smrg    touch $touch_files
18529459361Smrg    ;;
18629459361Smrg
18729459361Smrg  automake*)
18829459361Smrg    echo 1>&2 "\
18929459361SmrgWARNING: \`$1' is $msg.  You should only need it if
19029459361Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
19129459361Smrg         You might want to install the \`Automake' and \`Perl' packages.
19229459361Smrg         Grab them from any GNU archive site."
19329459361Smrg    find . -type f -name Makefile.am -print |
19429459361Smrg	   sed 's/\.am$/.in/' |
19529459361Smrg	   while read f; do touch "$f"; done
19629459361Smrg    ;;
19729459361Smrg
19847202d7bSmrg  autom4te*)
19929459361Smrg    echo 1>&2 "\
20029459361SmrgWARNING: \`$1' is needed, but is $msg.
20129459361Smrg         You might have modified some files without having the
20229459361Smrg         proper tools for further handling them.
20329459361Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
20429459361Smrg         archive site."
20529459361Smrg
20647202d7bSmrg    file=`echo "$*" | sed -n "$sed_output"`
20747202d7bSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20829459361Smrg    if test -f "$file"; then
20929459361Smrg	touch $file
21029459361Smrg    else
21129459361Smrg	test -z "$file" || exec >$file
21229459361Smrg	echo "#! /bin/sh"
21329459361Smrg	echo "# Created by GNU Automake missing as a replacement of"
21429459361Smrg	echo "#  $ $@"
21529459361Smrg	echo "exit 0"
21629459361Smrg	chmod +x $file
21729459361Smrg	exit 1
21829459361Smrg    fi
21929459361Smrg    ;;
22029459361Smrg
22147202d7bSmrg  bison*|yacc*)
22229459361Smrg    echo 1>&2 "\
22329459361SmrgWARNING: \`$1' $msg.  You should only need it if
22429459361Smrg         you modified a \`.y' file.  You may need the \`Bison' package
22529459361Smrg         in order for those modifications to take effect.  You can get
22629459361Smrg         \`Bison' from any GNU archive site."
22729459361Smrg    rm -f y.tab.c y.tab.h
22847202d7bSmrg    if test $# -ne 1; then
22929459361Smrg        eval LASTARG="\${$#}"
23047202d7bSmrg	case $LASTARG in
23129459361Smrg	*.y)
23229459361Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
23347202d7bSmrg	    if test -f "$SRCFILE"; then
23429459361Smrg	         cp "$SRCFILE" y.tab.c
23529459361Smrg	    fi
23629459361Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
23747202d7bSmrg	    if test -f "$SRCFILE"; then
23829459361Smrg	         cp "$SRCFILE" y.tab.h
23929459361Smrg	    fi
24029459361Smrg	  ;;
24129459361Smrg	esac
24229459361Smrg    fi
24347202d7bSmrg    if test ! -f y.tab.h; then
24429459361Smrg	echo >y.tab.h
24529459361Smrg    fi
24647202d7bSmrg    if test ! -f y.tab.c; then
24729459361Smrg	echo 'main() { return 0; }' >y.tab.c
24829459361Smrg    fi
24929459361Smrg    ;;
25029459361Smrg
25147202d7bSmrg  lex*|flex*)
25229459361Smrg    echo 1>&2 "\
25329459361SmrgWARNING: \`$1' is $msg.  You should only need it if
25429459361Smrg         you modified a \`.l' file.  You may need the \`Flex' package
25529459361Smrg         in order for those modifications to take effect.  You can get
25629459361Smrg         \`Flex' from any GNU archive site."
25729459361Smrg    rm -f lex.yy.c
25847202d7bSmrg    if test $# -ne 1; then
25929459361Smrg        eval LASTARG="\${$#}"
26047202d7bSmrg	case $LASTARG in
26129459361Smrg	*.l)
26229459361Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
26347202d7bSmrg	    if test -f "$SRCFILE"; then
26429459361Smrg	         cp "$SRCFILE" lex.yy.c
26529459361Smrg	    fi
26629459361Smrg	  ;;
26729459361Smrg	esac
26829459361Smrg    fi
26947202d7bSmrg    if test ! -f lex.yy.c; then
27029459361Smrg	echo 'main() { return 0; }' >lex.yy.c
27129459361Smrg    fi
27229459361Smrg    ;;
27329459361Smrg
27447202d7bSmrg  help2man*)
27529459361Smrg    echo 1>&2 "\
27629459361SmrgWARNING: \`$1' is $msg.  You should only need it if
27729459361Smrg	 you modified a dependency of a manual page.  You may need the
27829459361Smrg	 \`Help2man' package in order for those modifications to take
27929459361Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
28029459361Smrg
28147202d7bSmrg    file=`echo "$*" | sed -n "$sed_output"`
28247202d7bSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
28347202d7bSmrg    if test -f "$file"; then
28429459361Smrg	touch $file
28529459361Smrg    else
28629459361Smrg	test -z "$file" || exec >$file
28729459361Smrg	echo ".ab help2man is required to generate this page"
28847202d7bSmrg	exit $?
28929459361Smrg    fi
29029459361Smrg    ;;
29129459361Smrg
29247202d7bSmrg  makeinfo*)
29329459361Smrg    echo 1>&2 "\
29429459361SmrgWARNING: \`$1' is $msg.  You should only need it if
29529459361Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
29629459361Smrg         indirectly affecting the aspect of the manual.  The spurious
29729459361Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29829459361Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29929459361Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
30029459361Smrg    # The file to touch is that specified with -o ...
30147202d7bSmrg    file=`echo "$*" | sed -n "$sed_output"`
30247202d7bSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
30329459361Smrg    if test -z "$file"; then
30429459361Smrg      # ... or it is the one specified with @setfilename ...
30529459361Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
30647202d7bSmrg      file=`sed -n '
30747202d7bSmrg	/^@setfilename/{
30847202d7bSmrg	  s/.* \([^ ]*\) *$/\1/
30947202d7bSmrg	  p
31047202d7bSmrg	  q
31147202d7bSmrg	}' $infile`
31229459361Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
31329459361Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
31429459361Smrg    fi
31529459361Smrg    # If the file does not exist, the user really needs makeinfo;
31629459361Smrg    # let's fail without touching anything.
31729459361Smrg    test -f $file || exit 1
31829459361Smrg    touch $file
31929459361Smrg    ;;
32029459361Smrg
32147202d7bSmrg  tar*)
32229459361Smrg    shift
32329459361Smrg
32429459361Smrg    # We have already tried tar in the generic part.
32529459361Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
32629459361Smrg    # messages.
32729459361Smrg    if (gnutar --version > /dev/null 2>&1); then
32829459361Smrg       gnutar "$@" && exit 0
32929459361Smrg    fi
33029459361Smrg    if (gtar --version > /dev/null 2>&1); then
33129459361Smrg       gtar "$@" && exit 0
33229459361Smrg    fi
33329459361Smrg    firstarg="$1"
33429459361Smrg    if shift; then
33547202d7bSmrg	case $firstarg in
33629459361Smrg	*o*)
33729459361Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33829459361Smrg	    tar "$firstarg" "$@" && exit 0
33929459361Smrg	    ;;
34029459361Smrg	esac
34147202d7bSmrg	case $firstarg in
34229459361Smrg	*h*)
34329459361Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
34429459361Smrg	    tar "$firstarg" "$@" && exit 0
34529459361Smrg	    ;;
34629459361Smrg	esac
34729459361Smrg    fi
34829459361Smrg
34929459361Smrg    echo 1>&2 "\
35029459361SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
35129459361Smrg         You may want to install GNU tar or Free paxutils, or check the
35229459361Smrg         command line arguments."
35329459361Smrg    exit 1
35429459361Smrg    ;;
35529459361Smrg
35629459361Smrg  *)
35729459361Smrg    echo 1>&2 "\
35829459361SmrgWARNING: \`$1' is needed, and is $msg.
35929459361Smrg         You might have modified some files without having the
36029459361Smrg         proper tools for further handling them.  Check the \`README' file,
36129459361Smrg         it often tells you about the needed prerequisites for installing
36229459361Smrg         this package.  You may also peek at any GNU archive site, in case
36329459361Smrg         some other package would contain this missing \`$1' program."
36429459361Smrg    exit 1
36529459361Smrg    ;;
36629459361Smrgesac
36729459361Smrg
36829459361Smrgexit 0
36929459361Smrg
37029459361Smrg# Local variables:
37129459361Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
37229459361Smrg# time-stamp-start: "scriptversion="
37329459361Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
37447202d7bSmrg# time-stamp-time-zone: "UTC"
37547202d7bSmrg# time-stamp-end: "; # UTC"
37629459361Smrg# End:
377