missing revision 9418810d
19bd41f2cSmrg#! /bin/sh
29bd41f2cSmrg# Common stub for a few missing GNU programs while installing.
39bd41f2cSmrg
49418810dSmrgscriptversion=2009-04-28.21; # UTC
59bd41f2cSmrg
69418810dSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
79418810dSmrg# 2008, 2009 Free Software Foundation, Inc.
89bd41f2cSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
99bd41f2cSmrg
109bd41f2cSmrg# This program is free software; you can redistribute it and/or modify
119bd41f2cSmrg# it under the terms of the GNU General Public License as published by
129bd41f2cSmrg# the Free Software Foundation; either version 2, or (at your option)
139bd41f2cSmrg# any later version.
149bd41f2cSmrg
159bd41f2cSmrg# This program is distributed in the hope that it will be useful,
169bd41f2cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
179bd41f2cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
189bd41f2cSmrg# GNU General Public License for more details.
199bd41f2cSmrg
209bd41f2cSmrg# You should have received a copy of the GNU General Public License
219418810dSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
229bd41f2cSmrg
239bd41f2cSmrg# As a special exception to the GNU General Public License, if you
249bd41f2cSmrg# distribute this file as part of a program that contains a
259bd41f2cSmrg# configuration script generated by Autoconf, you may include it under
269bd41f2cSmrg# the same distribution terms that you use for the rest of that program.
279bd41f2cSmrg
289bd41f2cSmrgif test $# -eq 0; then
299bd41f2cSmrg  echo 1>&2 "Try \`$0 --help' for more information"
309bd41f2cSmrg  exit 1
319bd41f2cSmrgfi
329bd41f2cSmrg
339bd41f2cSmrgrun=:
349418810dSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
359418810dSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
369bd41f2cSmrg
379bd41f2cSmrg# In the cases where this matters, `missing' is being run in the
389bd41f2cSmrg# srcdir already.
399bd41f2cSmrgif test -f configure.ac; then
409bd41f2cSmrg  configure_ac=configure.ac
419bd41f2cSmrgelse
429bd41f2cSmrg  configure_ac=configure.in
439bd41f2cSmrgfi
449bd41f2cSmrg
459bd41f2cSmrgmsg="missing on your system"
469bd41f2cSmrg
479418810dSmrgcase $1 in
489bd41f2cSmrg--run)
499bd41f2cSmrg  # Try to run requested program, and just exit if it succeeds.
509bd41f2cSmrg  run=
519bd41f2cSmrg  shift
529bd41f2cSmrg  "$@" && exit 0
539bd41f2cSmrg  # Exit code 63 means version mismatch.  This often happens
549bd41f2cSmrg  # when the user try to use an ancient version of a tool on
559bd41f2cSmrg  # a file that requires a minimum version.  In this case we
569bd41f2cSmrg  # we should proceed has if the program had been absent, or
579bd41f2cSmrg  # if --run hadn't been passed.
589bd41f2cSmrg  if test $? = 63; then
599bd41f2cSmrg    run=:
609bd41f2cSmrg    msg="probably too old"
619bd41f2cSmrg  fi
629bd41f2cSmrg  ;;
639bd41f2cSmrg
649bd41f2cSmrg  -h|--h|--he|--hel|--help)
659bd41f2cSmrg    echo "\
669bd41f2cSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
679bd41f2cSmrg
689bd41f2cSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
699bd41f2cSmrgerror status if there is no known handling for PROGRAM.
709bd41f2cSmrg
719bd41f2cSmrgOptions:
729bd41f2cSmrg  -h, --help      display this help and exit
739bd41f2cSmrg  -v, --version   output version information and exit
749bd41f2cSmrg  --run           try to run the given command, and emulate it if it fails
759bd41f2cSmrg
769bd41f2cSmrgSupported PROGRAM values:
779bd41f2cSmrg  aclocal      touch file \`aclocal.m4'
789bd41f2cSmrg  autoconf     touch file \`configure'
799bd41f2cSmrg  autoheader   touch file \`config.h.in'
809418810dSmrg  autom4te     touch the output file, or create a stub one
819bd41f2cSmrg  automake     touch all \`Makefile.in' files
829bd41f2cSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
839bd41f2cSmrg  flex         create \`lex.yy.c', if possible, from existing .c
849bd41f2cSmrg  help2man     touch the output file
859bd41f2cSmrg  lex          create \`lex.yy.c', if possible, from existing .c
869bd41f2cSmrg  makeinfo     touch the output file
879bd41f2cSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
889bd41f2cSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
899bd41f2cSmrg
909418810dSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
919418810dSmrg\`g' are ignored when checking the name.
929418810dSmrg
939bd41f2cSmrgSend bug reports to <bug-automake@gnu.org>."
949bd41f2cSmrg    exit $?
959bd41f2cSmrg    ;;
969bd41f2cSmrg
979bd41f2cSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
989bd41f2cSmrg    echo "missing $scriptversion (GNU Automake)"
999bd41f2cSmrg    exit $?
1009bd41f2cSmrg    ;;
1019bd41f2cSmrg
1029bd41f2cSmrg  -*)
1039bd41f2cSmrg    echo 1>&2 "$0: Unknown \`$1' option"
1049bd41f2cSmrg    echo 1>&2 "Try \`$0 --help' for more information"
1059bd41f2cSmrg    exit 1
1069bd41f2cSmrg    ;;
1079bd41f2cSmrg
1089bd41f2cSmrgesac
1099bd41f2cSmrg
1109418810dSmrg# normalize program name to check for.
1119418810dSmrgprogram=`echo "$1" | sed '
1129418810dSmrg  s/^gnu-//; t
1139418810dSmrg  s/^gnu//; t
1149418810dSmrg  s/^g//; t'`
1159418810dSmrg
1169bd41f2cSmrg# Now exit if we have it, but it failed.  Also exit now if we
1179bd41f2cSmrg# don't have it and --version was passed (most likely to detect
1189418810dSmrg# the program).  This is about non-GNU programs, so use $1 not
1199418810dSmrg# $program.
1209418810dSmrgcase $1 in
1219418810dSmrg  lex*|yacc*)
1229bd41f2cSmrg    # Not GNU programs, they don't have --version.
1239bd41f2cSmrg    ;;
1249bd41f2cSmrg
1259418810dSmrg  tar*)
1269bd41f2cSmrg    if test -n "$run"; then
1279bd41f2cSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
1289bd41f2cSmrg       exit 1
1299bd41f2cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1309bd41f2cSmrg       exit 1
1319bd41f2cSmrg    fi
1329bd41f2cSmrg    ;;
1339bd41f2cSmrg
1349bd41f2cSmrg  *)
1359bd41f2cSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1369bd41f2cSmrg       # We have it, but it failed.
1379bd41f2cSmrg       exit 1
1389bd41f2cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1399bd41f2cSmrg       # Could not run --version or --help.  This is probably someone
1409bd41f2cSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1419bd41f2cSmrg       # $TOOL exists and not knowing $TOOL uses missing.
1429bd41f2cSmrg       exit 1
1439bd41f2cSmrg    fi
1449bd41f2cSmrg    ;;
1459bd41f2cSmrgesac
1469bd41f2cSmrg
1479bd41f2cSmrg# If it does not exist, or fails to run (possibly an outdated version),
1489bd41f2cSmrg# try to emulate it.
1499418810dSmrgcase $program in
1509bd41f2cSmrg  aclocal*)
1519bd41f2cSmrg    echo 1>&2 "\
1529bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
1539bd41f2cSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1549bd41f2cSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1559bd41f2cSmrg         any GNU archive site."
1569bd41f2cSmrg    touch aclocal.m4
1579bd41f2cSmrg    ;;
1589bd41f2cSmrg
1599418810dSmrg  autoconf*)
1609bd41f2cSmrg    echo 1>&2 "\
1619bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
1629bd41f2cSmrg         you modified \`${configure_ac}'.  You might want to install the
1639bd41f2cSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1649bd41f2cSmrg         archive site."
1659bd41f2cSmrg    touch configure
1669bd41f2cSmrg    ;;
1679bd41f2cSmrg
1689418810dSmrg  autoheader*)
1699bd41f2cSmrg    echo 1>&2 "\
1709bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
1719bd41f2cSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1729bd41f2cSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1739bd41f2cSmrg         from any GNU archive site."
1749bd41f2cSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1759bd41f2cSmrg    test -z "$files" && files="config.h"
1769bd41f2cSmrg    touch_files=
1779bd41f2cSmrg    for f in $files; do
1789418810dSmrg      case $f in
1799bd41f2cSmrg      *:*) touch_files="$touch_files "`echo "$f" |
1809bd41f2cSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1819bd41f2cSmrg      *) touch_files="$touch_files $f.in";;
1829bd41f2cSmrg      esac
1839bd41f2cSmrg    done
1849bd41f2cSmrg    touch $touch_files
1859bd41f2cSmrg    ;;
1869bd41f2cSmrg
1879bd41f2cSmrg  automake*)
1889bd41f2cSmrg    echo 1>&2 "\
1899bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
1909bd41f2cSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1919bd41f2cSmrg         You might want to install the \`Automake' and \`Perl' packages.
1929bd41f2cSmrg         Grab them from any GNU archive site."
1939bd41f2cSmrg    find . -type f -name Makefile.am -print |
1949bd41f2cSmrg	   sed 's/\.am$/.in/' |
1959bd41f2cSmrg	   while read f; do touch "$f"; done
1969bd41f2cSmrg    ;;
1979bd41f2cSmrg
1989418810dSmrg  autom4te*)
1999bd41f2cSmrg    echo 1>&2 "\
2009bd41f2cSmrgWARNING: \`$1' is needed, but is $msg.
2019bd41f2cSmrg         You might have modified some files without having the
2029bd41f2cSmrg         proper tools for further handling them.
2039bd41f2cSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
2049bd41f2cSmrg         archive site."
2059bd41f2cSmrg
2069418810dSmrg    file=`echo "$*" | sed -n "$sed_output"`
2079418810dSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2089bd41f2cSmrg    if test -f "$file"; then
2099bd41f2cSmrg	touch $file
2109bd41f2cSmrg    else
2119bd41f2cSmrg	test -z "$file" || exec >$file
2129bd41f2cSmrg	echo "#! /bin/sh"
2139bd41f2cSmrg	echo "# Created by GNU Automake missing as a replacement of"
2149bd41f2cSmrg	echo "#  $ $@"
2159bd41f2cSmrg	echo "exit 0"
2169bd41f2cSmrg	chmod +x $file
2179bd41f2cSmrg	exit 1
2189bd41f2cSmrg    fi
2199bd41f2cSmrg    ;;
2209bd41f2cSmrg
2219418810dSmrg  bison*|yacc*)
2229bd41f2cSmrg    echo 1>&2 "\
2239bd41f2cSmrgWARNING: \`$1' $msg.  You should only need it if
2249bd41f2cSmrg         you modified a \`.y' file.  You may need the \`Bison' package
2259bd41f2cSmrg         in order for those modifications to take effect.  You can get
2269bd41f2cSmrg         \`Bison' from any GNU archive site."
2279bd41f2cSmrg    rm -f y.tab.c y.tab.h
2289418810dSmrg    if test $# -ne 1; then
2299bd41f2cSmrg        eval LASTARG="\${$#}"
2309418810dSmrg	case $LASTARG in
2319bd41f2cSmrg	*.y)
2329bd41f2cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2339418810dSmrg	    if test -f "$SRCFILE"; then
2349bd41f2cSmrg	         cp "$SRCFILE" y.tab.c
2359bd41f2cSmrg	    fi
2369bd41f2cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2379418810dSmrg	    if test -f "$SRCFILE"; then
2389bd41f2cSmrg	         cp "$SRCFILE" y.tab.h
2399bd41f2cSmrg	    fi
2409bd41f2cSmrg	  ;;
2419bd41f2cSmrg	esac
2429bd41f2cSmrg    fi
2439418810dSmrg    if test ! -f y.tab.h; then
2449bd41f2cSmrg	echo >y.tab.h
2459bd41f2cSmrg    fi
2469418810dSmrg    if test ! -f y.tab.c; then
2479bd41f2cSmrg	echo 'main() { return 0; }' >y.tab.c
2489bd41f2cSmrg    fi
2499bd41f2cSmrg    ;;
2509bd41f2cSmrg
2519418810dSmrg  lex*|flex*)
2529bd41f2cSmrg    echo 1>&2 "\
2539bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
2549bd41f2cSmrg         you modified a \`.l' file.  You may need the \`Flex' package
2559bd41f2cSmrg         in order for those modifications to take effect.  You can get
2569bd41f2cSmrg         \`Flex' from any GNU archive site."
2579bd41f2cSmrg    rm -f lex.yy.c
2589418810dSmrg    if test $# -ne 1; then
2599bd41f2cSmrg        eval LASTARG="\${$#}"
2609418810dSmrg	case $LASTARG in
2619bd41f2cSmrg	*.l)
2629bd41f2cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2639418810dSmrg	    if test -f "$SRCFILE"; then
2649bd41f2cSmrg	         cp "$SRCFILE" lex.yy.c
2659bd41f2cSmrg	    fi
2669bd41f2cSmrg	  ;;
2679bd41f2cSmrg	esac
2689bd41f2cSmrg    fi
2699418810dSmrg    if test ! -f lex.yy.c; then
2709bd41f2cSmrg	echo 'main() { return 0; }' >lex.yy.c
2719bd41f2cSmrg    fi
2729bd41f2cSmrg    ;;
2739bd41f2cSmrg
2749418810dSmrg  help2man*)
2759bd41f2cSmrg    echo 1>&2 "\
2769bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
2779bd41f2cSmrg	 you modified a dependency of a manual page.  You may need the
2789bd41f2cSmrg	 \`Help2man' package in order for those modifications to take
2799bd41f2cSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
2809bd41f2cSmrg
2819418810dSmrg    file=`echo "$*" | sed -n "$sed_output"`
2829418810dSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2839418810dSmrg    if test -f "$file"; then
2849bd41f2cSmrg	touch $file
2859bd41f2cSmrg    else
2869bd41f2cSmrg	test -z "$file" || exec >$file
2879bd41f2cSmrg	echo ".ab help2man is required to generate this page"
2889418810dSmrg	exit $?
2899bd41f2cSmrg    fi
2909bd41f2cSmrg    ;;
2919bd41f2cSmrg
2929418810dSmrg  makeinfo*)
2939bd41f2cSmrg    echo 1>&2 "\
2949bd41f2cSmrgWARNING: \`$1' is $msg.  You should only need it if
2959bd41f2cSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2969bd41f2cSmrg         indirectly affecting the aspect of the manual.  The spurious
2979bd41f2cSmrg         call might also be the consequence of using a buggy \`make' (AIX,
2989bd41f2cSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2999bd41f2cSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
3009bd41f2cSmrg    # The file to touch is that specified with -o ...
3019418810dSmrg    file=`echo "$*" | sed -n "$sed_output"`
3029418810dSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
3039bd41f2cSmrg    if test -z "$file"; then
3049bd41f2cSmrg      # ... or it is the one specified with @setfilename ...
3059bd41f2cSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3069418810dSmrg      file=`sed -n '
3079418810dSmrg	/^@setfilename/{
3089418810dSmrg	  s/.* \([^ ]*\) *$/\1/
3099418810dSmrg	  p
3109418810dSmrg	  q
3119418810dSmrg	}' $infile`
3129bd41f2cSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3139bd41f2cSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3149bd41f2cSmrg    fi
3159bd41f2cSmrg    # If the file does not exist, the user really needs makeinfo;
3169bd41f2cSmrg    # let's fail without touching anything.
3179bd41f2cSmrg    test -f $file || exit 1
3189bd41f2cSmrg    touch $file
3199bd41f2cSmrg    ;;
3209bd41f2cSmrg
3219418810dSmrg  tar*)
3229bd41f2cSmrg    shift
3239bd41f2cSmrg
3249bd41f2cSmrg    # We have already tried tar in the generic part.
3259bd41f2cSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
3269bd41f2cSmrg    # messages.
3279bd41f2cSmrg    if (gnutar --version > /dev/null 2>&1); then
3289bd41f2cSmrg       gnutar "$@" && exit 0
3299bd41f2cSmrg    fi
3309bd41f2cSmrg    if (gtar --version > /dev/null 2>&1); then
3319bd41f2cSmrg       gtar "$@" && exit 0
3329bd41f2cSmrg    fi
3339bd41f2cSmrg    firstarg="$1"
3349bd41f2cSmrg    if shift; then
3359418810dSmrg	case $firstarg in
3369bd41f2cSmrg	*o*)
3379bd41f2cSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
3389bd41f2cSmrg	    tar "$firstarg" "$@" && exit 0
3399bd41f2cSmrg	    ;;
3409bd41f2cSmrg	esac
3419418810dSmrg	case $firstarg in
3429bd41f2cSmrg	*h*)
3439bd41f2cSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
3449bd41f2cSmrg	    tar "$firstarg" "$@" && exit 0
3459bd41f2cSmrg	    ;;
3469bd41f2cSmrg	esac
3479bd41f2cSmrg    fi
3489bd41f2cSmrg
3499bd41f2cSmrg    echo 1>&2 "\
3509bd41f2cSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3519bd41f2cSmrg         You may want to install GNU tar or Free paxutils, or check the
3529bd41f2cSmrg         command line arguments."
3539bd41f2cSmrg    exit 1
3549bd41f2cSmrg    ;;
3559bd41f2cSmrg
3569bd41f2cSmrg  *)
3579bd41f2cSmrg    echo 1>&2 "\
3589bd41f2cSmrgWARNING: \`$1' is needed, and is $msg.
3599bd41f2cSmrg         You might have modified some files without having the
3609bd41f2cSmrg         proper tools for further handling them.  Check the \`README' file,
3619bd41f2cSmrg         it often tells you about the needed prerequisites for installing
3629bd41f2cSmrg         this package.  You may also peek at any GNU archive site, in case
3639bd41f2cSmrg         some other package would contain this missing \`$1' program."
3649bd41f2cSmrg    exit 1
3659bd41f2cSmrg    ;;
3669bd41f2cSmrgesac
3679bd41f2cSmrg
3689bd41f2cSmrgexit 0
3699bd41f2cSmrg
3709bd41f2cSmrg# Local variables:
3719bd41f2cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3729bd41f2cSmrg# time-stamp-start: "scriptversion="
3739bd41f2cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3749418810dSmrg# time-stamp-time-zone: "UTC"
3759418810dSmrg# time-stamp-end: "; # UTC"
3769bd41f2cSmrg# End:
377