missing revision ef7198c0
156f6b22bSmrg#! /bin/sh
256f6b22bSmrg# Common stub for a few missing GNU programs while installing.
3ef7198c0Smrg
4ef7198c0Smrgscriptversion=2009-04-28.21; # UTC
5ef7198c0Smrg
6ef7198c0Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7ef7198c0Smrg# 2008, 2009 Free Software Foundation, Inc.
856f6b22bSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
956f6b22bSmrg
1056f6b22bSmrg# This program is free software; you can redistribute it and/or modify
1156f6b22bSmrg# it under the terms of the GNU General Public License as published by
1256f6b22bSmrg# the Free Software Foundation; either version 2, or (at your option)
1356f6b22bSmrg# any later version.
1456f6b22bSmrg
1556f6b22bSmrg# This program is distributed in the hope that it will be useful,
1656f6b22bSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1756f6b22bSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1856f6b22bSmrg# GNU General Public License for more details.
1956f6b22bSmrg
2056f6b22bSmrg# You should have received a copy of the GNU General Public License
21ef7198c0Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2256f6b22bSmrg
2356f6b22bSmrg# As a special exception to the GNU General Public License, if you
2456f6b22bSmrg# distribute this file as part of a program that contains a
2556f6b22bSmrg# configuration script generated by Autoconf, you may include it under
2656f6b22bSmrg# the same distribution terms that you use for the rest of that program.
2756f6b22bSmrg
2856f6b22bSmrgif test $# -eq 0; then
2956f6b22bSmrg  echo 1>&2 "Try \`$0 --help' for more information"
3056f6b22bSmrg  exit 1
3156f6b22bSmrgfi
3256f6b22bSmrg
3356f6b22bSmrgrun=:
34ef7198c0Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35ef7198c0Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3656f6b22bSmrg
3756f6b22bSmrg# In the cases where this matters, `missing' is being run in the
3856f6b22bSmrg# srcdir already.
3956f6b22bSmrgif test -f configure.ac; then
4056f6b22bSmrg  configure_ac=configure.ac
4156f6b22bSmrgelse
4256f6b22bSmrg  configure_ac=configure.in
4356f6b22bSmrgfi
4456f6b22bSmrg
45ef7198c0Smrgmsg="missing on your system"
46ef7198c0Smrg
47ef7198c0Smrgcase $1 in
4856f6b22bSmrg--run)
4956f6b22bSmrg  # Try to run requested program, and just exit if it succeeds.
5056f6b22bSmrg  run=
5156f6b22bSmrg  shift
5256f6b22bSmrg  "$@" && exit 0
53ef7198c0Smrg  # Exit code 63 means version mismatch.  This often happens
54ef7198c0Smrg  # when the user try to use an ancient version of a tool on
55ef7198c0Smrg  # a file that requires a minimum version.  In this case we
56ef7198c0Smrg  # we should proceed has if the program had been absent, or
57ef7198c0Smrg  # if --run hadn't been passed.
58ef7198c0Smrg  if test $? = 63; then
59ef7198c0Smrg    run=:
60ef7198c0Smrg    msg="probably too old"
61ef7198c0Smrg  fi
6256f6b22bSmrg  ;;
6356f6b22bSmrg
6456f6b22bSmrg  -h|--h|--he|--hel|--help)
6556f6b22bSmrg    echo "\
6656f6b22bSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6756f6b22bSmrg
6856f6b22bSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6956f6b22bSmrgerror status if there is no known handling for PROGRAM.
7056f6b22bSmrg
7156f6b22bSmrgOptions:
7256f6b22bSmrg  -h, --help      display this help and exit
7356f6b22bSmrg  -v, --version   output version information and exit
7456f6b22bSmrg  --run           try to run the given command, and emulate it if it fails
7556f6b22bSmrg
7656f6b22bSmrgSupported PROGRAM values:
7756f6b22bSmrg  aclocal      touch file \`aclocal.m4'
7856f6b22bSmrg  autoconf     touch file \`configure'
7956f6b22bSmrg  autoheader   touch file \`config.h.in'
80ef7198c0Smrg  autom4te     touch the output file, or create a stub one
8156f6b22bSmrg  automake     touch all \`Makefile.in' files
8256f6b22bSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8356f6b22bSmrg  flex         create \`lex.yy.c', if possible, from existing .c
8456f6b22bSmrg  help2man     touch the output file
8556f6b22bSmrg  lex          create \`lex.yy.c', if possible, from existing .c
8656f6b22bSmrg  makeinfo     touch the output file
8756f6b22bSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
88ef7198c0Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
89ef7198c0Smrg
90ef7198c0SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91ef7198c0Smrg\`g' are ignored when checking the name.
92ef7198c0Smrg
93ef7198c0SmrgSend bug reports to <bug-automake@gnu.org>."
94ef7198c0Smrg    exit $?
9556f6b22bSmrg    ;;
9656f6b22bSmrg
9756f6b22bSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
98ef7198c0Smrg    echo "missing $scriptversion (GNU Automake)"
99ef7198c0Smrg    exit $?
10056f6b22bSmrg    ;;
10156f6b22bSmrg
10256f6b22bSmrg  -*)
10356f6b22bSmrg    echo 1>&2 "$0: Unknown \`$1' option"
10456f6b22bSmrg    echo 1>&2 "Try \`$0 --help' for more information"
10556f6b22bSmrg    exit 1
10656f6b22bSmrg    ;;
10756f6b22bSmrg
108ef7198c0Smrgesac
109ef7198c0Smrg
110ef7198c0Smrg# normalize program name to check for.
111ef7198c0Smrgprogram=`echo "$1" | sed '
112ef7198c0Smrg  s/^gnu-//; t
113ef7198c0Smrg  s/^gnu//; t
114ef7198c0Smrg  s/^g//; t'`
115ef7198c0Smrg
116ef7198c0Smrg# Now exit if we have it, but it failed.  Also exit now if we
117ef7198c0Smrg# don't have it and --version was passed (most likely to detect
118ef7198c0Smrg# the program).  This is about non-GNU programs, so use $1 not
119ef7198c0Smrg# $program.
120ef7198c0Smrgcase $1 in
121ef7198c0Smrg  lex*|yacc*)
122ef7198c0Smrg    # Not GNU programs, they don't have --version.
123ef7198c0Smrg    ;;
124ef7198c0Smrg
125ef7198c0Smrg  tar*)
126ef7198c0Smrg    if test -n "$run"; then
127ef7198c0Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
128ef7198c0Smrg       exit 1
129ef7198c0Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
130ef7198c0Smrg       exit 1
131ef7198c0Smrg    fi
132ef7198c0Smrg    ;;
133ef7198c0Smrg
134ef7198c0Smrg  *)
13556f6b22bSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
13656f6b22bSmrg       # We have it, but it failed.
13756f6b22bSmrg       exit 1
138ef7198c0Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
139ef7198c0Smrg       # Could not run --version or --help.  This is probably someone
140ef7198c0Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
141ef7198c0Smrg       # $TOOL exists and not knowing $TOOL uses missing.
142ef7198c0Smrg       exit 1
14356f6b22bSmrg    fi
144ef7198c0Smrg    ;;
145ef7198c0Smrgesac
14656f6b22bSmrg
147ef7198c0Smrg# If it does not exist, or fails to run (possibly an outdated version),
148ef7198c0Smrg# try to emulate it.
149ef7198c0Smrgcase $program in
150ef7198c0Smrg  aclocal*)
15156f6b22bSmrg    echo 1>&2 "\
152ef7198c0SmrgWARNING: \`$1' is $msg.  You should only need it if
15356f6b22bSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
15456f6b22bSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
15556f6b22bSmrg         any GNU archive site."
15656f6b22bSmrg    touch aclocal.m4
15756f6b22bSmrg    ;;
15856f6b22bSmrg
159ef7198c0Smrg  autoconf*)
16056f6b22bSmrg    echo 1>&2 "\
161ef7198c0SmrgWARNING: \`$1' is $msg.  You should only need it if
16256f6b22bSmrg         you modified \`${configure_ac}'.  You might want to install the
16356f6b22bSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
16456f6b22bSmrg         archive site."
16556f6b22bSmrg    touch configure
16656f6b22bSmrg    ;;
16756f6b22bSmrg
168ef7198c0Smrg  autoheader*)
16956f6b22bSmrg    echo 1>&2 "\
170ef7198c0SmrgWARNING: \`$1' is $msg.  You should only need it if
17156f6b22bSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
17256f6b22bSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
17356f6b22bSmrg         from any GNU archive site."
17456f6b22bSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
17556f6b22bSmrg    test -z "$files" && files="config.h"
17656f6b22bSmrg    touch_files=
17756f6b22bSmrg    for f in $files; do
178ef7198c0Smrg      case $f in
17956f6b22bSmrg      *:*) touch_files="$touch_files "`echo "$f" |
18056f6b22bSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
18156f6b22bSmrg      *) touch_files="$touch_files $f.in";;
18256f6b22bSmrg      esac
18356f6b22bSmrg    done
18456f6b22bSmrg    touch $touch_files
18556f6b22bSmrg    ;;
18656f6b22bSmrg
18756f6b22bSmrg  automake*)
18856f6b22bSmrg    echo 1>&2 "\
189ef7198c0SmrgWARNING: \`$1' is $msg.  You should only need it if
19056f6b22bSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
19156f6b22bSmrg         You might want to install the \`Automake' and \`Perl' packages.
19256f6b22bSmrg         Grab them from any GNU archive site."
19356f6b22bSmrg    find . -type f -name Makefile.am -print |
19456f6b22bSmrg	   sed 's/\.am$/.in/' |
19556f6b22bSmrg	   while read f; do touch "$f"; done
19656f6b22bSmrg    ;;
19756f6b22bSmrg
198ef7198c0Smrg  autom4te*)
19956f6b22bSmrg    echo 1>&2 "\
200ef7198c0SmrgWARNING: \`$1' is needed, but is $msg.
201ef7198c0Smrg         You might have modified some files without having the
20256f6b22bSmrg         proper tools for further handling them.
20356f6b22bSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
20456f6b22bSmrg         archive site."
20556f6b22bSmrg
206ef7198c0Smrg    file=`echo "$*" | sed -n "$sed_output"`
207ef7198c0Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20856f6b22bSmrg    if test -f "$file"; then
20956f6b22bSmrg	touch $file
21056f6b22bSmrg    else
21156f6b22bSmrg	test -z "$file" || exec >$file
21256f6b22bSmrg	echo "#! /bin/sh"
21356f6b22bSmrg	echo "# Created by GNU Automake missing as a replacement of"
21456f6b22bSmrg	echo "#  $ $@"
21556f6b22bSmrg	echo "exit 0"
21656f6b22bSmrg	chmod +x $file
21756f6b22bSmrg	exit 1
21856f6b22bSmrg    fi
21956f6b22bSmrg    ;;
22056f6b22bSmrg
221ef7198c0Smrg  bison*|yacc*)
22256f6b22bSmrg    echo 1>&2 "\
223ef7198c0SmrgWARNING: \`$1' $msg.  You should only need it if
22456f6b22bSmrg         you modified a \`.y' file.  You may need the \`Bison' package
22556f6b22bSmrg         in order for those modifications to take effect.  You can get
22656f6b22bSmrg         \`Bison' from any GNU archive site."
22756f6b22bSmrg    rm -f y.tab.c y.tab.h
228ef7198c0Smrg    if test $# -ne 1; then
22956f6b22bSmrg        eval LASTARG="\${$#}"
230ef7198c0Smrg	case $LASTARG in
23156f6b22bSmrg	*.y)
23256f6b22bSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
233ef7198c0Smrg	    if test -f "$SRCFILE"; then
23456f6b22bSmrg	         cp "$SRCFILE" y.tab.c
23556f6b22bSmrg	    fi
23656f6b22bSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
237ef7198c0Smrg	    if test -f "$SRCFILE"; then
23856f6b22bSmrg	         cp "$SRCFILE" y.tab.h
23956f6b22bSmrg	    fi
24056f6b22bSmrg	  ;;
24156f6b22bSmrg	esac
24256f6b22bSmrg    fi
243ef7198c0Smrg    if test ! -f y.tab.h; then
24456f6b22bSmrg	echo >y.tab.h
24556f6b22bSmrg    fi
246ef7198c0Smrg    if test ! -f y.tab.c; then
24756f6b22bSmrg	echo 'main() { return 0; }' >y.tab.c
24856f6b22bSmrg    fi
24956f6b22bSmrg    ;;
25056f6b22bSmrg
251ef7198c0Smrg  lex*|flex*)
25256f6b22bSmrg    echo 1>&2 "\
253ef7198c0SmrgWARNING: \`$1' is $msg.  You should only need it if
25456f6b22bSmrg         you modified a \`.l' file.  You may need the \`Flex' package
25556f6b22bSmrg         in order for those modifications to take effect.  You can get
25656f6b22bSmrg         \`Flex' from any GNU archive site."
25756f6b22bSmrg    rm -f lex.yy.c
258ef7198c0Smrg    if test $# -ne 1; then
25956f6b22bSmrg        eval LASTARG="\${$#}"
260ef7198c0Smrg	case $LASTARG in
26156f6b22bSmrg	*.l)
26256f6b22bSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
263ef7198c0Smrg	    if test -f "$SRCFILE"; then
26456f6b22bSmrg	         cp "$SRCFILE" lex.yy.c
26556f6b22bSmrg	    fi
26656f6b22bSmrg	  ;;
26756f6b22bSmrg	esac
26856f6b22bSmrg    fi
269ef7198c0Smrg    if test ! -f lex.yy.c; then
27056f6b22bSmrg	echo 'main() { return 0; }' >lex.yy.c
27156f6b22bSmrg    fi
27256f6b22bSmrg    ;;
27356f6b22bSmrg
274ef7198c0Smrg  help2man*)
27556f6b22bSmrg    echo 1>&2 "\
276ef7198c0SmrgWARNING: \`$1' is $msg.  You should only need it if
27756f6b22bSmrg	 you modified a dependency of a manual page.  You may need the
27856f6b22bSmrg	 \`Help2man' package in order for those modifications to take
27956f6b22bSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
28056f6b22bSmrg
281ef7198c0Smrg    file=`echo "$*" | sed -n "$sed_output"`
282ef7198c0Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
283ef7198c0Smrg    if test -f "$file"; then
28456f6b22bSmrg	touch $file
28556f6b22bSmrg    else
28656f6b22bSmrg	test -z "$file" || exec >$file
28756f6b22bSmrg	echo ".ab help2man is required to generate this page"
288ef7198c0Smrg	exit $?
28956f6b22bSmrg    fi
29056f6b22bSmrg    ;;
29156f6b22bSmrg
292ef7198c0Smrg  makeinfo*)
29356f6b22bSmrg    echo 1>&2 "\
294ef7198c0SmrgWARNING: \`$1' is $msg.  You should only need it if
29556f6b22bSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
29656f6b22bSmrg         indirectly affecting the aspect of the manual.  The spurious
29756f6b22bSmrg         call might also be the consequence of using a buggy \`make' (AIX,
29856f6b22bSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29956f6b22bSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
300ef7198c0Smrg    # The file to touch is that specified with -o ...
301ef7198c0Smrg    file=`echo "$*" | sed -n "$sed_output"`
302ef7198c0Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
30356f6b22bSmrg    if test -z "$file"; then
304ef7198c0Smrg      # ... or it is the one specified with @setfilename ...
305ef7198c0Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
306ef7198c0Smrg      file=`sed -n '
307ef7198c0Smrg	/^@setfilename/{
308ef7198c0Smrg	  s/.* \([^ ]*\) *$/\1/
309ef7198c0Smrg	  p
310ef7198c0Smrg	  q
311ef7198c0Smrg	}' $infile`
312ef7198c0Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
313ef7198c0Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
31456f6b22bSmrg    fi
315ef7198c0Smrg    # If the file does not exist, the user really needs makeinfo;
316ef7198c0Smrg    # let's fail without touching anything.
317ef7198c0Smrg    test -f $file || exit 1
31856f6b22bSmrg    touch $file
31956f6b22bSmrg    ;;
32056f6b22bSmrg
321ef7198c0Smrg  tar*)
32256f6b22bSmrg    shift
32356f6b22bSmrg
32456f6b22bSmrg    # We have already tried tar in the generic part.
32556f6b22bSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
32656f6b22bSmrg    # messages.
32756f6b22bSmrg    if (gnutar --version > /dev/null 2>&1); then
32856f6b22bSmrg       gnutar "$@" && exit 0
32956f6b22bSmrg    fi
33056f6b22bSmrg    if (gtar --version > /dev/null 2>&1); then
33156f6b22bSmrg       gtar "$@" && exit 0
33256f6b22bSmrg    fi
33356f6b22bSmrg    firstarg="$1"
33456f6b22bSmrg    if shift; then
335ef7198c0Smrg	case $firstarg in
33656f6b22bSmrg	*o*)
33756f6b22bSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
33856f6b22bSmrg	    tar "$firstarg" "$@" && exit 0
33956f6b22bSmrg	    ;;
34056f6b22bSmrg	esac
341ef7198c0Smrg	case $firstarg in
34256f6b22bSmrg	*h*)
34356f6b22bSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
34456f6b22bSmrg	    tar "$firstarg" "$@" && exit 0
34556f6b22bSmrg	    ;;
34656f6b22bSmrg	esac
34756f6b22bSmrg    fi
34856f6b22bSmrg
34956f6b22bSmrg    echo 1>&2 "\
35056f6b22bSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
35156f6b22bSmrg         You may want to install GNU tar or Free paxutils, or check the
35256f6b22bSmrg         command line arguments."
35356f6b22bSmrg    exit 1
35456f6b22bSmrg    ;;
35556f6b22bSmrg
35656f6b22bSmrg  *)
35756f6b22bSmrg    echo 1>&2 "\
358ef7198c0SmrgWARNING: \`$1' is needed, and is $msg.
359ef7198c0Smrg         You might have modified some files without having the
36056f6b22bSmrg         proper tools for further handling them.  Check the \`README' file,
36156f6b22bSmrg         it often tells you about the needed prerequisites for installing
36256f6b22bSmrg         this package.  You may also peek at any GNU archive site, in case
36356f6b22bSmrg         some other package would contain this missing \`$1' program."
36456f6b22bSmrg    exit 1
36556f6b22bSmrg    ;;
36656f6b22bSmrgesac
36756f6b22bSmrg
36856f6b22bSmrgexit 0
369ef7198c0Smrg
370ef7198c0Smrg# Local variables:
371ef7198c0Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
372ef7198c0Smrg# time-stamp-start: "scriptversion="
373ef7198c0Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374ef7198c0Smrg# time-stamp-time-zone: "UTC"
375ef7198c0Smrg# time-stamp-end: "; # UTC"
376ef7198c0Smrg# End:
377