missing revision 0ad07f78
198049353Smrg#! /bin/sh
298049353Smrg# Common stub for a few missing GNU programs while installing.
30ad07f78Smrg
40ad07f78Smrgscriptversion=2009-04-28.21; # UTC
50ad07f78Smrg
60ad07f78Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
70ad07f78Smrg# 2008, 2009 Free Software Foundation, Inc.
898049353Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
998049353Smrg
1098049353Smrg# This program is free software; you can redistribute it and/or modify
1198049353Smrg# it under the terms of the GNU General Public License as published by
1298049353Smrg# the Free Software Foundation; either version 2, or (at your option)
1398049353Smrg# any later version.
1498049353Smrg
1598049353Smrg# This program is distributed in the hope that it will be useful,
1698049353Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1798049353Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1898049353Smrg# GNU General Public License for more details.
1998049353Smrg
2098049353Smrg# You should have received a copy of the GNU General Public License
210ad07f78Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2298049353Smrg
2398049353Smrg# As a special exception to the GNU General Public License, if you
2498049353Smrg# distribute this file as part of a program that contains a
2598049353Smrg# configuration script generated by Autoconf, you may include it under
2698049353Smrg# the same distribution terms that you use for the rest of that program.
2798049353Smrg
2898049353Smrgif test $# -eq 0; then
2998049353Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3098049353Smrg  exit 1
3198049353Smrgfi
3298049353Smrg
3398049353Smrgrun=:
340ad07f78Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
350ad07f78Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3698049353Smrg
3798049353Smrg# In the cases where this matters, `missing' is being run in the
3898049353Smrg# srcdir already.
3998049353Smrgif test -f configure.ac; then
4098049353Smrg  configure_ac=configure.ac
4198049353Smrgelse
4298049353Smrg  configure_ac=configure.in
4398049353Smrgfi
4498049353Smrg
450ad07f78Smrgmsg="missing on your system"
460ad07f78Smrg
470ad07f78Smrgcase $1 in
4898049353Smrg--run)
4998049353Smrg  # Try to run requested program, and just exit if it succeeds.
5098049353Smrg  run=
5198049353Smrg  shift
5298049353Smrg  "$@" && exit 0
530ad07f78Smrg  # Exit code 63 means version mismatch.  This often happens
540ad07f78Smrg  # when the user try to use an ancient version of a tool on
550ad07f78Smrg  # a file that requires a minimum version.  In this case we
560ad07f78Smrg  # we should proceed has if the program had been absent, or
570ad07f78Smrg  # if --run hadn't been passed.
580ad07f78Smrg  if test $? = 63; then
590ad07f78Smrg    run=:
600ad07f78Smrg    msg="probably too old"
610ad07f78Smrg  fi
6298049353Smrg  ;;
6398049353Smrg
6498049353Smrg  -h|--h|--he|--hel|--help)
6598049353Smrg    echo "\
6698049353Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6798049353Smrg
6898049353SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6998049353Smrgerror status if there is no known handling for PROGRAM.
7098049353Smrg
7198049353SmrgOptions:
7298049353Smrg  -h, --help      display this help and exit
7398049353Smrg  -v, --version   output version information and exit
7498049353Smrg  --run           try to run the given command, and emulate it if it fails
7598049353Smrg
7698049353SmrgSupported PROGRAM values:
7798049353Smrg  aclocal      touch file \`aclocal.m4'
7898049353Smrg  autoconf     touch file \`configure'
7998049353Smrg  autoheader   touch file \`config.h.in'
800ad07f78Smrg  autom4te     touch the output file, or create a stub one
8198049353Smrg  automake     touch all \`Makefile.in' files
8298049353Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8398049353Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8498049353Smrg  help2man     touch the output file
8598049353Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8698049353Smrg  makeinfo     touch the output file
8798049353Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
880ad07f78Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
890ad07f78Smrg
900ad07f78SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
910ad07f78Smrg\`g' are ignored when checking the name.
920ad07f78Smrg
930ad07f78SmrgSend bug reports to <bug-automake@gnu.org>."
940ad07f78Smrg    exit $?
9598049353Smrg    ;;
9698049353Smrg
9798049353Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
980ad07f78Smrg    echo "missing $scriptversion (GNU Automake)"
990ad07f78Smrg    exit $?
10098049353Smrg    ;;
10198049353Smrg
10298049353Smrg  -*)
10398049353Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10498049353Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10598049353Smrg    exit 1
10698049353Smrg    ;;
10798049353Smrg
1080ad07f78Smrgesac
1090ad07f78Smrg
1100ad07f78Smrg# normalize program name to check for.
1110ad07f78Smrgprogram=`echo "$1" | sed '
1120ad07f78Smrg  s/^gnu-//; t
1130ad07f78Smrg  s/^gnu//; t
1140ad07f78Smrg  s/^g//; t'`
1150ad07f78Smrg
1160ad07f78Smrg# Now exit if we have it, but it failed.  Also exit now if we
1170ad07f78Smrg# don't have it and --version was passed (most likely to detect
1180ad07f78Smrg# the program).  This is about non-GNU programs, so use $1 not
1190ad07f78Smrg# $program.
1200ad07f78Smrgcase $1 in
1210ad07f78Smrg  lex*|yacc*)
1220ad07f78Smrg    # Not GNU programs, they don't have --version.
1230ad07f78Smrg    ;;
1240ad07f78Smrg
1250ad07f78Smrg  tar*)
1260ad07f78Smrg    if test -n "$run"; then
1270ad07f78Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1280ad07f78Smrg       exit 1
1290ad07f78Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1300ad07f78Smrg       exit 1
1310ad07f78Smrg    fi
1320ad07f78Smrg    ;;
1330ad07f78Smrg
1340ad07f78Smrg  *)
13598049353Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
13698049353Smrg       # We have it, but it failed.
13798049353Smrg       exit 1
1380ad07f78Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1390ad07f78Smrg       # Could not run --version or --help.  This is probably someone
1400ad07f78Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1410ad07f78Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1420ad07f78Smrg       exit 1
14398049353Smrg    fi
1440ad07f78Smrg    ;;
1450ad07f78Smrgesac
14698049353Smrg
1470ad07f78Smrg# If it does not exist, or fails to run (possibly an outdated version),
1480ad07f78Smrg# try to emulate it.
1490ad07f78Smrgcase $program in
1500ad07f78Smrg  aclocal*)
15198049353Smrg    echo 1>&2 "\
1520ad07f78SmrgWARNING: \`$1' is $msg.  You should only need it if
15398049353Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
15498049353Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
15598049353Smrg         any GNU archive site."
15698049353Smrg    touch aclocal.m4
15798049353Smrg    ;;
15898049353Smrg
1590ad07f78Smrg  autoconf*)
16098049353Smrg    echo 1>&2 "\
1610ad07f78SmrgWARNING: \`$1' is $msg.  You should only need it if
16298049353Smrg         you modified \`${configure_ac}'.  You might want to install the
16398049353Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
16498049353Smrg         archive site."
16598049353Smrg    touch configure
16698049353Smrg    ;;
16798049353Smrg
1680ad07f78Smrg  autoheader*)
16998049353Smrg    echo 1>&2 "\
1700ad07f78SmrgWARNING: \`$1' is $msg.  You should only need it if
17198049353Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
17298049353Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
17398049353Smrg         from any GNU archive site."
17498049353Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
17598049353Smrg    test -z "$files" && files="config.h"
17698049353Smrg    touch_files=
17798049353Smrg    for f in $files; do
1780ad07f78Smrg      case $f in
17998049353Smrg      *:*) touch_files="$touch_files "`echo "$f" |
18098049353Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
18198049353Smrg      *) touch_files="$touch_files $f.in";;
18298049353Smrg      esac
18398049353Smrg    done
18498049353Smrg    touch $touch_files
18598049353Smrg    ;;
18698049353Smrg
18798049353Smrg  automake*)
18898049353Smrg    echo 1>&2 "\
1890ad07f78SmrgWARNING: \`$1' is $msg.  You should only need it if
19098049353Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
19198049353Smrg         You might want to install the \`Automake' and \`Perl' packages.
19298049353Smrg         Grab them from any GNU archive site."
19398049353Smrg    find . -type f -name Makefile.am -print |
19498049353Smrg	   sed 's/\.am$/.in/' |
19598049353Smrg	   while read f; do touch "$f"; done
19698049353Smrg    ;;
19798049353Smrg
1980ad07f78Smrg  autom4te*)
19998049353Smrg    echo 1>&2 "\
2000ad07f78SmrgWARNING: \`$1' is needed, but is $msg.
2010ad07f78Smrg         You might have modified some files without having the
20298049353Smrg         proper tools for further handling them.
20398049353Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
20498049353Smrg         archive site."
20598049353Smrg
2060ad07f78Smrg    file=`echo "$*" | sed -n "$sed_output"`
2070ad07f78Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20898049353Smrg    if test -f "$file"; then
20998049353Smrg	touch $file
21098049353Smrg    else
21198049353Smrg	test -z "$file" || exec >$file
21298049353Smrg	echo "#! /bin/sh"
21398049353Smrg	echo "# Created by GNU Automake missing as a replacement of"
21498049353Smrg	echo "#  $ $@"
21598049353Smrg	echo "exit 0"
21698049353Smrg	chmod +x $file
21798049353Smrg	exit 1
21898049353Smrg    fi
21998049353Smrg    ;;
22098049353Smrg
2210ad07f78Smrg  bison*|yacc*)
22298049353Smrg    echo 1>&2 "\
2230ad07f78SmrgWARNING: \`$1' $msg.  You should only need it if
22498049353Smrg         you modified a \`.y' file.  You may need the \`Bison' package
22598049353Smrg         in order for those modifications to take effect.  You can get
22698049353Smrg         \`Bison' from any GNU archive site."
22798049353Smrg    rm -f y.tab.c y.tab.h
2280ad07f78Smrg    if test $# -ne 1; then
22998049353Smrg        eval LASTARG="\${$#}"
2300ad07f78Smrg	case $LASTARG in
23198049353Smrg	*.y)
23298049353Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2330ad07f78Smrg	    if test -f "$SRCFILE"; then
23498049353Smrg	         cp "$SRCFILE" y.tab.c
23598049353Smrg	    fi
23698049353Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2370ad07f78Smrg	    if test -f "$SRCFILE"; then
23898049353Smrg	         cp "$SRCFILE" y.tab.h
23998049353Smrg	    fi
24098049353Smrg	  ;;
24198049353Smrg	esac
24298049353Smrg    fi
2430ad07f78Smrg    if test ! -f y.tab.h; then
24498049353Smrg	echo >y.tab.h
24598049353Smrg    fi
2460ad07f78Smrg    if test ! -f y.tab.c; then
24798049353Smrg	echo 'main() { return 0; }' >y.tab.c
24898049353Smrg    fi
24998049353Smrg    ;;
25098049353Smrg
2510ad07f78Smrg  lex*|flex*)
25298049353Smrg    echo 1>&2 "\
2530ad07f78SmrgWARNING: \`$1' is $msg.  You should only need it if
25498049353Smrg         you modified a \`.l' file.  You may need the \`Flex' package
25598049353Smrg         in order for those modifications to take effect.  You can get
25698049353Smrg         \`Flex' from any GNU archive site."
25798049353Smrg    rm -f lex.yy.c
2580ad07f78Smrg    if test $# -ne 1; then
25998049353Smrg        eval LASTARG="\${$#}"
2600ad07f78Smrg	case $LASTARG in
26198049353Smrg	*.l)
26298049353Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2630ad07f78Smrg	    if test -f "$SRCFILE"; then
26498049353Smrg	         cp "$SRCFILE" lex.yy.c
26598049353Smrg	    fi
26698049353Smrg	  ;;
26798049353Smrg	esac
26898049353Smrg    fi
2690ad07f78Smrg    if test ! -f lex.yy.c; then
27098049353Smrg	echo 'main() { return 0; }' >lex.yy.c
27198049353Smrg    fi
27298049353Smrg    ;;
27398049353Smrg
2740ad07f78Smrg  help2man*)
27598049353Smrg    echo 1>&2 "\
2760ad07f78SmrgWARNING: \`$1' is $msg.  You should only need it if
27798049353Smrg	 you modified a dependency of a manual page.  You may need the
27898049353Smrg	 \`Help2man' package in order for those modifications to take
27998049353Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
28098049353Smrg
2810ad07f78Smrg    file=`echo "$*" | sed -n "$sed_output"`
2820ad07f78Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2830ad07f78Smrg    if test -f "$file"; then
28498049353Smrg	touch $file
28598049353Smrg    else
28698049353Smrg	test -z "$file" || exec >$file
28798049353Smrg	echo ".ab help2man is required to generate this page"
2880ad07f78Smrg	exit $?
28998049353Smrg    fi
29098049353Smrg    ;;
29198049353Smrg
2920ad07f78Smrg  makeinfo*)
29398049353Smrg    echo 1>&2 "\
2940ad07f78SmrgWARNING: \`$1' is $msg.  You should only need it if
29598049353Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
29698049353Smrg         indirectly affecting the aspect of the manual.  The spurious
29798049353Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29898049353Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29998049353Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
3000ad07f78Smrg    # The file to touch is that specified with -o ...
3010ad07f78Smrg    file=`echo "$*" | sed -n "$sed_output"`
3020ad07f78Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
30398049353Smrg    if test -z "$file"; then
3040ad07f78Smrg      # ... or it is the one specified with @setfilename ...
3050ad07f78Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3060ad07f78Smrg      file=`sed -n '
3070ad07f78Smrg	/^@setfilename/{
3080ad07f78Smrg	  s/.* \([^ ]*\) *$/\1/
3090ad07f78Smrg	  p
3100ad07f78Smrg	  q
3110ad07f78Smrg	}' $infile`
3120ad07f78Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3130ad07f78Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
31498049353Smrg    fi
3150ad07f78Smrg    # If the file does not exist, the user really needs makeinfo;
3160ad07f78Smrg    # let's fail without touching anything.
3170ad07f78Smrg    test -f $file || exit 1
31898049353Smrg    touch $file
31998049353Smrg    ;;
32098049353Smrg
3210ad07f78Smrg  tar*)
32298049353Smrg    shift
32398049353Smrg
32498049353Smrg    # We have already tried tar in the generic part.
32598049353Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
32698049353Smrg    # messages.
32798049353Smrg    if (gnutar --version > /dev/null 2>&1); then
32898049353Smrg       gnutar "$@" && exit 0
32998049353Smrg    fi
33098049353Smrg    if (gtar --version > /dev/null 2>&1); then
33198049353Smrg       gtar "$@" && exit 0
33298049353Smrg    fi
33398049353Smrg    firstarg="$1"
33498049353Smrg    if shift; then
3350ad07f78Smrg	case $firstarg in
33698049353Smrg	*o*)
33798049353Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33898049353Smrg	    tar "$firstarg" "$@" && exit 0
33998049353Smrg	    ;;
34098049353Smrg	esac
3410ad07f78Smrg	case $firstarg in
34298049353Smrg	*h*)
34398049353Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
34498049353Smrg	    tar "$firstarg" "$@" && exit 0
34598049353Smrg	    ;;
34698049353Smrg	esac
34798049353Smrg    fi
34898049353Smrg
34998049353Smrg    echo 1>&2 "\
35098049353SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
35198049353Smrg         You may want to install GNU tar or Free paxutils, or check the
35298049353Smrg         command line arguments."
35398049353Smrg    exit 1
35498049353Smrg    ;;
35598049353Smrg
35698049353Smrg  *)
35798049353Smrg    echo 1>&2 "\
3580ad07f78SmrgWARNING: \`$1' is needed, and is $msg.
3590ad07f78Smrg         You might have modified some files without having the
36098049353Smrg         proper tools for further handling them.  Check the \`README' file,
36198049353Smrg         it often tells you about the needed prerequisites for installing
36298049353Smrg         this package.  You may also peek at any GNU archive site, in case
36398049353Smrg         some other package would contain this missing \`$1' program."
36498049353Smrg    exit 1
36598049353Smrg    ;;
36698049353Smrgesac
36798049353Smrg
36898049353Smrgexit 0
3690ad07f78Smrg
3700ad07f78Smrg# Local variables:
3710ad07f78Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3720ad07f78Smrg# time-stamp-start: "scriptversion="
3730ad07f78Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3740ad07f78Smrg# time-stamp-time-zone: "UTC"
3750ad07f78Smrg# time-stamp-end: "; # UTC"
3760ad07f78Smrg# End:
377