missing
author Ozkan Sezer <sezeroz@gmail.com>
Thu, 18 Oct 2018 11:57:19 +0300
changeset 612 ca95d0e31aec
parent 374 cde07907e374
child 664 b6b714389ea9
permissions -rwxr-xr-x
use less ancient versions of autofoo scripts
slouken@285
     1
#! /bin/sh
slouken@374
     2
# Common wrapper for a few potentially missing GNU programs.
slouken@285
     3
slouken@374
     4
scriptversion=2012-06-26.16; # UTC
slouken@285
     5
slouken@374
     6
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
slouken@374
     7
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
slouken@285
     8
slouken@285
     9
# This program is free software; you can redistribute it and/or modify
slouken@285
    10
# it under the terms of the GNU General Public License as published by
slouken@285
    11
# the Free Software Foundation; either version 2, or (at your option)
slouken@285
    12
# any later version.
slouken@285
    13
slouken@285
    14
# This program is distributed in the hope that it will be useful,
slouken@285
    15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@285
    16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
slouken@285
    17
# GNU General Public License for more details.
slouken@285
    18
slouken@285
    19
# You should have received a copy of the GNU General Public License
slouken@374
    20
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
slouken@285
    21
slouken@285
    22
# As a special exception to the GNU General Public License, if you
slouken@285
    23
# distribute this file as part of a program that contains a
slouken@285
    24
# configuration script generated by Autoconf, you may include it under
slouken@285
    25
# the same distribution terms that you use for the rest of that program.
slouken@285
    26
slouken@285
    27
if test $# -eq 0; then
slouken@374
    28
  echo 1>&2 "Try '$0 --help' for more information"
slouken@285
    29
  exit 1
slouken@285
    30
fi
slouken@285
    31
slouken@374
    32
case $1 in
slouken@285
    33
slouken@374
    34
  --is-lightweight)
slouken@374
    35
    # Used by our autoconf macros to check whether the available missing
slouken@374
    36
    # script is modern enough.
slouken@374
    37
    exit 0
slouken@374
    38
    ;;
slouken@285
    39
slouken@374
    40
  --run)
slouken@374
    41
    # Back-compat with the calling convention used by older automake.
slouken@374
    42
    shift
slouken@374
    43
    ;;
slouken@285
    44
slouken@285
    45
  -h|--h|--he|--hel|--help)
slouken@285
    46
    echo "\
slouken@285
    47
$0 [OPTION]... PROGRAM [ARGUMENT]...
slouken@285
    48
slouken@374
    49
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
slouken@374
    50
to PROGRAM being missing or too old.
slouken@285
    51
slouken@285
    52
Options:
slouken@285
    53
  -h, --help      display this help and exit
slouken@285
    54
  -v, --version   output version information and exit
slouken@285
    55
slouken@285
    56
Supported PROGRAM values:
slouken@374
    57
  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
slouken@374
    58
  bison     yacc      flex         lex       help2man
slouken@374
    59
slouken@374
    60
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
slouken@374
    61
'g' are ignored when checking the name.
slouken@285
    62
slouken@285
    63
Send bug reports to <bug-automake@gnu.org>."
slouken@285
    64
    exit $?
slouken@285
    65
    ;;
slouken@285
    66
slouken@285
    67
  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
slouken@285
    68
    echo "missing $scriptversion (GNU Automake)"
slouken@285
    69
    exit $?
slouken@285
    70
    ;;
slouken@285
    71
slouken@285
    72
  -*)
slouken@374
    73
    echo 1>&2 "$0: unknown '$1' option"
slouken@374
    74
    echo 1>&2 "Try '$0 --help' for more information"
slouken@285
    75
    exit 1
slouken@285
    76
    ;;
slouken@285
    77
slouken@285
    78
esac
slouken@285
    79
slouken@374
    80
# Run the given program, remember its exit status.
slouken@374
    81
"$@"; st=$?
slouken@374
    82
slouken@374
    83
# If it succeeded, we are done.
slouken@374
    84
test $st -eq 0 && exit 0
slouken@374
    85
slouken@374
    86
# Also exit now if we it failed (or wasn't found), and '--version' was
slouken@374
    87
# passed; such an option is passed most likely to detect whether the
slouken@374
    88
# program is present and works.
slouken@374
    89
case $2 in --version|--help) exit $st;; esac
slouken@374
    90
slouken@374
    91
# Exit code 63 means version mismatch.  This often happens when the user
slouken@374
    92
# tries to use an ancient version of a tool on a file that requires a
slouken@374
    93
# minimum version.
slouken@374
    94
if test $st -eq 63; then
slouken@374
    95
  msg="probably too old"
slouken@374
    96
elif test $st -eq 127; then
slouken@374
    97
  # Program was missing.
slouken@374
    98
  msg="missing on your system"
slouken@374
    99
else
slouken@374
   100
  # Program was found and executed, but failed.  Give up.
slouken@374
   101
  exit $st
slouken@374
   102
fi
slouken@374
   103
slouken@374
   104
perl_URL=http://www.perl.org/
slouken@374
   105
flex_URL=http://flex.sourceforge.net/
slouken@374
   106
gnu_software_URL=http://www.gnu.org/software
slouken@374
   107
slouken@374
   108
program_details ()
slouken@374
   109
{
slouken@374
   110
  case $1 in
slouken@374
   111
    aclocal|automake)
slouken@374
   112
      echo "The '$1' program is part of the GNU Automake package:"
slouken@374
   113
      echo "<$gnu_software_URL/automake>"
slouken@374
   114
      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
slouken@374
   115
      echo "<$gnu_software_URL/autoconf>"
slouken@374
   116
      echo "<$gnu_software_URL/m4/>"
slouken@374
   117
      echo "<$perl_URL>"
slouken@374
   118
      ;;
slouken@374
   119
    autoconf|autom4te|autoheader)
slouken@374
   120
      echo "The '$1' program is part of the GNU Autoconf package:"
slouken@374
   121
      echo "<$gnu_software_URL/autoconf/>"
slouken@374
   122
      echo "It also requires GNU m4 and Perl in order to run:"
slouken@374
   123
      echo "<$gnu_software_URL/m4/>"
slouken@374
   124
      echo "<$perl_URL>"
slouken@374
   125
      ;;
slouken@374
   126
  esac
slouken@374
   127
}
slouken@374
   128
slouken@374
   129
give_advice ()
slouken@374
   130
{
slouken@374
   131
  # Normalize program name to check for.
slouken@374
   132
  normalized_program=`echo "$1" | sed '
slouken@374
   133
    s/^gnu-//; t
slouken@374
   134
    s/^gnu//; t
slouken@374
   135
    s/^g//; t'`
slouken@374
   136
slouken@374
   137
  printf '%s\n' "'$1' is $msg."
slouken@374
   138
slouken@374
   139
  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
slouken@374
   140
  case $normalized_program in
slouken@374
   141
    autoconf*)
slouken@374
   142
      echo "You should only need it if you modified 'configure.ac',"
slouken@374
   143
      echo "or m4 files included by it."
slouken@374
   144
      program_details 'autoconf'
slouken@374
   145
      ;;
slouken@374
   146
    autoheader*)
slouken@374
   147
      echo "You should only need it if you modified 'acconfig.h' or"
slouken@374
   148
      echo "$configure_deps."
slouken@374
   149
      program_details 'autoheader'
slouken@374
   150
      ;;
slouken@374
   151
    automake*)
slouken@374
   152
      echo "You should only need it if you modified 'Makefile.am' or"
slouken@374
   153
      echo "$configure_deps."
slouken@374
   154
      program_details 'automake'
slouken@374
   155
      ;;
slouken@374
   156
    aclocal*)
slouken@374
   157
      echo "You should only need it if you modified 'acinclude.m4' or"
slouken@374
   158
      echo "$configure_deps."
slouken@374
   159
      program_details 'aclocal'
slouken@374
   160
      ;;
slouken@374
   161
   autom4te*)
slouken@374
   162
      echo "You might have modified some maintainer files that require"
slouken@374
   163
      echo "the 'automa4te' program to be rebuilt."
slouken@374
   164
      program_details 'autom4te'
slouken@374
   165
      ;;
slouken@374
   166
    bison*|yacc*)
slouken@374
   167
      echo "You should only need it if you modified a '.y' file."
slouken@374
   168
      echo "You may want to install the GNU Bison package:"
slouken@374
   169
      echo "<$gnu_software_URL/bison/>"
slouken@374
   170
      ;;
slouken@374
   171
    lex*|flex*)
slouken@374
   172
      echo "You should only need it if you modified a '.l' file."
slouken@374
   173
      echo "You may want to install the Fast Lexical Analyzer package:"
slouken@374
   174
      echo "<$flex_URL>"
slouken@374
   175
      ;;
slouken@374
   176
    help2man*)
slouken@374
   177
      echo "You should only need it if you modified a dependency" \
slouken@374
   178
           "of a man page."
slouken@374
   179
      echo "You may want to install the GNU Help2man package:"
slouken@374
   180
      echo "<$gnu_software_URL/help2man/>"
slouken@285
   181
    ;;
slouken@374
   182
    makeinfo*)
slouken@374
   183
      echo "You should only need it if you modified a '.texi' file, or"
slouken@374
   184
      echo "any other file indirectly affecting the aspect of the manual."
slouken@374
   185
      echo "You might want to install the Texinfo package:"
slouken@374
   186
      echo "<$gnu_software_URL/texinfo/>"
slouken@374
   187
      echo "The spurious makeinfo call might also be the consequence of"
slouken@374
   188
      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
slouken@374
   189
      echo "want to install GNU make:"
slouken@374
   190
      echo "<$gnu_software_URL/make/>"
slouken@374
   191
      ;;
slouken@374
   192
    *)
slouken@374
   193
      echo "You might have modified some files without having the proper"
slouken@374
   194
      echo "tools for further handling them.  Check the 'README' file, it"
slouken@374
   195
      echo "often tells you about the needed prerequisites for installing"
slouken@374
   196
      echo "this package.  You may also peek at any GNU archive site, in"
slouken@374
   197
      echo "case some other package contains this missing '$1' program."
slouken@374
   198
      ;;
slouken@374
   199
  esac
slouken@374
   200
}
slouken@285
   201
slouken@374
   202
give_advice "$1" | sed -e '1s/^/WARNING: /' \
slouken@374
   203
                       -e '2,$s/^/         /' >&2
slouken@285
   204
slouken@374
   205
# Propagate the correct exit status (expected to be 127 for a program
slouken@374
   206
# not found, 63 for a program that failed due to version mismatch).
slouken@374
   207
exit $st
slouken@285
   208
slouken@285
   209
# Local variables:
slouken@285
   210
# eval: (add-hook 'write-file-hooks 'time-stamp)
slouken@285
   211
# time-stamp-start: "scriptversion="
slouken@285
   212
# time-stamp-format: "%:y-%02m-%02d.%02H"
slouken@374
   213
# time-stamp-time-zone: "UTC"
slouken@374
   214
# time-stamp-end: "; # UTC"
slouken@285
   215
# End: