Blame build-aux/missing

Packit 47b4ca
#! /bin/sh
Packit 47b4ca
# Common stub for a few missing GNU programs while installing.
Packit 47b4ca
Packit 47b4ca
scriptversion=2012-01-06.18; # UTC
Packit 47b4ca
Packit 47b4ca
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
Packit 47b4ca
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
Packit 47b4ca
Packit 47b4ca
# This program is free software; you can redistribute it and/or modify
Packit 47b4ca
# it under the terms of the GNU General Public License as published by
Packit 47b4ca
# the Free Software Foundation; either version 2, or (at your option)
Packit 47b4ca
# any later version.
Packit 47b4ca
Packit 47b4ca
# This program is distributed in the hope that it will be useful,
Packit 47b4ca
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 47b4ca
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 47b4ca
# GNU General Public License for more details.
Packit 47b4ca
Packit 47b4ca
# You should have received a copy of the GNU General Public License
Packit 47b4ca
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 47b4ca
Packit 47b4ca
# As a special exception to the GNU General Public License, if you
Packit 47b4ca
# distribute this file as part of a program that contains a
Packit 47b4ca
# configuration script generated by Autoconf, you may include it under
Packit 47b4ca
# the same distribution terms that you use for the rest of that program.
Packit 47b4ca
Packit 47b4ca
if test $# -eq 0; then
Packit 47b4ca
  echo 1>&2 "Try '$0 --help' for more information"
Packit 47b4ca
  exit 1
Packit 47b4ca
fi
Packit 47b4ca
Packit 47b4ca
run=:
Packit 47b4ca
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
Packit 47b4ca
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
Packit 47b4ca
Packit 47b4ca
# In the cases where this matters, 'missing' is being run in the
Packit 47b4ca
# srcdir already.
Packit 47b4ca
if test -f configure.ac; then
Packit 47b4ca
  configure_ac=configure.ac
Packit 47b4ca
else
Packit 47b4ca
  configure_ac=configure.in
Packit 47b4ca
fi
Packit 47b4ca
Packit 47b4ca
msg="missing on your system"
Packit 47b4ca
Packit 47b4ca
case $1 in
Packit 47b4ca
--run)
Packit 47b4ca
  # Try to run requested program, and just exit if it succeeds.
Packit 47b4ca
  run=
Packit 47b4ca
  shift
Packit 47b4ca
  "$@" && exit 0
Packit 47b4ca
  # Exit code 63 means version mismatch.  This often happens
Packit 47b4ca
  # when the user try to use an ancient version of a tool on
Packit 47b4ca
  # a file that requires a minimum version.  In this case we
Packit 47b4ca
  # we should proceed has if the program had been absent, or
Packit 47b4ca
  # if --run hadn't been passed.
Packit 47b4ca
  if test $? = 63; then
Packit 47b4ca
    run=:
Packit 47b4ca
    msg="probably too old"
Packit 47b4ca
  fi
Packit 47b4ca
  ;;
Packit 47b4ca
Packit 47b4ca
  -h|--h|--he|--hel|--help)
Packit 47b4ca
    echo "\
Packit 47b4ca
$0 [OPTION]... PROGRAM [ARGUMENT]...
Packit 47b4ca
Packit 47b4ca
Handle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
Packit 47b4ca
error status if there is no known handling for PROGRAM.
Packit 47b4ca
Packit 47b4ca
Options:
Packit 47b4ca
  -h, --help      display this help and exit
Packit 47b4ca
  -v, --version   output version information and exit
Packit 47b4ca
  --run           try to run the given command, and emulate it if it fails
Packit 47b4ca
Packit 47b4ca
Supported PROGRAM values:
Packit 47b4ca
  aclocal      touch file 'aclocal.m4'
Packit 47b4ca
  autoconf     touch file 'configure'
Packit 47b4ca
  autoheader   touch file 'config.h.in'
Packit 47b4ca
  autom4te     touch the output file, or create a stub one
Packit 47b4ca
  automake     touch all 'Makefile.in' files
Packit 47b4ca
  bison        create 'y.tab.[ch]', if possible, from existing .[ch]
Packit 47b4ca
  flex         create 'lex.yy.c', if possible, from existing .c
Packit 47b4ca
  help2man     touch the output file
Packit 47b4ca
  lex          create 'lex.yy.c', if possible, from existing .c
Packit 47b4ca
  makeinfo     touch the output file
Packit 47b4ca
  yacc         create 'y.tab.[ch]', if possible, from existing .[ch]
Packit 47b4ca
Packit 47b4ca
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
Packit 47b4ca
'g' are ignored when checking the name.
Packit 47b4ca
Packit 47b4ca
Send bug reports to <bug-automake@gnu.org>."
Packit 47b4ca
    exit $?
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
Packit 47b4ca
    echo "missing $scriptversion (GNU Automake)"
Packit 47b4ca
    exit $?
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
  -*)
Packit 47b4ca
    echo 1>&2 "$0: Unknown '$1' option"
Packit 47b4ca
    echo 1>&2 "Try '$0 --help' for more information"
Packit 47b4ca
    exit 1
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
esac
Packit 47b4ca
Packit 47b4ca
# normalize program name to check for.
Packit 47b4ca
program=`echo "$1" | sed '
Packit 47b4ca
  s/^gnu-//; t
Packit 47b4ca
  s/^gnu//; t
Packit 47b4ca
  s/^g//; t'`
Packit 47b4ca
Packit 47b4ca
# Now exit if we have it, but it failed.  Also exit now if we
Packit 47b4ca
# don't have it and --version was passed (most likely to detect
Packit 47b4ca
# the program).  This is about non-GNU programs, so use $1 not
Packit 47b4ca
# $program.
Packit 47b4ca
case $1 in
Packit 47b4ca
  lex*|yacc*)
Packit 47b4ca
    # Not GNU programs, they don't have --version.
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
  *)
Packit 47b4ca
    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
Packit 47b4ca
       # We have it, but it failed.
Packit 47b4ca
       exit 1
Packit 47b4ca
    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
Packit 47b4ca
       # Could not run --version or --help.  This is probably someone
Packit 47b4ca
       # running '$TOOL --version' or '$TOOL --help' to check whether
Packit 47b4ca
       # $TOOL exists and not knowing $TOOL uses missing.
Packit 47b4ca
       exit 1
Packit 47b4ca
    fi
Packit 47b4ca
    ;;
Packit 47b4ca
esac
Packit 47b4ca
Packit 47b4ca
# If it does not exist, or fails to run (possibly an outdated version),
Packit 47b4ca
# try to emulate it.
Packit 47b4ca
case $program in
Packit 47b4ca
  aclocal*)
Packit 47b4ca
    echo 1>&2 "\
Packit 47b4ca
WARNING: '$1' is $msg.  You should only need it if
Packit 47b4ca
         you modified 'acinclude.m4' or '${configure_ac}'.  You might want
Packit 47b4ca
         to install the Automake and Perl packages.  Grab them from
Packit 47b4ca
         any GNU archive site."
Packit 47b4ca
    touch aclocal.m4
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
  autoconf*)
Packit 47b4ca
    echo 1>&2 "\
Packit 47b4ca
WARNING: '$1' is $msg.  You should only need it if
Packit 47b4ca
         you modified '${configure_ac}'.  You might want to install the
Packit 47b4ca
         Autoconf and GNU m4 packages.  Grab them from any GNU
Packit 47b4ca
         archive site."
Packit 47b4ca
    touch configure
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
  autoheader*)
Packit 47b4ca
    echo 1>&2 "\
Packit 47b4ca
WARNING: '$1' is $msg.  You should only need it if
Packit 47b4ca
         you modified 'acconfig.h' or '${configure_ac}'.  You might want
Packit 47b4ca
         to install the Autoconf and GNU m4 packages.  Grab them
Packit 47b4ca
         from any GNU archive site."
Packit 47b4ca
    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
Packit 47b4ca
    test -z "$files" && files="config.h"
Packit 47b4ca
    touch_files=
Packit 47b4ca
    for f in $files; do
Packit 47b4ca
      case $f in
Packit 47b4ca
      *:*) touch_files="$touch_files "`echo "$f" |
Packit 47b4ca
				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
Packit 47b4ca
      *) touch_files="$touch_files $f.in";;
Packit 47b4ca
      esac
Packit 47b4ca
    done
Packit 47b4ca
    touch $touch_files
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
  automake*)
Packit 47b4ca
    echo 1>&2 "\
Packit 47b4ca
WARNING: '$1' is $msg.  You should only need it if
Packit 47b4ca
         you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'.
Packit 47b4ca
         You might want to install the Automake and Perl packages.
Packit 47b4ca
         Grab them from any GNU archive site."
Packit 47b4ca
    find . -type f -name Makefile.am -print |
Packit 47b4ca
	   sed 's/\.am$/.in/' |
Packit 47b4ca
	   while read f; do touch "$f"; done
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
  autom4te*)
Packit 47b4ca
    echo 1>&2 "\
Packit 47b4ca
WARNING: '$1' is needed, but is $msg.
Packit 47b4ca
         You might have modified some files without having the
Packit 47b4ca
         proper tools for further handling them.
Packit 47b4ca
         You can get '$1' as part of Autoconf from any GNU
Packit 47b4ca
         archive site."
Packit 47b4ca
Packit 47b4ca
    file=`echo "$*" | sed -n "$sed_output"`
Packit 47b4ca
    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
Packit 47b4ca
    if test -f "$file"; then
Packit 47b4ca
	touch $file
Packit 47b4ca
    else
Packit 47b4ca
	test -z "$file" || exec >$file
Packit 47b4ca
	echo "#! /bin/sh"
Packit 47b4ca
	echo "# Created by GNU Automake missing as a replacement of"
Packit 47b4ca
	echo "#  $ $@"
Packit 47b4ca
	echo "exit 0"
Packit 47b4ca
	chmod +x $file
Packit 47b4ca
	exit 1
Packit 47b4ca
    fi
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
  bison*|yacc*)
Packit 47b4ca
    echo 1>&2 "\
Packit 47b4ca
WARNING: '$1' $msg.  You should only need it if
Packit 47b4ca
         you modified a '.y' file.  You may need the Bison package
Packit 47b4ca
         in order for those modifications to take effect.  You can get
Packit 47b4ca
         Bison from any GNU archive site."
Packit 47b4ca
    rm -f y.tab.c y.tab.h
Packit 47b4ca
    if test $# -ne 1; then
Packit 47b4ca
        eval LASTARG=\${$#}
Packit 47b4ca
	case $LASTARG in
Packit 47b4ca
	*.y)
Packit 47b4ca
	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
Packit 47b4ca
	    if test -f "$SRCFILE"; then
Packit 47b4ca
	         cp "$SRCFILE" y.tab.c
Packit 47b4ca
	    fi
Packit 47b4ca
	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
Packit 47b4ca
	    if test -f "$SRCFILE"; then
Packit 47b4ca
	         cp "$SRCFILE" y.tab.h
Packit 47b4ca
	    fi
Packit 47b4ca
	  ;;
Packit 47b4ca
	esac
Packit 47b4ca
    fi
Packit 47b4ca
    if test ! -f y.tab.h; then
Packit 47b4ca
	echo >y.tab.h
Packit 47b4ca
    fi
Packit 47b4ca
    if test ! -f y.tab.c; then
Packit 47b4ca
	echo 'main() { return 0; }' >y.tab.c
Packit 47b4ca
    fi
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
  lex*|flex*)
Packit 47b4ca
    echo 1>&2 "\
Packit 47b4ca
WARNING: '$1' is $msg.  You should only need it if
Packit 47b4ca
         you modified a '.l' file.  You may need the Flex package
Packit 47b4ca
         in order for those modifications to take effect.  You can get
Packit 47b4ca
         Flex from any GNU archive site."
Packit 47b4ca
    rm -f lex.yy.c
Packit 47b4ca
    if test $# -ne 1; then
Packit 47b4ca
        eval LASTARG=\${$#}
Packit 47b4ca
	case $LASTARG in
Packit 47b4ca
	*.l)
Packit 47b4ca
	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
Packit 47b4ca
	    if test -f "$SRCFILE"; then
Packit 47b4ca
	         cp "$SRCFILE" lex.yy.c
Packit 47b4ca
	    fi
Packit 47b4ca
	  ;;
Packit 47b4ca
	esac
Packit 47b4ca
    fi
Packit 47b4ca
    if test ! -f lex.yy.c; then
Packit 47b4ca
	echo 'main() { return 0; }' >lex.yy.c
Packit 47b4ca
    fi
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
  help2man*)
Packit 47b4ca
    echo 1>&2 "\
Packit 47b4ca
WARNING: '$1' is $msg.  You should only need it if
Packit 47b4ca
	 you modified a dependency of a manual page.  You may need the
Packit 47b4ca
	 Help2man package in order for those modifications to take
Packit 47b4ca
	 effect.  You can get Help2man from any GNU archive site."
Packit 47b4ca
Packit 47b4ca
    file=`echo "$*" | sed -n "$sed_output"`
Packit 47b4ca
    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
Packit 47b4ca
    if test -f "$file"; then
Packit 47b4ca
	touch $file
Packit 47b4ca
    else
Packit 47b4ca
	test -z "$file" || exec >$file
Packit 47b4ca
	echo ".ab help2man is required to generate this page"
Packit 47b4ca
	exit $?
Packit 47b4ca
    fi
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
  makeinfo*)
Packit 47b4ca
    echo 1>&2 "\
Packit 47b4ca
WARNING: '$1' is $msg.  You should only need it if
Packit 47b4ca
         you modified a '.texi' or '.texinfo' file, or any other file
Packit 47b4ca
         indirectly affecting the aspect of the manual.  The spurious
Packit 47b4ca
         call might also be the consequence of using a buggy 'make' (AIX,
Packit 47b4ca
         DU, IRIX).  You might want to install the Texinfo package or
Packit 47b4ca
         the GNU make package.  Grab either from any GNU archive site."
Packit 47b4ca
    # The file to touch is that specified with -o ...
Packit 47b4ca
    file=`echo "$*" | sed -n "$sed_output"`
Packit 47b4ca
    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
Packit 47b4ca
    if test -z "$file"; then
Packit 47b4ca
      # ... or it is the one specified with @setfilename ...
Packit 47b4ca
      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
Packit 47b4ca
      file=`sed -n '
Packit 47b4ca
	/^@setfilename/{
Packit 47b4ca
	  s/.* \([^ ]*\) *$/\1/
Packit 47b4ca
	  p
Packit 47b4ca
	  q
Packit 47b4ca
	}' $infile`
Packit 47b4ca
      # ... or it is derived from the source name (dir/f.texi becomes f.info)
Packit 47b4ca
      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
Packit 47b4ca
    fi
Packit 47b4ca
    # If the file does not exist, the user really needs makeinfo;
Packit 47b4ca
    # let's fail without touching anything.
Packit 47b4ca
    test -f $file || exit 1
Packit 47b4ca
    touch $file
Packit 47b4ca
    ;;
Packit 47b4ca
Packit 47b4ca
  *)
Packit 47b4ca
    echo 1>&2 "\
Packit 47b4ca
WARNING: '$1' is needed, and is $msg.
Packit 47b4ca
         You might have modified some files without having the
Packit 47b4ca
         proper tools for further handling them.  Check the 'README' file,
Packit 47b4ca
         it often tells you about the needed prerequisites for installing
Packit 47b4ca
         this package.  You may also peek at any GNU archive site, in case
Packit 47b4ca
         some other package would contain this missing '$1' program."
Packit 47b4ca
    exit 1
Packit 47b4ca
    ;;
Packit 47b4ca
esac
Packit 47b4ca
Packit 47b4ca
exit 0
Packit 47b4ca
Packit 47b4ca
# Local variables:
Packit 47b4ca
# eval: (add-hook 'write-file-hooks 'time-stamp)
Packit 47b4ca
# time-stamp-start: "scriptversion="
Packit 47b4ca
# time-stamp-format: "%:y-%02m-%02d.%02H"
Packit 47b4ca
# time-stamp-time-zone: "UTC"
Packit 47b4ca
# time-stamp-end: "; # UTC"
Packit 47b4ca
# End: