missing revision b3078add
15c10afb9Smrg#! /bin/sh
25c10afb9Smrg# Common stub for a few missing GNU programs while installing.
3b3078addSmrg
4b3078addSmrgscriptversion=2009-04-28.21; # UTC
5b3078addSmrg
6b3078addSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7b3078addSmrg# 2008, 2009 Free Software Foundation, Inc.
85c10afb9Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
95c10afb9Smrg
105c10afb9Smrg# This program is free software; you can redistribute it and/or modify
115c10afb9Smrg# it under the terms of the GNU General Public License as published by
125c10afb9Smrg# the Free Software Foundation; either version 2, or (at your option)
135c10afb9Smrg# any later version.
145c10afb9Smrg
155c10afb9Smrg# This program is distributed in the hope that it will be useful,
165c10afb9Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
175c10afb9Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
185c10afb9Smrg# GNU General Public License for more details.
195c10afb9Smrg
205c10afb9Smrg# You should have received a copy of the GNU General Public License
21b3078addSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
225c10afb9Smrg
235c10afb9Smrg# As a special exception to the GNU General Public License, if you
245c10afb9Smrg# distribute this file as part of a program that contains a
255c10afb9Smrg# configuration script generated by Autoconf, you may include it under
265c10afb9Smrg# the same distribution terms that you use for the rest of that program.
275c10afb9Smrg
285c10afb9Smrgif test $# -eq 0; then
295c10afb9Smrg  echo 1>&2 "Try \`$0 --help' for more information"
305c10afb9Smrg  exit 1
315c10afb9Smrgfi
325c10afb9Smrg
335c10afb9Smrgrun=:
34b3078addSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35b3078addSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
365c10afb9Smrg
375c10afb9Smrg# In the cases where this matters, `missing' is being run in the
385c10afb9Smrg# srcdir already.
395c10afb9Smrgif test -f configure.ac; then
405c10afb9Smrg  configure_ac=configure.ac
415c10afb9Smrgelse
425c10afb9Smrg  configure_ac=configure.in
435c10afb9Smrgfi
445c10afb9Smrg
45b3078addSmrgmsg="missing on your system"
46b3078addSmrg
47b3078addSmrgcase $1 in
485c10afb9Smrg--run)
495c10afb9Smrg  # Try to run requested program, and just exit if it succeeds.
505c10afb9Smrg  run=
515c10afb9Smrg  shift
525c10afb9Smrg  "$@" && exit 0
53b3078addSmrg  # Exit code 63 means version mismatch.  This often happens
54b3078addSmrg  # when the user try to use an ancient version of a tool on
55b3078addSmrg  # a file that requires a minimum version.  In this case we
56b3078addSmrg  # we should proceed has if the program had been absent, or
57b3078addSmrg  # if --run hadn't been passed.
58b3078addSmrg  if test $? = 63; then
59b3078addSmrg    run=:
60b3078addSmrg    msg="probably too old"
61b3078addSmrg  fi
625c10afb9Smrg  ;;
635c10afb9Smrg
645c10afb9Smrg  -h|--h|--he|--hel|--help)
655c10afb9Smrg    echo "\
665c10afb9Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
675c10afb9Smrg
685c10afb9SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
695c10afb9Smrgerror status if there is no known handling for PROGRAM.
705c10afb9Smrg
715c10afb9SmrgOptions:
725c10afb9Smrg  -h, --help      display this help and exit
735c10afb9Smrg  -v, --version   output version information and exit
745c10afb9Smrg  --run           try to run the given command, and emulate it if it fails
755c10afb9Smrg
765c10afb9SmrgSupported PROGRAM values:
775c10afb9Smrg  aclocal      touch file \`aclocal.m4'
785c10afb9Smrg  autoconf     touch file \`configure'
795c10afb9Smrg  autoheader   touch file \`config.h.in'
80b3078addSmrg  autom4te     touch the output file, or create a stub one
815c10afb9Smrg  automake     touch all \`Makefile.in' files
825c10afb9Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
835c10afb9Smrg  flex         create \`lex.yy.c', if possible, from existing .c
845c10afb9Smrg  help2man     touch the output file
855c10afb9Smrg  lex          create \`lex.yy.c', if possible, from existing .c
865c10afb9Smrg  makeinfo     touch the output file
875c10afb9Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
88b3078addSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
89b3078addSmrg
90b3078addSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91b3078addSmrg\`g' are ignored when checking the name.
92b3078addSmrg
93b3078addSmrgSend bug reports to <bug-automake@gnu.org>."
94b3078addSmrg    exit $?
955c10afb9Smrg    ;;
965c10afb9Smrg
975c10afb9Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
98b3078addSmrg    echo "missing $scriptversion (GNU Automake)"
99b3078addSmrg    exit $?
1005c10afb9Smrg    ;;
1015c10afb9Smrg
1025c10afb9Smrg  -*)
1035c10afb9Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1045c10afb9Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1055c10afb9Smrg    exit 1
1065c10afb9Smrg    ;;
1075c10afb9Smrg
108b3078addSmrgesac
109b3078addSmrg
110b3078addSmrg# normalize program name to check for.
111b3078addSmrgprogram=`echo "$1" | sed '
112b3078addSmrg  s/^gnu-//; t
113b3078addSmrg  s/^gnu//; t
114b3078addSmrg  s/^g//; t'`
115b3078addSmrg
116b3078addSmrg# Now exit if we have it, but it failed.  Also exit now if we
117b3078addSmrg# don't have it and --version was passed (most likely to detect
118b3078addSmrg# the program).  This is about non-GNU programs, so use $1 not
119b3078addSmrg# $program.
120b3078addSmrgcase $1 in
121b3078addSmrg  lex*|yacc*)
122b3078addSmrg    # Not GNU programs, they don't have --version.
123b3078addSmrg    ;;
124b3078addSmrg
125b3078addSmrg  tar*)
126b3078addSmrg    if test -n "$run"; then
127b3078addSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
128b3078addSmrg       exit 1
129b3078addSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
130b3078addSmrg       exit 1
131b3078addSmrg    fi
132b3078addSmrg    ;;
133b3078addSmrg
134b3078addSmrg  *)
1355c10afb9Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1365c10afb9Smrg       # We have it, but it failed.
1375c10afb9Smrg       exit 1
138b3078addSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
139b3078addSmrg       # Could not run --version or --help.  This is probably someone
140b3078addSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
141b3078addSmrg       # $TOOL exists and not knowing $TOOL uses missing.
142b3078addSmrg       exit 1
1435c10afb9Smrg    fi
144b3078addSmrg    ;;
145b3078addSmrgesac
1465c10afb9Smrg
147b3078addSmrg# If it does not exist, or fails to run (possibly an outdated version),
148b3078addSmrg# try to emulate it.
149b3078addSmrgcase $program in
150b3078addSmrg  aclocal*)
1515c10afb9Smrg    echo 1>&2 "\
152b3078addSmrgWARNING: \`$1' is $msg.  You should only need it if
1535c10afb9Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1545c10afb9Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1555c10afb9Smrg         any GNU archive site."
1565c10afb9Smrg    touch aclocal.m4
1575c10afb9Smrg    ;;
1585c10afb9Smrg
159b3078addSmrg  autoconf*)
1605c10afb9Smrg    echo 1>&2 "\
161b3078addSmrgWARNING: \`$1' is $msg.  You should only need it if
1625c10afb9Smrg         you modified \`${configure_ac}'.  You might want to install the
1635c10afb9Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1645c10afb9Smrg         archive site."
1655c10afb9Smrg    touch configure
1665c10afb9Smrg    ;;
1675c10afb9Smrg
168b3078addSmrg  autoheader*)
1695c10afb9Smrg    echo 1>&2 "\
170b3078addSmrgWARNING: \`$1' is $msg.  You should only need it if
1715c10afb9Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1725c10afb9Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1735c10afb9Smrg         from any GNU archive site."
1745c10afb9Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1755c10afb9Smrg    test -z "$files" && files="config.h"
1765c10afb9Smrg    touch_files=
1775c10afb9Smrg    for f in $files; do
178b3078addSmrg      case $f in
1795c10afb9Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1805c10afb9Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1815c10afb9Smrg      *) touch_files="$touch_files $f.in";;
1825c10afb9Smrg      esac
1835c10afb9Smrg    done
1845c10afb9Smrg    touch $touch_files
1855c10afb9Smrg    ;;
1865c10afb9Smrg
1875c10afb9Smrg  automake*)
1885c10afb9Smrg    echo 1>&2 "\
189b3078addSmrgWARNING: \`$1' is $msg.  You should only need it if
1905c10afb9Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1915c10afb9Smrg         You might want to install the \`Automake' and \`Perl' packages.
1925c10afb9Smrg         Grab them from any GNU archive site."
1935c10afb9Smrg    find . -type f -name Makefile.am -print |
1945c10afb9Smrg	   sed 's/\.am$/.in/' |
1955c10afb9Smrg	   while read f; do touch "$f"; done
1965c10afb9Smrg    ;;
1975c10afb9Smrg
198b3078addSmrg  autom4te*)
1995c10afb9Smrg    echo 1>&2 "\
200b3078addSmrgWARNING: \`$1' is needed, but is $msg.
201b3078addSmrg         You might have modified some files without having the
2025c10afb9Smrg         proper tools for further handling them.
2035c10afb9Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
2045c10afb9Smrg         archive site."
2055c10afb9Smrg
206b3078addSmrg    file=`echo "$*" | sed -n "$sed_output"`
207b3078addSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2085c10afb9Smrg    if test -f "$file"; then
2095c10afb9Smrg	touch $file
2105c10afb9Smrg    else
2115c10afb9Smrg	test -z "$file" || exec >$file
2125c10afb9Smrg	echo "#! /bin/sh"
2135c10afb9Smrg	echo "# Created by GNU Automake missing as a replacement of"
2145c10afb9Smrg	echo "#  $ $@"
2155c10afb9Smrg	echo "exit 0"
2165c10afb9Smrg	chmod +x $file
2175c10afb9Smrg	exit 1
2185c10afb9Smrg    fi
2195c10afb9Smrg    ;;
2205c10afb9Smrg
221b3078addSmrg  bison*|yacc*)
2225c10afb9Smrg    echo 1>&2 "\
223b3078addSmrgWARNING: \`$1' $msg.  You should only need it if
2245c10afb9Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2255c10afb9Smrg         in order for those modifications to take effect.  You can get
2265c10afb9Smrg         \`Bison' from any GNU archive site."
2275c10afb9Smrg    rm -f y.tab.c y.tab.h
228b3078addSmrg    if test $# -ne 1; then
2295c10afb9Smrg        eval LASTARG="\${$#}"
230b3078addSmrg	case $LASTARG in
2315c10afb9Smrg	*.y)
2325c10afb9Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
233b3078addSmrg	    if test -f "$SRCFILE"; then
2345c10afb9Smrg	         cp "$SRCFILE" y.tab.c
2355c10afb9Smrg	    fi
2365c10afb9Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
237b3078addSmrg	    if test -f "$SRCFILE"; then
2385c10afb9Smrg	         cp "$SRCFILE" y.tab.h
2395c10afb9Smrg	    fi
2405c10afb9Smrg	  ;;
2415c10afb9Smrg	esac
2425c10afb9Smrg    fi
243b3078addSmrg    if test ! -f y.tab.h; then
2445c10afb9Smrg	echo >y.tab.h
2455c10afb9Smrg    fi
246b3078addSmrg    if test ! -f y.tab.c; then
2475c10afb9Smrg	echo 'main() { return 0; }' >y.tab.c
2485c10afb9Smrg    fi
2495c10afb9Smrg    ;;
2505c10afb9Smrg
251b3078addSmrg  lex*|flex*)
2525c10afb9Smrg    echo 1>&2 "\
253b3078addSmrgWARNING: \`$1' is $msg.  You should only need it if
2545c10afb9Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2555c10afb9Smrg         in order for those modifications to take effect.  You can get
2565c10afb9Smrg         \`Flex' from any GNU archive site."
2575c10afb9Smrg    rm -f lex.yy.c
258b3078addSmrg    if test $# -ne 1; then
2595c10afb9Smrg        eval LASTARG="\${$#}"
260b3078addSmrg	case $LASTARG in
2615c10afb9Smrg	*.l)
2625c10afb9Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
263b3078addSmrg	    if test -f "$SRCFILE"; then
2645c10afb9Smrg	         cp "$SRCFILE" lex.yy.c
2655c10afb9Smrg	    fi
2665c10afb9Smrg	  ;;
2675c10afb9Smrg	esac
2685c10afb9Smrg    fi
269b3078addSmrg    if test ! -f lex.yy.c; then
2705c10afb9Smrg	echo 'main() { return 0; }' >lex.yy.c
2715c10afb9Smrg    fi
2725c10afb9Smrg    ;;
2735c10afb9Smrg
274b3078addSmrg  help2man*)
2755c10afb9Smrg    echo 1>&2 "\
276b3078addSmrgWARNING: \`$1' is $msg.  You should only need it if
2775c10afb9Smrg	 you modified a dependency of a manual page.  You may need the
2785c10afb9Smrg	 \`Help2man' package in order for those modifications to take
2795c10afb9Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2805c10afb9Smrg
281b3078addSmrg    file=`echo "$*" | sed -n "$sed_output"`
282b3078addSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
283b3078addSmrg    if test -f "$file"; then
2845c10afb9Smrg	touch $file
2855c10afb9Smrg    else
2865c10afb9Smrg	test -z "$file" || exec >$file
2875c10afb9Smrg	echo ".ab help2man is required to generate this page"
288b3078addSmrg	exit $?
2895c10afb9Smrg    fi
2905c10afb9Smrg    ;;
2915c10afb9Smrg
292b3078addSmrg  makeinfo*)
2935c10afb9Smrg    echo 1>&2 "\
294b3078addSmrgWARNING: \`$1' is $msg.  You should only need it if
2955c10afb9Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2965c10afb9Smrg         indirectly affecting the aspect of the manual.  The spurious
2975c10afb9Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2985c10afb9Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2995c10afb9Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
300b3078addSmrg    # The file to touch is that specified with -o ...
301b3078addSmrg    file=`echo "$*" | sed -n "$sed_output"`
302b3078addSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
3035c10afb9Smrg    if test -z "$file"; then
304b3078addSmrg      # ... or it is the one specified with @setfilename ...
305b3078addSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
306b3078addSmrg      file=`sed -n '
307b3078addSmrg	/^@setfilename/{
308b3078addSmrg	  s/.* \([^ ]*\) *$/\1/
309b3078addSmrg	  p
310b3078addSmrg	  q
311b3078addSmrg	}' $infile`
312b3078addSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
313b3078addSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3145c10afb9Smrg    fi
315b3078addSmrg    # If the file does not exist, the user really needs makeinfo;
316b3078addSmrg    # let's fail without touching anything.
317b3078addSmrg    test -f $file || exit 1
3185c10afb9Smrg    touch $file
3195c10afb9Smrg    ;;
3205c10afb9Smrg
321b3078addSmrg  tar*)
3225c10afb9Smrg    shift
3235c10afb9Smrg
3245c10afb9Smrg    # We have already tried tar in the generic part.
3255c10afb9Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3265c10afb9Smrg    # messages.
3275c10afb9Smrg    if (gnutar --version > /dev/null 2>&1); then
3285c10afb9Smrg       gnutar "$@" && exit 0
3295c10afb9Smrg    fi
3305c10afb9Smrg    if (gtar --version > /dev/null 2>&1); then
3315c10afb9Smrg       gtar "$@" && exit 0
3325c10afb9Smrg    fi
3335c10afb9Smrg    firstarg="$1"
3345c10afb9Smrg    if shift; then
335b3078addSmrg	case $firstarg in
3365c10afb9Smrg	*o*)
3375c10afb9Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3385c10afb9Smrg	    tar "$firstarg" "$@" && exit 0
3395c10afb9Smrg	    ;;
3405c10afb9Smrg	esac
341b3078addSmrg	case $firstarg in
3425c10afb9Smrg	*h*)
3435c10afb9Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3445c10afb9Smrg	    tar "$firstarg" "$@" && exit 0
3455c10afb9Smrg	    ;;
3465c10afb9Smrg	esac
3475c10afb9Smrg    fi
3485c10afb9Smrg
3495c10afb9Smrg    echo 1>&2 "\
3505c10afb9SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3515c10afb9Smrg         You may want to install GNU tar or Free paxutils, or check the
3525c10afb9Smrg         command line arguments."
3535c10afb9Smrg    exit 1
3545c10afb9Smrg    ;;
3555c10afb9Smrg
3565c10afb9Smrg  *)
3575c10afb9Smrg    echo 1>&2 "\
358b3078addSmrgWARNING: \`$1' is needed, and is $msg.
359b3078addSmrg         You might have modified some files without having the
3605c10afb9Smrg         proper tools for further handling them.  Check the \`README' file,
3615c10afb9Smrg         it often tells you about the needed prerequisites for installing
3625c10afb9Smrg         this package.  You may also peek at any GNU archive site, in case
3635c10afb9Smrg         some other package would contain this missing \`$1' program."
3645c10afb9Smrg    exit 1
3655c10afb9Smrg    ;;
3665c10afb9Smrgesac
3675c10afb9Smrg
3685c10afb9Smrgexit 0
369b3078addSmrg
370b3078addSmrg# Local variables:
371b3078addSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
372b3078addSmrg# time-stamp-start: "scriptversion="
373b3078addSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374b3078addSmrg# time-stamp-time-zone: "UTC"
375b3078addSmrg# time-stamp-end: "; # UTC"
376b3078addSmrg# End:
377