xref: /freebsd/contrib/ntp/sntp/libevent/build-aux/missing (revision e43d33d286a1aa41b6fc6a209f28a18e8cd7437a)
12b15cb3dSCy Schubert#! /bin/sh
2f0574f5cSXin LI# Common wrapper for a few potentially missing GNU programs.
32b15cb3dSCy Schubert
4*2d4e511cSCy Schubertscriptversion=2013-10-28.13; # UTC
52b15cb3dSCy Schubert
6*2d4e511cSCy Schubert# Copyright (C) 1996-2014 Free Software Foundation, Inc.
7f0574f5cSXin LI# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
82b15cb3dSCy Schubert
92b15cb3dSCy Schubert# This program is free software; you can redistribute it and/or modify
102b15cb3dSCy Schubert# it under the terms of the GNU General Public License as published by
112b15cb3dSCy Schubert# the Free Software Foundation; either version 2, or (at your option)
122b15cb3dSCy Schubert# any later version.
132b15cb3dSCy Schubert
142b15cb3dSCy Schubert# This program is distributed in the hope that it will be useful,
152b15cb3dSCy Schubert# but WITHOUT ANY WARRANTY; without even the implied warranty of
162b15cb3dSCy Schubert# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
172b15cb3dSCy Schubert# GNU General Public License for more details.
182b15cb3dSCy Schubert
192b15cb3dSCy Schubert# You should have received a copy of the GNU General Public License
202b15cb3dSCy Schubert# along with this program.  If not, see <http://www.gnu.org/licenses/>.
212b15cb3dSCy Schubert
222b15cb3dSCy Schubert# As a special exception to the GNU General Public License, if you
232b15cb3dSCy Schubert# distribute this file as part of a program that contains a
242b15cb3dSCy Schubert# configuration script generated by Autoconf, you may include it under
252b15cb3dSCy Schubert# the same distribution terms that you use for the rest of that program.
262b15cb3dSCy Schubert
272b15cb3dSCy Schubertif test $# -eq 0; then
28f0574f5cSXin LI  echo 1>&2 "Try '$0 --help' for more information"
292b15cb3dSCy Schubert  exit 1
302b15cb3dSCy Schubertfi
312b15cb3dSCy Schubert
322b15cb3dSCy Schubertcase $1 in
33f0574f5cSXin LI
34f0574f5cSXin LI  --is-lightweight)
35f0574f5cSXin LI    # Used by our autoconf macros to check whether the available missing
36f0574f5cSXin LI    # script is modern enough.
37f0574f5cSXin LI    exit 0
38f0574f5cSXin LI    ;;
39f0574f5cSXin LI
402b15cb3dSCy Schubert  --run)
41f0574f5cSXin LI    # Back-compat with the calling convention used by older automake.
422b15cb3dSCy Schubert    shift
432b15cb3dSCy Schubert    ;;
442b15cb3dSCy Schubert
452b15cb3dSCy Schubert  -h|--h|--he|--hel|--help)
462b15cb3dSCy Schubert    echo "\
472b15cb3dSCy Schubert$0 [OPTION]... PROGRAM [ARGUMENT]...
482b15cb3dSCy Schubert
49f0574f5cSXin LIRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50f0574f5cSXin LIto PROGRAM being missing or too old.
512b15cb3dSCy Schubert
522b15cb3dSCy SchubertOptions:
532b15cb3dSCy Schubert  -h, --help      display this help and exit
542b15cb3dSCy Schubert  -v, --version   output version information and exit
552b15cb3dSCy Schubert
562b15cb3dSCy SchubertSupported PROGRAM values:
57f0574f5cSXin LI  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
58f0574f5cSXin LI  bison     yacc      flex         lex       help2man
592b15cb3dSCy Schubert
60f0574f5cSXin LIVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61f0574f5cSXin LI'g' are ignored when checking the name.
622b15cb3dSCy Schubert
632b15cb3dSCy SchubertSend bug reports to <bug-automake@gnu.org>."
642b15cb3dSCy Schubert    exit $?
652b15cb3dSCy Schubert    ;;
662b15cb3dSCy Schubert
672b15cb3dSCy Schubert  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
682b15cb3dSCy Schubert    echo "missing $scriptversion (GNU Automake)"
692b15cb3dSCy Schubert    exit $?
702b15cb3dSCy Schubert    ;;
712b15cb3dSCy Schubert
722b15cb3dSCy Schubert  -*)
73f0574f5cSXin LI    echo 1>&2 "$0: unknown '$1' option"
74f0574f5cSXin LI    echo 1>&2 "Try '$0 --help' for more information"
752b15cb3dSCy Schubert    exit 1
762b15cb3dSCy Schubert    ;;
772b15cb3dSCy Schubert
782b15cb3dSCy Schubertesac
792b15cb3dSCy Schubert
80f0574f5cSXin LI# Run the given program, remember its exit status.
81f0574f5cSXin LI"$@"; st=$?
82f0574f5cSXin LI
83f0574f5cSXin LI# If it succeeded, we are done.
84f0574f5cSXin LItest $st -eq 0 && exit 0
85f0574f5cSXin LI
86f0574f5cSXin LI# Also exit now if we it failed (or wasn't found), and '--version' was
87f0574f5cSXin LI# passed; such an option is passed most likely to detect whether the
88f0574f5cSXin LI# program is present and works.
89f0574f5cSXin LIcase $2 in --version|--help) exit $st;; esac
90f0574f5cSXin LI
91f0574f5cSXin LI# Exit code 63 means version mismatch.  This often happens when the user
92f0574f5cSXin LI# tries to use an ancient version of a tool on a file that requires a
93f0574f5cSXin LI# minimum version.
94f0574f5cSXin LIif test $st -eq 63; then
95f0574f5cSXin LI  msg="probably too old"
96f0574f5cSXin LIelif test $st -eq 127; then
97f0574f5cSXin LI  # Program was missing.
98f0574f5cSXin LI  msg="missing on your system"
99f0574f5cSXin LIelse
100f0574f5cSXin LI  # Program was found and executed, but failed.  Give up.
101f0574f5cSXin LI  exit $st
102f0574f5cSXin LIfi
103f0574f5cSXin LI
104f0574f5cSXin LIperl_URL=http://www.perl.org/
105f0574f5cSXin LIflex_URL=http://flex.sourceforge.net/
106f0574f5cSXin LIgnu_software_URL=http://www.gnu.org/software
107f0574f5cSXin LI
108f0574f5cSXin LIprogram_details ()
109f0574f5cSXin LI{
110f0574f5cSXin LI  case $1 in
111f0574f5cSXin LI    aclocal|automake)
112f0574f5cSXin LI      echo "The '$1' program is part of the GNU Automake package:"
113f0574f5cSXin LI      echo "<$gnu_software_URL/automake>"
114f0574f5cSXin LI      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115f0574f5cSXin LI      echo "<$gnu_software_URL/autoconf>"
116f0574f5cSXin LI      echo "<$gnu_software_URL/m4/>"
117f0574f5cSXin LI      echo "<$perl_URL>"
118f0574f5cSXin LI      ;;
119f0574f5cSXin LI    autoconf|autom4te|autoheader)
120f0574f5cSXin LI      echo "The '$1' program is part of the GNU Autoconf package:"
121f0574f5cSXin LI      echo "<$gnu_software_URL/autoconf/>"
122f0574f5cSXin LI      echo "It also requires GNU m4 and Perl in order to run:"
123f0574f5cSXin LI      echo "<$gnu_software_URL/m4/>"
124f0574f5cSXin LI      echo "<$perl_URL>"
125f0574f5cSXin LI      ;;
126f0574f5cSXin LI  esac
127f0574f5cSXin LI}
128f0574f5cSXin LI
129f0574f5cSXin LIgive_advice ()
130f0574f5cSXin LI{
131f0574f5cSXin LI  # Normalize program name to check for.
132f0574f5cSXin LI  normalized_program=`echo "$1" | sed '
1332b15cb3dSCy Schubert    s/^gnu-//; t
1342b15cb3dSCy Schubert    s/^gnu//; t
1352b15cb3dSCy Schubert    s/^g//; t'`
1362b15cb3dSCy Schubert
137f0574f5cSXin LI  printf '%s\n' "'$1' is $msg."
1382b15cb3dSCy Schubert
139f0574f5cSXin LI  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140f0574f5cSXin LI  case $normalized_program in
1412b15cb3dSCy Schubert    autoconf*)
142f0574f5cSXin LI      echo "You should only need it if you modified 'configure.ac',"
143f0574f5cSXin LI      echo "or m4 files included by it."
144f0574f5cSXin LI      program_details 'autoconf'
1452b15cb3dSCy Schubert      ;;
1462b15cb3dSCy Schubert    autoheader*)
147f0574f5cSXin LI      echo "You should only need it if you modified 'acconfig.h' or"
148f0574f5cSXin LI      echo "$configure_deps."
149f0574f5cSXin LI      program_details 'autoheader'
1502b15cb3dSCy Schubert      ;;
1512b15cb3dSCy Schubert    automake*)
152f0574f5cSXin LI      echo "You should only need it if you modified 'Makefile.am' or"
153f0574f5cSXin LI      echo "$configure_deps."
154f0574f5cSXin LI      program_details 'automake'
1552b15cb3dSCy Schubert      ;;
156f0574f5cSXin LI    aclocal*)
157f0574f5cSXin LI      echo "You should only need it if you modified 'acinclude.m4' or"
158f0574f5cSXin LI      echo "$configure_deps."
159f0574f5cSXin LI      program_details 'aclocal'
160f0574f5cSXin LI      ;;
1612b15cb3dSCy Schubert   autom4te*)
162f0574f5cSXin LI      echo "You might have modified some maintainer files that require"
163f0574f5cSXin LI      echo "the 'autom4te' program to be rebuilt."
164f0574f5cSXin LI      program_details 'autom4te'
1652b15cb3dSCy Schubert      ;;
1662b15cb3dSCy Schubert    bison*|yacc*)
167f0574f5cSXin LI      echo "You should only need it if you modified a '.y' file."
168f0574f5cSXin LI      echo "You may want to install the GNU Bison package:"
169f0574f5cSXin LI      echo "<$gnu_software_URL/bison/>"
1702b15cb3dSCy Schubert      ;;
1712b15cb3dSCy Schubert    lex*|flex*)
172f0574f5cSXin LI      echo "You should only need it if you modified a '.l' file."
173f0574f5cSXin LI      echo "You may want to install the Fast Lexical Analyzer package:"
174f0574f5cSXin LI      echo "<$flex_URL>"
1752b15cb3dSCy Schubert      ;;
1762b15cb3dSCy Schubert    help2man*)
177f0574f5cSXin LI      echo "You should only need it if you modified a dependency" \
178f0574f5cSXin LI           "of a man page."
179f0574f5cSXin LI      echo "You may want to install the GNU Help2man package:"
180f0574f5cSXin LI      echo "<$gnu_software_URL/help2man/>"
1812b15cb3dSCy Schubert    ;;
1822b15cb3dSCy Schubert    makeinfo*)
183f0574f5cSXin LI      echo "You should only need it if you modified a '.texi' file, or"
184f0574f5cSXin LI      echo "any other file indirectly affecting the aspect of the manual."
185f0574f5cSXin LI      echo "You might want to install the Texinfo package:"
186f0574f5cSXin LI      echo "<$gnu_software_URL/texinfo/>"
187f0574f5cSXin LI      echo "The spurious makeinfo call might also be the consequence of"
188f0574f5cSXin LI      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189f0574f5cSXin LI      echo "want to install GNU make:"
190f0574f5cSXin LI      echo "<$gnu_software_URL/make/>"
1912b15cb3dSCy Schubert      ;;
1922b15cb3dSCy Schubert    *)
193f0574f5cSXin LI      echo "You might have modified some files without having the proper"
194f0574f5cSXin LI      echo "tools for further handling them.  Check the 'README' file, it"
195f0574f5cSXin LI      echo "often tells you about the needed prerequisites for installing"
196f0574f5cSXin LI      echo "this package.  You may also peek at any GNU archive site, in"
197f0574f5cSXin LI      echo "case some other package contains this missing '$1' program."
1982b15cb3dSCy Schubert      ;;
1992b15cb3dSCy Schubert  esac
200f0574f5cSXin LI}
2012b15cb3dSCy Schubert
202f0574f5cSXin LIgive_advice "$1" | sed -e '1s/^/WARNING: /' \
203f0574f5cSXin LI                       -e '2,$s/^/         /' >&2
204f0574f5cSXin LI
205f0574f5cSXin LI# Propagate the correct exit status (expected to be 127 for a program
206f0574f5cSXin LI# not found, 63 for a program that failed due to version mismatch).
207f0574f5cSXin LIexit $st
2082b15cb3dSCy Schubert
2092b15cb3dSCy Schubert# Local variables:
2102b15cb3dSCy Schubert# eval: (add-hook 'write-file-hooks 'time-stamp)
2112b15cb3dSCy Schubert# time-stamp-start: "scriptversion="
2122b15cb3dSCy Schubert# time-stamp-format: "%:y-%02m-%02d.%02H"
213*2d4e511cSCy Schubert# time-stamp-time-zone: "UTC"
2142b15cb3dSCy Schubert# time-stamp-end: "; # UTC"
2152b15cb3dSCy Schubert# End:
216