missing revision e8ead290
17914d74bSmrg#! /bin/sh
27914d74bSmrg# Common stub for a few missing GNU programs while installing.
37914d74bSmrg
4e8ead290Smrgscriptversion=2009-04-28.21; # UTC
57914d74bSmrg
6e8ead290Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7e8ead290Smrg# 2008, 2009 Free Software Foundation, Inc.
87914d74bSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
97914d74bSmrg
107914d74bSmrg# This program is free software; you can redistribute it and/or modify
117914d74bSmrg# it under the terms of the GNU General Public License as published by
127914d74bSmrg# the Free Software Foundation; either version 2, or (at your option)
137914d74bSmrg# any later version.
147914d74bSmrg
157914d74bSmrg# This program is distributed in the hope that it will be useful,
167914d74bSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
177914d74bSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
187914d74bSmrg# GNU General Public License for more details.
197914d74bSmrg
207914d74bSmrg# You should have received a copy of the GNU General Public License
21e8ead290Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
227914d74bSmrg
237914d74bSmrg# As a special exception to the GNU General Public License, if you
247914d74bSmrg# distribute this file as part of a program that contains a
257914d74bSmrg# configuration script generated by Autoconf, you may include it under
267914d74bSmrg# the same distribution terms that you use for the rest of that program.
277914d74bSmrg
287914d74bSmrgif test $# -eq 0; then
297914d74bSmrg  echo 1>&2 "Try \`$0 --help' for more information"
307914d74bSmrg  exit 1
317914d74bSmrgfi
327914d74bSmrg
337914d74bSmrgrun=:
347914d74bSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
357914d74bSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
367914d74bSmrg
377914d74bSmrg# In the cases where this matters, `missing' is being run in the
387914d74bSmrg# srcdir already.
397914d74bSmrgif test -f configure.ac; then
407914d74bSmrg  configure_ac=configure.ac
417914d74bSmrgelse
427914d74bSmrg  configure_ac=configure.in
437914d74bSmrgfi
447914d74bSmrg
457914d74bSmrgmsg="missing on your system"
467914d74bSmrg
477914d74bSmrgcase $1 in
487914d74bSmrg--run)
497914d74bSmrg  # Try to run requested program, and just exit if it succeeds.
507914d74bSmrg  run=
517914d74bSmrg  shift
527914d74bSmrg  "$@" && exit 0
537914d74bSmrg  # Exit code 63 means version mismatch.  This often happens
547914d74bSmrg  # when the user try to use an ancient version of a tool on
557914d74bSmrg  # a file that requires a minimum version.  In this case we
567914d74bSmrg  # we should proceed has if the program had been absent, or
577914d74bSmrg  # if --run hadn't been passed.
587914d74bSmrg  if test $? = 63; then
597914d74bSmrg    run=:
607914d74bSmrg    msg="probably too old"
617914d74bSmrg  fi
627914d74bSmrg  ;;
637914d74bSmrg
647914d74bSmrg  -h|--h|--he|--hel|--help)
657914d74bSmrg    echo "\
667914d74bSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
677914d74bSmrg
687914d74bSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
697914d74bSmrgerror status if there is no known handling for PROGRAM.
707914d74bSmrg
717914d74bSmrgOptions:
727914d74bSmrg  -h, --help      display this help and exit
737914d74bSmrg  -v, --version   output version information and exit
747914d74bSmrg  --run           try to run the given command, and emulate it if it fails
757914d74bSmrg
767914d74bSmrgSupported PROGRAM values:
777914d74bSmrg  aclocal      touch file \`aclocal.m4'
787914d74bSmrg  autoconf     touch file \`configure'
797914d74bSmrg  autoheader   touch file \`config.h.in'
807914d74bSmrg  autom4te     touch the output file, or create a stub one
817914d74bSmrg  automake     touch all \`Makefile.in' files
827914d74bSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
837914d74bSmrg  flex         create \`lex.yy.c', if possible, from existing .c
847914d74bSmrg  help2man     touch the output file
857914d74bSmrg  lex          create \`lex.yy.c', if possible, from existing .c
867914d74bSmrg  makeinfo     touch the output file
877914d74bSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
887914d74bSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
897914d74bSmrg
90e8ead290SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91e8ead290Smrg\`g' are ignored when checking the name.
92e8ead290Smrg
937914d74bSmrgSend bug reports to <bug-automake@gnu.org>."
947914d74bSmrg    exit $?
957914d74bSmrg    ;;
967914d74bSmrg
977914d74bSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
987914d74bSmrg    echo "missing $scriptversion (GNU Automake)"
997914d74bSmrg    exit $?
1007914d74bSmrg    ;;
1017914d74bSmrg
1027914d74bSmrg  -*)
1037914d74bSmrg    echo 1>&2 "$0: Unknown \`$1' option"
1047914d74bSmrg    echo 1>&2 "Try \`$0 --help' for more information"
1057914d74bSmrg    exit 1
1067914d74bSmrg    ;;
1077914d74bSmrg
1087914d74bSmrgesac
1097914d74bSmrg
110e8ead290Smrg# normalize program name to check for.
111e8ead290Smrgprogram=`echo "$1" | sed '
112e8ead290Smrg  s/^gnu-//; t
113e8ead290Smrg  s/^gnu//; t
114e8ead290Smrg  s/^g//; t'`
115e8ead290Smrg
1167914d74bSmrg# Now exit if we have it, but it failed.  Also exit now if we
1177914d74bSmrg# don't have it and --version was passed (most likely to detect
118e8ead290Smrg# the program).  This is about non-GNU programs, so use $1 not
119e8ead290Smrg# $program.
1207914d74bSmrgcase $1 in
121e8ead290Smrg  lex*|yacc*)
1227914d74bSmrg    # Not GNU programs, they don't have --version.
1237914d74bSmrg    ;;
1247914d74bSmrg
125e8ead290Smrg  tar*)
1267914d74bSmrg    if test -n "$run"; then
1277914d74bSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
1287914d74bSmrg       exit 1
1297914d74bSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1307914d74bSmrg       exit 1
1317914d74bSmrg    fi
1327914d74bSmrg    ;;
1337914d74bSmrg
1347914d74bSmrg  *)
1357914d74bSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1367914d74bSmrg       # We have it, but it failed.
1377914d74bSmrg       exit 1
1387914d74bSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1397914d74bSmrg       # Could not run --version or --help.  This is probably someone
1407914d74bSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1417914d74bSmrg       # $TOOL exists and not knowing $TOOL uses missing.
1427914d74bSmrg       exit 1
1437914d74bSmrg    fi
1447914d74bSmrg    ;;
1457914d74bSmrgesac
1467914d74bSmrg
1477914d74bSmrg# If it does not exist, or fails to run (possibly an outdated version),
1487914d74bSmrg# try to emulate it.
149e8ead290Smrgcase $program in
1507914d74bSmrg  aclocal*)
1517914d74bSmrg    echo 1>&2 "\
1527914d74bSmrgWARNING: \`$1' is $msg.  You should only need it if
1537914d74bSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1547914d74bSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1557914d74bSmrg         any GNU archive site."
1567914d74bSmrg    touch aclocal.m4
1577914d74bSmrg    ;;
1587914d74bSmrg
159e8ead290Smrg  autoconf*)
1607914d74bSmrg    echo 1>&2 "\
1617914d74bSmrgWARNING: \`$1' is $msg.  You should only need it if
1627914d74bSmrg         you modified \`${configure_ac}'.  You might want to install the
1637914d74bSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1647914d74bSmrg         archive site."
1657914d74bSmrg    touch configure
1667914d74bSmrg    ;;
1677914d74bSmrg
168e8ead290Smrg  autoheader*)
1697914d74bSmrg    echo 1>&2 "\
1707914d74bSmrgWARNING: \`$1' is $msg.  You should only need it if
1717914d74bSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1727914d74bSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1737914d74bSmrg         from any GNU archive site."
1747914d74bSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1757914d74bSmrg    test -z "$files" && files="config.h"
1767914d74bSmrg    touch_files=
1777914d74bSmrg    for f in $files; do
1787914d74bSmrg      case $f in
1797914d74bSmrg      *:*) touch_files="$touch_files "`echo "$f" |
1807914d74bSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1817914d74bSmrg      *) touch_files="$touch_files $f.in";;
1827914d74bSmrg      esac
1837914d74bSmrg    done
1847914d74bSmrg    touch $touch_files
1857914d74bSmrg    ;;
1867914d74bSmrg
1877914d74bSmrg  automake*)
1887914d74bSmrg    echo 1>&2 "\
1897914d74bSmrgWARNING: \`$1' is $msg.  You should only need it if
1907914d74bSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1917914d74bSmrg         You might want to install the \`Automake' and \`Perl' packages.
1927914d74bSmrg         Grab them from any GNU archive site."
1937914d74bSmrg    find . -type f -name Makefile.am -print |
1947914d74bSmrg	   sed 's/\.am$/.in/' |
1957914d74bSmrg	   while read f; do touch "$f"; done
1967914d74bSmrg    ;;
1977914d74bSmrg
198e8ead290Smrg  autom4te*)
1997914d74bSmrg    echo 1>&2 "\
2007914d74bSmrgWARNING: \`$1' is needed, but is $msg.
2017914d74bSmrg         You might have modified some files without having the
2027914d74bSmrg         proper tools for further handling them.
2037914d74bSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
2047914d74bSmrg         archive site."
2057914d74bSmrg
2067914d74bSmrg    file=`echo "$*" | sed -n "$sed_output"`
2077914d74bSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2087914d74bSmrg    if test -f "$file"; then
2097914d74bSmrg	touch $file
2107914d74bSmrg    else
2117914d74bSmrg	test -z "$file" || exec >$file
2127914d74bSmrg	echo "#! /bin/sh"
2137914d74bSmrg	echo "# Created by GNU Automake missing as a replacement of"
2147914d74bSmrg	echo "#  $ $@"
2157914d74bSmrg	echo "exit 0"
2167914d74bSmrg	chmod +x $file
2177914d74bSmrg	exit 1
2187914d74bSmrg    fi
2197914d74bSmrg    ;;
2207914d74bSmrg
221e8ead290Smrg  bison*|yacc*)
2227914d74bSmrg    echo 1>&2 "\
2237914d74bSmrgWARNING: \`$1' $msg.  You should only need it if
2247914d74bSmrg         you modified a \`.y' file.  You may need the \`Bison' package
2257914d74bSmrg         in order for those modifications to take effect.  You can get
2267914d74bSmrg         \`Bison' from any GNU archive site."
2277914d74bSmrg    rm -f y.tab.c y.tab.h
2287914d74bSmrg    if test $# -ne 1; then
2297914d74bSmrg        eval LASTARG="\${$#}"
2307914d74bSmrg	case $LASTARG in
2317914d74bSmrg	*.y)
2327914d74bSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2337914d74bSmrg	    if test -f "$SRCFILE"; then
2347914d74bSmrg	         cp "$SRCFILE" y.tab.c
2357914d74bSmrg	    fi
2367914d74bSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2377914d74bSmrg	    if test -f "$SRCFILE"; then
2387914d74bSmrg	         cp "$SRCFILE" y.tab.h
2397914d74bSmrg	    fi
2407914d74bSmrg	  ;;
2417914d74bSmrg	esac
2427914d74bSmrg    fi
2437914d74bSmrg    if test ! -f y.tab.h; then
2447914d74bSmrg	echo >y.tab.h
2457914d74bSmrg    fi
2467914d74bSmrg    if test ! -f y.tab.c; then
2477914d74bSmrg	echo 'main() { return 0; }' >y.tab.c
2487914d74bSmrg    fi
2497914d74bSmrg    ;;
2507914d74bSmrg
251e8ead290Smrg  lex*|flex*)
2527914d74bSmrg    echo 1>&2 "\
2537914d74bSmrgWARNING: \`$1' is $msg.  You should only need it if
2547914d74bSmrg         you modified a \`.l' file.  You may need the \`Flex' package
2557914d74bSmrg         in order for those modifications to take effect.  You can get
2567914d74bSmrg         \`Flex' from any GNU archive site."
2577914d74bSmrg    rm -f lex.yy.c
2587914d74bSmrg    if test $# -ne 1; then
2597914d74bSmrg        eval LASTARG="\${$#}"
2607914d74bSmrg	case $LASTARG in
2617914d74bSmrg	*.l)
2627914d74bSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2637914d74bSmrg	    if test -f "$SRCFILE"; then
2647914d74bSmrg	         cp "$SRCFILE" lex.yy.c
2657914d74bSmrg	    fi
2667914d74bSmrg	  ;;
2677914d74bSmrg	esac
2687914d74bSmrg    fi
2697914d74bSmrg    if test ! -f lex.yy.c; then
2707914d74bSmrg	echo 'main() { return 0; }' >lex.yy.c
2717914d74bSmrg    fi
2727914d74bSmrg    ;;
2737914d74bSmrg
274e8ead290Smrg  help2man*)
2757914d74bSmrg    echo 1>&2 "\
2767914d74bSmrgWARNING: \`$1' is $msg.  You should only need it if
2777914d74bSmrg	 you modified a dependency of a manual page.  You may need the
2787914d74bSmrg	 \`Help2man' package in order for those modifications to take
2797914d74bSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
2807914d74bSmrg
2817914d74bSmrg    file=`echo "$*" | sed -n "$sed_output"`
2827914d74bSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2837914d74bSmrg    if test -f "$file"; then
2847914d74bSmrg	touch $file
2857914d74bSmrg    else
2867914d74bSmrg	test -z "$file" || exec >$file
2877914d74bSmrg	echo ".ab help2man is required to generate this page"
288e8ead290Smrg	exit $?
2897914d74bSmrg    fi
2907914d74bSmrg    ;;
2917914d74bSmrg
292e8ead290Smrg  makeinfo*)
2937914d74bSmrg    echo 1>&2 "\
2947914d74bSmrgWARNING: \`$1' is $msg.  You should only need it if
2957914d74bSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2967914d74bSmrg         indirectly affecting the aspect of the manual.  The spurious
2977914d74bSmrg         call might also be the consequence of using a buggy \`make' (AIX,
2987914d74bSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2997914d74bSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
3007914d74bSmrg    # The file to touch is that specified with -o ...
3017914d74bSmrg    file=`echo "$*" | sed -n "$sed_output"`
3027914d74bSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
3037914d74bSmrg    if test -z "$file"; then
3047914d74bSmrg      # ... or it is the one specified with @setfilename ...
3057914d74bSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3067914d74bSmrg      file=`sed -n '
3077914d74bSmrg	/^@setfilename/{
3087914d74bSmrg	  s/.* \([^ ]*\) *$/\1/
3097914d74bSmrg	  p
3107914d74bSmrg	  q
3117914d74bSmrg	}' $infile`
3127914d74bSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3137914d74bSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3147914d74bSmrg    fi
3157914d74bSmrg    # If the file does not exist, the user really needs makeinfo;
3167914d74bSmrg    # let's fail without touching anything.
3177914d74bSmrg    test -f $file || exit 1
3187914d74bSmrg    touch $file
3197914d74bSmrg    ;;
3207914d74bSmrg
321e8ead290Smrg  tar*)
3227914d74bSmrg    shift
3237914d74bSmrg
3247914d74bSmrg    # We have already tried tar in the generic part.
3257914d74bSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
3267914d74bSmrg    # messages.
3277914d74bSmrg    if (gnutar --version > /dev/null 2>&1); then
3287914d74bSmrg       gnutar "$@" && exit 0
3297914d74bSmrg    fi
3307914d74bSmrg    if (gtar --version > /dev/null 2>&1); then
3317914d74bSmrg       gtar "$@" && exit 0
3327914d74bSmrg    fi
3337914d74bSmrg    firstarg="$1"
3347914d74bSmrg    if shift; then
3357914d74bSmrg	case $firstarg in
3367914d74bSmrg	*o*)
3377914d74bSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
3387914d74bSmrg	    tar "$firstarg" "$@" && exit 0
3397914d74bSmrg	    ;;
3407914d74bSmrg	esac
3417914d74bSmrg	case $firstarg in
3427914d74bSmrg	*h*)
3437914d74bSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
3447914d74bSmrg	    tar "$firstarg" "$@" && exit 0
3457914d74bSmrg	    ;;
3467914d74bSmrg	esac
3477914d74bSmrg    fi
3487914d74bSmrg
3497914d74bSmrg    echo 1>&2 "\
3507914d74bSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3517914d74bSmrg         You may want to install GNU tar or Free paxutils, or check the
3527914d74bSmrg         command line arguments."
3537914d74bSmrg    exit 1
3547914d74bSmrg    ;;
3557914d74bSmrg
3567914d74bSmrg  *)
3577914d74bSmrg    echo 1>&2 "\
3587914d74bSmrgWARNING: \`$1' is needed, and is $msg.
3597914d74bSmrg         You might have modified some files without having the
3607914d74bSmrg         proper tools for further handling them.  Check the \`README' file,
3617914d74bSmrg         it often tells you about the needed prerequisites for installing
3627914d74bSmrg         this package.  You may also peek at any GNU archive site, in case
3637914d74bSmrg         some other package would contain this missing \`$1' program."
3647914d74bSmrg    exit 1
3657914d74bSmrg    ;;
3667914d74bSmrgesac
3677914d74bSmrg
3687914d74bSmrgexit 0
3697914d74bSmrg
3707914d74bSmrg# Local variables:
3717914d74bSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3727914d74bSmrg# time-stamp-start: "scriptversion="
3737914d74bSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374e8ead290Smrg# time-stamp-time-zone: "UTC"
375e8ead290Smrg# time-stamp-end: "; # UTC"
3767914d74bSmrg# End:
377