missing revision e1e1713c
17a84e134Smrg#! /bin/sh
27a84e134Smrg# Common stub for a few missing GNU programs while installing.
37a84e134Smrg
4e1e1713cSmrgscriptversion=2009-04-28.21; # UTC
57a84e134Smrg
6e1e1713cSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7e1e1713cSmrg# 2008, 2009 Free Software Foundation, Inc.
87a84e134Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
97a84e134Smrg
107a84e134Smrg# This program is free software; you can redistribute it and/or modify
117a84e134Smrg# it under the terms of the GNU General Public License as published by
127a84e134Smrg# the Free Software Foundation; either version 2, or (at your option)
137a84e134Smrg# any later version.
147a84e134Smrg
157a84e134Smrg# This program is distributed in the hope that it will be useful,
167a84e134Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
177a84e134Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
187a84e134Smrg# GNU General Public License for more details.
197a84e134Smrg
207a84e134Smrg# You should have received a copy of the GNU General Public License
21e1e1713cSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
227a84e134Smrg
237a84e134Smrg# As a special exception to the GNU General Public License, if you
247a84e134Smrg# distribute this file as part of a program that contains a
257a84e134Smrg# configuration script generated by Autoconf, you may include it under
267a84e134Smrg# the same distribution terms that you use for the rest of that program.
277a84e134Smrg
287a84e134Smrgif test $# -eq 0; then
297a84e134Smrg  echo 1>&2 "Try \`$0 --help' for more information"
307a84e134Smrg  exit 1
317a84e134Smrgfi
327a84e134Smrg
337a84e134Smrgrun=:
347a84e134Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
357a84e134Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
367a84e134Smrg
377a84e134Smrg# In the cases where this matters, `missing' is being run in the
387a84e134Smrg# srcdir already.
397a84e134Smrgif test -f configure.ac; then
407a84e134Smrg  configure_ac=configure.ac
417a84e134Smrgelse
427a84e134Smrg  configure_ac=configure.in
437a84e134Smrgfi
447a84e134Smrg
457a84e134Smrgmsg="missing on your system"
467a84e134Smrg
477a84e134Smrgcase $1 in
487a84e134Smrg--run)
497a84e134Smrg  # Try to run requested program, and just exit if it succeeds.
507a84e134Smrg  run=
517a84e134Smrg  shift
527a84e134Smrg  "$@" && exit 0
537a84e134Smrg  # Exit code 63 means version mismatch.  This often happens
547a84e134Smrg  # when the user try to use an ancient version of a tool on
557a84e134Smrg  # a file that requires a minimum version.  In this case we
567a84e134Smrg  # we should proceed has if the program had been absent, or
577a84e134Smrg  # if --run hadn't been passed.
587a84e134Smrg  if test $? = 63; then
597a84e134Smrg    run=:
607a84e134Smrg    msg="probably too old"
617a84e134Smrg  fi
627a84e134Smrg  ;;
637a84e134Smrg
647a84e134Smrg  -h|--h|--he|--hel|--help)
657a84e134Smrg    echo "\
667a84e134Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
677a84e134Smrg
687a84e134SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
697a84e134Smrgerror status if there is no known handling for PROGRAM.
707a84e134Smrg
717a84e134SmrgOptions:
727a84e134Smrg  -h, --help      display this help and exit
737a84e134Smrg  -v, --version   output version information and exit
747a84e134Smrg  --run           try to run the given command, and emulate it if it fails
757a84e134Smrg
767a84e134SmrgSupported PROGRAM values:
777a84e134Smrg  aclocal      touch file \`aclocal.m4'
787a84e134Smrg  autoconf     touch file \`configure'
797a84e134Smrg  autoheader   touch file \`config.h.in'
807a84e134Smrg  autom4te     touch the output file, or create a stub one
817a84e134Smrg  automake     touch all \`Makefile.in' files
827a84e134Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
837a84e134Smrg  flex         create \`lex.yy.c', if possible, from existing .c
847a84e134Smrg  help2man     touch the output file
857a84e134Smrg  lex          create \`lex.yy.c', if possible, from existing .c
867a84e134Smrg  makeinfo     touch the output file
877a84e134Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
887a84e134Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
897a84e134Smrg
90e1e1713cSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91e1e1713cSmrg\`g' are ignored when checking the name.
92e1e1713cSmrg
937a84e134SmrgSend bug reports to <bug-automake@gnu.org>."
947a84e134Smrg    exit $?
957a84e134Smrg    ;;
967a84e134Smrg
977a84e134Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
987a84e134Smrg    echo "missing $scriptversion (GNU Automake)"
997a84e134Smrg    exit $?
1007a84e134Smrg    ;;
1017a84e134Smrg
1027a84e134Smrg  -*)
1037a84e134Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1047a84e134Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1057a84e134Smrg    exit 1
1067a84e134Smrg    ;;
1077a84e134Smrg
1087a84e134Smrgesac
1097a84e134Smrg
110e1e1713cSmrg# normalize program name to check for.
111e1e1713cSmrgprogram=`echo "$1" | sed '
112e1e1713cSmrg  s/^gnu-//; t
113e1e1713cSmrg  s/^gnu//; t
114e1e1713cSmrg  s/^g//; t'`
115e1e1713cSmrg
1167a84e134Smrg# Now exit if we have it, but it failed.  Also exit now if we
1177a84e134Smrg# don't have it and --version was passed (most likely to detect
118e1e1713cSmrg# the program).  This is about non-GNU programs, so use $1 not
119e1e1713cSmrg# $program.
1207a84e134Smrgcase $1 in
121e1e1713cSmrg  lex*|yacc*)
1227a84e134Smrg    # Not GNU programs, they don't have --version.
1237a84e134Smrg    ;;
1247a84e134Smrg
125e1e1713cSmrg  tar*)
1267a84e134Smrg    if test -n "$run"; then
1277a84e134Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1287a84e134Smrg       exit 1
1297a84e134Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1307a84e134Smrg       exit 1
1317a84e134Smrg    fi
1327a84e134Smrg    ;;
1337a84e134Smrg
1347a84e134Smrg  *)
1357a84e134Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1367a84e134Smrg       # We have it, but it failed.
1377a84e134Smrg       exit 1
1387a84e134Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1397a84e134Smrg       # Could not run --version or --help.  This is probably someone
1407a84e134Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1417a84e134Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1427a84e134Smrg       exit 1
1437a84e134Smrg    fi
1447a84e134Smrg    ;;
1457a84e134Smrgesac
1467a84e134Smrg
1477a84e134Smrg# If it does not exist, or fails to run (possibly an outdated version),
1487a84e134Smrg# try to emulate it.
149e1e1713cSmrgcase $program in
1507a84e134Smrg  aclocal*)
1517a84e134Smrg    echo 1>&2 "\
1527a84e134SmrgWARNING: \`$1' is $msg.  You should only need it if
1537a84e134Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1547a84e134Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1557a84e134Smrg         any GNU archive site."
1567a84e134Smrg    touch aclocal.m4
1577a84e134Smrg    ;;
1587a84e134Smrg
159e1e1713cSmrg  autoconf*)
1607a84e134Smrg    echo 1>&2 "\
1617a84e134SmrgWARNING: \`$1' is $msg.  You should only need it if
1627a84e134Smrg         you modified \`${configure_ac}'.  You might want to install the
1637a84e134Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1647a84e134Smrg         archive site."
1657a84e134Smrg    touch configure
1667a84e134Smrg    ;;
1677a84e134Smrg
168e1e1713cSmrg  autoheader*)
1697a84e134Smrg    echo 1>&2 "\
1707a84e134SmrgWARNING: \`$1' is $msg.  You should only need it if
1717a84e134Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1727a84e134Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1737a84e134Smrg         from any GNU archive site."
1747a84e134Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1757a84e134Smrg    test -z "$files" && files="config.h"
1767a84e134Smrg    touch_files=
1777a84e134Smrg    for f in $files; do
1787a84e134Smrg      case $f in
1797a84e134Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1807a84e134Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1817a84e134Smrg      *) touch_files="$touch_files $f.in";;
1827a84e134Smrg      esac
1837a84e134Smrg    done
1847a84e134Smrg    touch $touch_files
1857a84e134Smrg    ;;
1867a84e134Smrg
1877a84e134Smrg  automake*)
1887a84e134Smrg    echo 1>&2 "\
1897a84e134SmrgWARNING: \`$1' is $msg.  You should only need it if
1907a84e134Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1917a84e134Smrg         You might want to install the \`Automake' and \`Perl' packages.
1927a84e134Smrg         Grab them from any GNU archive site."
1937a84e134Smrg    find . -type f -name Makefile.am -print |
1947a84e134Smrg	   sed 's/\.am$/.in/' |
1957a84e134Smrg	   while read f; do touch "$f"; done
1967a84e134Smrg    ;;
1977a84e134Smrg
198e1e1713cSmrg  autom4te*)
1997a84e134Smrg    echo 1>&2 "\
2007a84e134SmrgWARNING: \`$1' is needed, but is $msg.
2017a84e134Smrg         You might have modified some files without having the
2027a84e134Smrg         proper tools for further handling them.
2037a84e134Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
2047a84e134Smrg         archive site."
2057a84e134Smrg
2067a84e134Smrg    file=`echo "$*" | sed -n "$sed_output"`
2077a84e134Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2087a84e134Smrg    if test -f "$file"; then
2097a84e134Smrg	touch $file
2107a84e134Smrg    else
2117a84e134Smrg	test -z "$file" || exec >$file
2127a84e134Smrg	echo "#! /bin/sh"
2137a84e134Smrg	echo "# Created by GNU Automake missing as a replacement of"
2147a84e134Smrg	echo "#  $ $@"
2157a84e134Smrg	echo "exit 0"
2167a84e134Smrg	chmod +x $file
2177a84e134Smrg	exit 1
2187a84e134Smrg    fi
2197a84e134Smrg    ;;
2207a84e134Smrg
221e1e1713cSmrg  bison*|yacc*)
2227a84e134Smrg    echo 1>&2 "\
2237a84e134SmrgWARNING: \`$1' $msg.  You should only need it if
2247a84e134Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2257a84e134Smrg         in order for those modifications to take effect.  You can get
2267a84e134Smrg         \`Bison' from any GNU archive site."
2277a84e134Smrg    rm -f y.tab.c y.tab.h
2287a84e134Smrg    if test $# -ne 1; then
2297a84e134Smrg        eval LASTARG="\${$#}"
2307a84e134Smrg	case $LASTARG in
2317a84e134Smrg	*.y)
2327a84e134Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2337a84e134Smrg	    if test -f "$SRCFILE"; then
2347a84e134Smrg	         cp "$SRCFILE" y.tab.c
2357a84e134Smrg	    fi
2367a84e134Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2377a84e134Smrg	    if test -f "$SRCFILE"; then
2387a84e134Smrg	         cp "$SRCFILE" y.tab.h
2397a84e134Smrg	    fi
2407a84e134Smrg	  ;;
2417a84e134Smrg	esac
2427a84e134Smrg    fi
2437a84e134Smrg    if test ! -f y.tab.h; then
2447a84e134Smrg	echo >y.tab.h
2457a84e134Smrg    fi
2467a84e134Smrg    if test ! -f y.tab.c; then
2477a84e134Smrg	echo 'main() { return 0; }' >y.tab.c
2487a84e134Smrg    fi
2497a84e134Smrg    ;;
2507a84e134Smrg
251e1e1713cSmrg  lex*|flex*)
2527a84e134Smrg    echo 1>&2 "\
2537a84e134SmrgWARNING: \`$1' is $msg.  You should only need it if
2547a84e134Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2557a84e134Smrg         in order for those modifications to take effect.  You can get
2567a84e134Smrg         \`Flex' from any GNU archive site."
2577a84e134Smrg    rm -f lex.yy.c
2587a84e134Smrg    if test $# -ne 1; then
2597a84e134Smrg        eval LASTARG="\${$#}"
2607a84e134Smrg	case $LASTARG in
2617a84e134Smrg	*.l)
2627a84e134Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2637a84e134Smrg	    if test -f "$SRCFILE"; then
2647a84e134Smrg	         cp "$SRCFILE" lex.yy.c
2657a84e134Smrg	    fi
2667a84e134Smrg	  ;;
2677a84e134Smrg	esac
2687a84e134Smrg    fi
2697a84e134Smrg    if test ! -f lex.yy.c; then
2707a84e134Smrg	echo 'main() { return 0; }' >lex.yy.c
2717a84e134Smrg    fi
2727a84e134Smrg    ;;
2737a84e134Smrg
274e1e1713cSmrg  help2man*)
2757a84e134Smrg    echo 1>&2 "\
2767a84e134SmrgWARNING: \`$1' is $msg.  You should only need it if
2777a84e134Smrg	 you modified a dependency of a manual page.  You may need the
2787a84e134Smrg	 \`Help2man' package in order for those modifications to take
2797a84e134Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2807a84e134Smrg
2817a84e134Smrg    file=`echo "$*" | sed -n "$sed_output"`
2827a84e134Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2837a84e134Smrg    if test -f "$file"; then
2847a84e134Smrg	touch $file
2857a84e134Smrg    else
2867a84e134Smrg	test -z "$file" || exec >$file
2877a84e134Smrg	echo ".ab help2man is required to generate this page"
288e1e1713cSmrg	exit $?
2897a84e134Smrg    fi
2907a84e134Smrg    ;;
2917a84e134Smrg
292e1e1713cSmrg  makeinfo*)
2937a84e134Smrg    echo 1>&2 "\
2947a84e134SmrgWARNING: \`$1' is $msg.  You should only need it if
2957a84e134Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2967a84e134Smrg         indirectly affecting the aspect of the manual.  The spurious
2977a84e134Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2987a84e134Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2997a84e134Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
3007a84e134Smrg    # The file to touch is that specified with -o ...
3017a84e134Smrg    file=`echo "$*" | sed -n "$sed_output"`
3027a84e134Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
3037a84e134Smrg    if test -z "$file"; then
3047a84e134Smrg      # ... or it is the one specified with @setfilename ...
3057a84e134Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3067a84e134Smrg      file=`sed -n '
3077a84e134Smrg	/^@setfilename/{
3087a84e134Smrg	  s/.* \([^ ]*\) *$/\1/
3097a84e134Smrg	  p
3107a84e134Smrg	  q
3117a84e134Smrg	}' $infile`
3127a84e134Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3137a84e134Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3147a84e134Smrg    fi
3157a84e134Smrg    # If the file does not exist, the user really needs makeinfo;
3167a84e134Smrg    # let's fail without touching anything.
3177a84e134Smrg    test -f $file || exit 1
3187a84e134Smrg    touch $file
3197a84e134Smrg    ;;
3207a84e134Smrg
321e1e1713cSmrg  tar*)
3227a84e134Smrg    shift
3237a84e134Smrg
3247a84e134Smrg    # We have already tried tar in the generic part.
3257a84e134Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3267a84e134Smrg    # messages.
3277a84e134Smrg    if (gnutar --version > /dev/null 2>&1); then
3287a84e134Smrg       gnutar "$@" && exit 0
3297a84e134Smrg    fi
3307a84e134Smrg    if (gtar --version > /dev/null 2>&1); then
3317a84e134Smrg       gtar "$@" && exit 0
3327a84e134Smrg    fi
3337a84e134Smrg    firstarg="$1"
3347a84e134Smrg    if shift; then
3357a84e134Smrg	case $firstarg in
3367a84e134Smrg	*o*)
3377a84e134Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3387a84e134Smrg	    tar "$firstarg" "$@" && exit 0
3397a84e134Smrg	    ;;
3407a84e134Smrg	esac
3417a84e134Smrg	case $firstarg in
3427a84e134Smrg	*h*)
3437a84e134Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3447a84e134Smrg	    tar "$firstarg" "$@" && exit 0
3457a84e134Smrg	    ;;
3467a84e134Smrg	esac
3477a84e134Smrg    fi
3487a84e134Smrg
3497a84e134Smrg    echo 1>&2 "\
3507a84e134SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3517a84e134Smrg         You may want to install GNU tar or Free paxutils, or check the
3527a84e134Smrg         command line arguments."
3537a84e134Smrg    exit 1
3547a84e134Smrg    ;;
3557a84e134Smrg
3567a84e134Smrg  *)
3577a84e134Smrg    echo 1>&2 "\
3587a84e134SmrgWARNING: \`$1' is needed, and is $msg.
3597a84e134Smrg         You might have modified some files without having the
3607a84e134Smrg         proper tools for further handling them.  Check the \`README' file,
3617a84e134Smrg         it often tells you about the needed prerequisites for installing
3627a84e134Smrg         this package.  You may also peek at any GNU archive site, in case
3637a84e134Smrg         some other package would contain this missing \`$1' program."
3647a84e134Smrg    exit 1
3657a84e134Smrg    ;;
3667a84e134Smrgesac
3677a84e134Smrg
3687a84e134Smrgexit 0
3697a84e134Smrg
3707a84e134Smrg# Local variables:
3717a84e134Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3727a84e134Smrg# time-stamp-start: "scriptversion="
3737a84e134Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374e1e1713cSmrg# time-stamp-time-zone: "UTC"
375e1e1713cSmrg# time-stamp-end: "; # UTC"
3767a84e134Smrg# End:
377