missing revision 7ae0a258
17706df26Smrg#! /bin/sh
27706df26Smrg# Common stub for a few missing GNU programs while installing.
37706df26Smrg
47ae0a258Smrgscriptversion=2009-04-28.21; # UTC
57706df26Smrg
67ae0a258Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
77ae0a258Smrg# 2008, 2009 Free Software Foundation, Inc.
87706df26Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
97706df26Smrg
107706df26Smrg# This program is free software; you can redistribute it and/or modify
117706df26Smrg# it under the terms of the GNU General Public License as published by
127706df26Smrg# the Free Software Foundation; either version 2, or (at your option)
137706df26Smrg# any later version.
147706df26Smrg
157706df26Smrg# This program is distributed in the hope that it will be useful,
167706df26Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
177706df26Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
187706df26Smrg# GNU General Public License for more details.
197706df26Smrg
207706df26Smrg# You should have received a copy of the GNU General Public License
217ae0a258Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
227706df26Smrg
237706df26Smrg# As a special exception to the GNU General Public License, if you
247706df26Smrg# distribute this file as part of a program that contains a
257706df26Smrg# configuration script generated by Autoconf, you may include it under
267706df26Smrg# the same distribution terms that you use for the rest of that program.
277706df26Smrg
287706df26Smrgif test $# -eq 0; then
297706df26Smrg  echo 1>&2 "Try \`$0 --help' for more information"
307706df26Smrg  exit 1
317706df26Smrgfi
327706df26Smrg
337706df26Smrgrun=:
34047944f3Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35047944f3Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
367706df26Smrg
377706df26Smrg# In the cases where this matters, `missing' is being run in the
387706df26Smrg# srcdir already.
397706df26Smrgif test -f configure.ac; then
407706df26Smrg  configure_ac=configure.ac
417706df26Smrgelse
427706df26Smrg  configure_ac=configure.in
437706df26Smrgfi
447706df26Smrg
457706df26Smrgmsg="missing on your system"
467706df26Smrg
47047944f3Smrgcase $1 in
487706df26Smrg--run)
497706df26Smrg  # Try to run requested program, and just exit if it succeeds.
507706df26Smrg  run=
517706df26Smrg  shift
527706df26Smrg  "$@" && exit 0
537706df26Smrg  # Exit code 63 means version mismatch.  This often happens
547706df26Smrg  # when the user try to use an ancient version of a tool on
557706df26Smrg  # a file that requires a minimum version.  In this case we
567706df26Smrg  # we should proceed has if the program had been absent, or
577706df26Smrg  # if --run hadn't been passed.
587706df26Smrg  if test $? = 63; then
597706df26Smrg    run=:
607706df26Smrg    msg="probably too old"
617706df26Smrg  fi
627706df26Smrg  ;;
637706df26Smrg
647706df26Smrg  -h|--h|--he|--hel|--help)
657706df26Smrg    echo "\
667706df26Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
677706df26Smrg
687706df26SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
697706df26Smrgerror status if there is no known handling for PROGRAM.
707706df26Smrg
717706df26SmrgOptions:
727706df26Smrg  -h, --help      display this help and exit
737706df26Smrg  -v, --version   output version information and exit
747706df26Smrg  --run           try to run the given command, and emulate it if it fails
757706df26Smrg
767706df26SmrgSupported PROGRAM values:
777706df26Smrg  aclocal      touch file \`aclocal.m4'
787706df26Smrg  autoconf     touch file \`configure'
797706df26Smrg  autoheader   touch file \`config.h.in'
80047944f3Smrg  autom4te     touch the output file, or create a stub one
817706df26Smrg  automake     touch all \`Makefile.in' files
827706df26Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
837706df26Smrg  flex         create \`lex.yy.c', if possible, from existing .c
847706df26Smrg  help2man     touch the output file
857706df26Smrg  lex          create \`lex.yy.c', if possible, from existing .c
867706df26Smrg  makeinfo     touch the output file
877706df26Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
887706df26Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
897706df26Smrg
907ae0a258SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
917ae0a258Smrg\`g' are ignored when checking the name.
927ae0a258Smrg
937706df26SmrgSend bug reports to <bug-automake@gnu.org>."
947706df26Smrg    exit $?
957706df26Smrg    ;;
967706df26Smrg
977706df26Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
987706df26Smrg    echo "missing $scriptversion (GNU Automake)"
997706df26Smrg    exit $?
1007706df26Smrg    ;;
1017706df26Smrg
1027706df26Smrg  -*)
1037706df26Smrg    echo 1>&2 "$0: Unknown \`$1' option"
1047706df26Smrg    echo 1>&2 "Try \`$0 --help' for more information"
1057706df26Smrg    exit 1
1067706df26Smrg    ;;
1077706df26Smrg
1087706df26Smrgesac
1097706df26Smrg
1107ae0a258Smrg# normalize program name to check for.
1117ae0a258Smrgprogram=`echo "$1" | sed '
1127ae0a258Smrg  s/^gnu-//; t
1137ae0a258Smrg  s/^gnu//; t
1147ae0a258Smrg  s/^g//; t'`
1157ae0a258Smrg
1167706df26Smrg# Now exit if we have it, but it failed.  Also exit now if we
1177706df26Smrg# don't have it and --version was passed (most likely to detect
1187ae0a258Smrg# the program).  This is about non-GNU programs, so use $1 not
1197ae0a258Smrg# $program.
120047944f3Smrgcase $1 in
1217ae0a258Smrg  lex*|yacc*)
1227706df26Smrg    # Not GNU programs, they don't have --version.
1237706df26Smrg    ;;
1247706df26Smrg
1257ae0a258Smrg  tar*)
1267706df26Smrg    if test -n "$run"; then
1277706df26Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
1287706df26Smrg       exit 1
1297706df26Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1307706df26Smrg       exit 1
1317706df26Smrg    fi
1327706df26Smrg    ;;
1337706df26Smrg
1347706df26Smrg  *)
1357706df26Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
1367706df26Smrg       # We have it, but it failed.
1377706df26Smrg       exit 1
1387706df26Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1397706df26Smrg       # Could not run --version or --help.  This is probably someone
1407706df26Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1417706df26Smrg       # $TOOL exists and not knowing $TOOL uses missing.
1427706df26Smrg       exit 1
1437706df26Smrg    fi
1447706df26Smrg    ;;
1457706df26Smrgesac
1467706df26Smrg
1477706df26Smrg# If it does not exist, or fails to run (possibly an outdated version),
1487706df26Smrg# try to emulate it.
1497ae0a258Smrgcase $program in
1507706df26Smrg  aclocal*)
1517706df26Smrg    echo 1>&2 "\
1527706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
1537706df26Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
1547706df26Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
1557706df26Smrg         any GNU archive site."
1567706df26Smrg    touch aclocal.m4
1577706df26Smrg    ;;
1587706df26Smrg
1597ae0a258Smrg  autoconf*)
1607706df26Smrg    echo 1>&2 "\
1617706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
1627706df26Smrg         you modified \`${configure_ac}'.  You might want to install the
1637706df26Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
1647706df26Smrg         archive site."
1657706df26Smrg    touch configure
1667706df26Smrg    ;;
1677706df26Smrg
1687ae0a258Smrg  autoheader*)
1697706df26Smrg    echo 1>&2 "\
1707706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
1717706df26Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
1727706df26Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
1737706df26Smrg         from any GNU archive site."
1747706df26Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
1757706df26Smrg    test -z "$files" && files="config.h"
1767706df26Smrg    touch_files=
1777706df26Smrg    for f in $files; do
178047944f3Smrg      case $f in
1797706df26Smrg      *:*) touch_files="$touch_files "`echo "$f" |
1807706df26Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
1817706df26Smrg      *) touch_files="$touch_files $f.in";;
1827706df26Smrg      esac
1837706df26Smrg    done
1847706df26Smrg    touch $touch_files
1857706df26Smrg    ;;
1867706df26Smrg
1877706df26Smrg  automake*)
1887706df26Smrg    echo 1>&2 "\
1897706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
1907706df26Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
1917706df26Smrg         You might want to install the \`Automake' and \`Perl' packages.
1927706df26Smrg         Grab them from any GNU archive site."
1937706df26Smrg    find . -type f -name Makefile.am -print |
1947706df26Smrg	   sed 's/\.am$/.in/' |
1957706df26Smrg	   while read f; do touch "$f"; done
1967706df26Smrg    ;;
1977706df26Smrg
1987ae0a258Smrg  autom4te*)
1997706df26Smrg    echo 1>&2 "\
2007706df26SmrgWARNING: \`$1' is needed, but is $msg.
2017706df26Smrg         You might have modified some files without having the
2027706df26Smrg         proper tools for further handling them.
2037706df26Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
2047706df26Smrg         archive site."
2057706df26Smrg
206047944f3Smrg    file=`echo "$*" | sed -n "$sed_output"`
207047944f3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2087706df26Smrg    if test -f "$file"; then
2097706df26Smrg	touch $file
2107706df26Smrg    else
2117706df26Smrg	test -z "$file" || exec >$file
2127706df26Smrg	echo "#! /bin/sh"
2137706df26Smrg	echo "# Created by GNU Automake missing as a replacement of"
2147706df26Smrg	echo "#  $ $@"
2157706df26Smrg	echo "exit 0"
2167706df26Smrg	chmod +x $file
2177706df26Smrg	exit 1
2187706df26Smrg    fi
2197706df26Smrg    ;;
2207706df26Smrg
2217ae0a258Smrg  bison*|yacc*)
2227706df26Smrg    echo 1>&2 "\
2237706df26SmrgWARNING: \`$1' $msg.  You should only need it if
2247706df26Smrg         you modified a \`.y' file.  You may need the \`Bison' package
2257706df26Smrg         in order for those modifications to take effect.  You can get
2267706df26Smrg         \`Bison' from any GNU archive site."
2277706df26Smrg    rm -f y.tab.c y.tab.h
228047944f3Smrg    if test $# -ne 1; then
2297706df26Smrg        eval LASTARG="\${$#}"
230047944f3Smrg	case $LASTARG in
2317706df26Smrg	*.y)
2327706df26Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
233047944f3Smrg	    if test -f "$SRCFILE"; then
2347706df26Smrg	         cp "$SRCFILE" y.tab.c
2357706df26Smrg	    fi
2367706df26Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
237047944f3Smrg	    if test -f "$SRCFILE"; then
2387706df26Smrg	         cp "$SRCFILE" y.tab.h
2397706df26Smrg	    fi
2407706df26Smrg	  ;;
2417706df26Smrg	esac
2427706df26Smrg    fi
243047944f3Smrg    if test ! -f y.tab.h; then
2447706df26Smrg	echo >y.tab.h
2457706df26Smrg    fi
246047944f3Smrg    if test ! -f y.tab.c; then
2477706df26Smrg	echo 'main() { return 0; }' >y.tab.c
2487706df26Smrg    fi
2497706df26Smrg    ;;
2507706df26Smrg
2517ae0a258Smrg  lex*|flex*)
2527706df26Smrg    echo 1>&2 "\
2537706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
2547706df26Smrg         you modified a \`.l' file.  You may need the \`Flex' package
2557706df26Smrg         in order for those modifications to take effect.  You can get
2567706df26Smrg         \`Flex' from any GNU archive site."
2577706df26Smrg    rm -f lex.yy.c
258047944f3Smrg    if test $# -ne 1; then
2597706df26Smrg        eval LASTARG="\${$#}"
260047944f3Smrg	case $LASTARG in
2617706df26Smrg	*.l)
2627706df26Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
263047944f3Smrg	    if test -f "$SRCFILE"; then
2647706df26Smrg	         cp "$SRCFILE" lex.yy.c
2657706df26Smrg	    fi
2667706df26Smrg	  ;;
2677706df26Smrg	esac
2687706df26Smrg    fi
269047944f3Smrg    if test ! -f lex.yy.c; then
2707706df26Smrg	echo 'main() { return 0; }' >lex.yy.c
2717706df26Smrg    fi
2727706df26Smrg    ;;
2737706df26Smrg
2747ae0a258Smrg  help2man*)
2757706df26Smrg    echo 1>&2 "\
2767706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
2777706df26Smrg	 you modified a dependency of a manual page.  You may need the
2787706df26Smrg	 \`Help2man' package in order for those modifications to take
2797706df26Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
2807706df26Smrg
281047944f3Smrg    file=`echo "$*" | sed -n "$sed_output"`
282047944f3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
283047944f3Smrg    if test -f "$file"; then
2847706df26Smrg	touch $file
2857706df26Smrg    else
2867706df26Smrg	test -z "$file" || exec >$file
2877706df26Smrg	echo ".ab help2man is required to generate this page"
2887ae0a258Smrg	exit $?
2897706df26Smrg    fi
2907706df26Smrg    ;;
2917706df26Smrg
2927ae0a258Smrg  makeinfo*)
2937706df26Smrg    echo 1>&2 "\
2947706df26SmrgWARNING: \`$1' is $msg.  You should only need it if
2957706df26Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
2967706df26Smrg         indirectly affecting the aspect of the manual.  The spurious
2977706df26Smrg         call might also be the consequence of using a buggy \`make' (AIX,
2987706df26Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
2997706df26Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
3007706df26Smrg    # The file to touch is that specified with -o ...
301047944f3Smrg    file=`echo "$*" | sed -n "$sed_output"`
302047944f3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
3037706df26Smrg    if test -z "$file"; then
3047706df26Smrg      # ... or it is the one specified with @setfilename ...
3057706df26Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
306047944f3Smrg      file=`sed -n '
307047944f3Smrg	/^@setfilename/{
308047944f3Smrg	  s/.* \([^ ]*\) *$/\1/
309047944f3Smrg	  p
310047944f3Smrg	  q
311047944f3Smrg	}' $infile`
3127706df26Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3137706df26Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
3147706df26Smrg    fi
3157706df26Smrg    # If the file does not exist, the user really needs makeinfo;
3167706df26Smrg    # let's fail without touching anything.
3177706df26Smrg    test -f $file || exit 1
3187706df26Smrg    touch $file
3197706df26Smrg    ;;
3207706df26Smrg
3217ae0a258Smrg  tar*)
3227706df26Smrg    shift
3237706df26Smrg
3247706df26Smrg    # We have already tried tar in the generic part.
3257706df26Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
3267706df26Smrg    # messages.
3277706df26Smrg    if (gnutar --version > /dev/null 2>&1); then
3287706df26Smrg       gnutar "$@" && exit 0
3297706df26Smrg    fi
3307706df26Smrg    if (gtar --version > /dev/null 2>&1); then
3317706df26Smrg       gtar "$@" && exit 0
3327706df26Smrg    fi
3337706df26Smrg    firstarg="$1"
3347706df26Smrg    if shift; then
335047944f3Smrg	case $firstarg in
3367706df26Smrg	*o*)
3377706df26Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
3387706df26Smrg	    tar "$firstarg" "$@" && exit 0
3397706df26Smrg	    ;;
3407706df26Smrg	esac
341047944f3Smrg	case $firstarg in
3427706df26Smrg	*h*)
3437706df26Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
3447706df26Smrg	    tar "$firstarg" "$@" && exit 0
3457706df26Smrg	    ;;
3467706df26Smrg	esac
3477706df26Smrg    fi
3487706df26Smrg
3497706df26Smrg    echo 1>&2 "\
3507706df26SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
3517706df26Smrg         You may want to install GNU tar or Free paxutils, or check the
3527706df26Smrg         command line arguments."
3537706df26Smrg    exit 1
3547706df26Smrg    ;;
3557706df26Smrg
3567706df26Smrg  *)
3577706df26Smrg    echo 1>&2 "\
3587706df26SmrgWARNING: \`$1' is needed, and is $msg.
3597706df26Smrg         You might have modified some files without having the
3607706df26Smrg         proper tools for further handling them.  Check the \`README' file,
3617706df26Smrg         it often tells you about the needed prerequisites for installing
3627706df26Smrg         this package.  You may also peek at any GNU archive site, in case
3637706df26Smrg         some other package would contain this missing \`$1' program."
3647706df26Smrg    exit 1
3657706df26Smrg    ;;
3667706df26Smrgesac
3677706df26Smrg
3687706df26Smrgexit 0
3697706df26Smrg
3707706df26Smrg# Local variables:
3717706df26Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3727706df26Smrg# time-stamp-start: "scriptversion="
3737706df26Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3747ae0a258Smrg# time-stamp-time-zone: "UTC"
3757ae0a258Smrg# time-stamp-end: "; # UTC"
3767706df26Smrg# End:
377