xref: /freebsd/contrib/ntp/sntp/libevent/build-aux/missing (revision f0574f5cf69e168cc4ea71ebbe5fdec9ec9a3dfe)
12b15cb3dSCy Schubert#! /bin/sh
2*f0574f5cSXin LI# Common wrapper for a few potentially missing GNU programs.
32b15cb3dSCy Schubert
4*f0574f5cSXin LIscriptversion=2013-10-28.13; # UTC
52b15cb3dSCy Schubert
6*f0574f5cSXin LI# Copyright (C) 1996-2014 Free Software Foundation, Inc.
7*f0574f5cSXin 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
28*f0574f5cSXin LI  echo 1>&2 "Try '$0 --help' for more information"
292b15cb3dSCy Schubert  exit 1
302b15cb3dSCy Schubertfi
312b15cb3dSCy Schubert
322b15cb3dSCy Schubertcase $1 in
33*f0574f5cSXin LI
34*f0574f5cSXin LI  --is-lightweight)
35*f0574f5cSXin LI    # Used by our autoconf macros to check whether the available missing
36*f0574f5cSXin LI    # script is modern enough.
37*f0574f5cSXin LI    exit 0
38*f0574f5cSXin LI    ;;
39*f0574f5cSXin LI
402b15cb3dSCy Schubert  --run)
41*f0574f5cSXin 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
49*f0574f5cSXin LIRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50*f0574f5cSXin 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:
57*f0574f5cSXin LI  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
58*f0574f5cSXin LI  bison     yacc      flex         lex       help2man
592b15cb3dSCy Schubert
60*f0574f5cSXin LIVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61*f0574f5cSXin 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  -*)
73*f0574f5cSXin LI    echo 1>&2 "$0: unknown '$1' option"
74*f0574f5cSXin LI    echo 1>&2 "Try '$0 --help' for more information"
752b15cb3dSCy Schubert    exit 1
762b15cb3dSCy Schubert    ;;
772b15cb3dSCy Schubert
782b15cb3dSCy Schubertesac
792b15cb3dSCy Schubert
80*f0574f5cSXin LI# Run the given program, remember its exit status.
81*f0574f5cSXin LI"$@"; st=$?
82*f0574f5cSXin LI
83*f0574f5cSXin LI# If it succeeded, we are done.
84*f0574f5cSXin LItest $st -eq 0 && exit 0
85*f0574f5cSXin LI
86*f0574f5cSXin LI# Also exit now if we it failed (or wasn't found), and '--version' was
87*f0574f5cSXin LI# passed; such an option is passed most likely to detect whether the
88*f0574f5cSXin LI# program is present and works.
89*f0574f5cSXin LIcase $2 in --version|--help) exit $st;; esac
90*f0574f5cSXin LI
91*f0574f5cSXin LI# Exit code 63 means version mismatch.  This often happens when the user
92*f0574f5cSXin LI# tries to use an ancient version of a tool on a file that requires a
93*f0574f5cSXin LI# minimum version.
94*f0574f5cSXin LIif test $st -eq 63; then
95*f0574f5cSXin LI  msg="probably too old"
96*f0574f5cSXin LIelif test $st -eq 127; then
97*f0574f5cSXin LI  # Program was missing.
98*f0574f5cSXin LI  msg="missing on your system"
99*f0574f5cSXin LIelse
100*f0574f5cSXin LI  # Program was found and executed, but failed.  Give up.
101*f0574f5cSXin LI  exit $st
102*f0574f5cSXin LIfi
103*f0574f5cSXin LI
104*f0574f5cSXin LIperl_URL=http://www.perl.org/
105*f0574f5cSXin LIflex_URL=http://flex.sourceforge.net/
106*f0574f5cSXin LIgnu_software_URL=http://www.gnu.org/software
107*f0574f5cSXin LI
108*f0574f5cSXin LIprogram_details ()
109*f0574f5cSXin LI{
110*f0574f5cSXin LI  case $1 in
111*f0574f5cSXin LI    aclocal|automake)
112*f0574f5cSXin LI      echo "The '$1' program is part of the GNU Automake package:"
113*f0574f5cSXin LI      echo "<$gnu_software_URL/automake>"
114*f0574f5cSXin LI      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115*f0574f5cSXin LI      echo "<$gnu_software_URL/autoconf>"
116*f0574f5cSXin LI      echo "<$gnu_software_URL/m4/>"
117*f0574f5cSXin LI      echo "<$perl_URL>"
118*f0574f5cSXin LI      ;;
119*f0574f5cSXin LI    autoconf|autom4te|autoheader)
120*f0574f5cSXin LI      echo "The '$1' program is part of the GNU Autoconf package:"
121*f0574f5cSXin LI      echo "<$gnu_software_URL/autoconf/>"
122*f0574f5cSXin LI      echo "It also requires GNU m4 and Perl in order to run:"
123*f0574f5cSXin LI      echo "<$gnu_software_URL/m4/>"
124*f0574f5cSXin LI      echo "<$perl_URL>"
125*f0574f5cSXin LI      ;;
126*f0574f5cSXin LI  esac
127*f0574f5cSXin LI}
128*f0574f5cSXin LI
129*f0574f5cSXin LIgive_advice ()
130*f0574f5cSXin LI{
131*f0574f5cSXin LI  # Normalize program name to check for.
132*f0574f5cSXin LI  normalized_program=`echo "$1" | sed '
1332b15cb3dSCy Schubert    s/^gnu-//; t
1342b15cb3dSCy Schubert    s/^gnu//; t
1352b15cb3dSCy Schubert    s/^g//; t'`
1362b15cb3dSCy Schubert
137*f0574f5cSXin LI  printf '%s\n' "'$1' is $msg."
1382b15cb3dSCy Schubert
139*f0574f5cSXin LI  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140*f0574f5cSXin LI  case $normalized_program in
1412b15cb3dSCy Schubert    autoconf*)
142*f0574f5cSXin LI      echo "You should only need it if you modified 'configure.ac',"
143*f0574f5cSXin LI      echo "or m4 files included by it."
144*f0574f5cSXin LI      program_details 'autoconf'
1452b15cb3dSCy Schubert      ;;
1462b15cb3dSCy Schubert    autoheader*)
147*f0574f5cSXin LI      echo "You should only need it if you modified 'acconfig.h' or"
148*f0574f5cSXin LI      echo "$configure_deps."
149*f0574f5cSXin LI      program_details 'autoheader'
1502b15cb3dSCy Schubert      ;;
1512b15cb3dSCy Schubert    automake*)
152*f0574f5cSXin LI      echo "You should only need it if you modified 'Makefile.am' or"
153*f0574f5cSXin LI      echo "$configure_deps."
154*f0574f5cSXin LI      program_details 'automake'
1552b15cb3dSCy Schubert      ;;
156*f0574f5cSXin LI    aclocal*)
157*f0574f5cSXin LI      echo "You should only need it if you modified 'acinclude.m4' or"
158*f0574f5cSXin LI      echo "$configure_deps."
159*f0574f5cSXin LI      program_details 'aclocal'
160*f0574f5cSXin LI      ;;
1612b15cb3dSCy Schubert   autom4te*)
162*f0574f5cSXin LI      echo "You might have modified some maintainer files that require"
163*f0574f5cSXin LI      echo "the 'autom4te' program to be rebuilt."
164*f0574f5cSXin LI      program_details 'autom4te'
1652b15cb3dSCy Schubert      ;;
1662b15cb3dSCy Schubert    bison*|yacc*)
167*f0574f5cSXin LI      echo "You should only need it if you modified a '.y' file."
168*f0574f5cSXin LI      echo "You may want to install the GNU Bison package:"
169*f0574f5cSXin LI      echo "<$gnu_software_URL/bison/>"
1702b15cb3dSCy Schubert      ;;
1712b15cb3dSCy Schubert    lex*|flex*)
172*f0574f5cSXin LI      echo "You should only need it if you modified a '.l' file."
173*f0574f5cSXin LI      echo "You may want to install the Fast Lexical Analyzer package:"
174*f0574f5cSXin LI      echo "<$flex_URL>"
1752b15cb3dSCy Schubert      ;;
1762b15cb3dSCy Schubert    help2man*)
177*f0574f5cSXin LI      echo "You should only need it if you modified a dependency" \
178*f0574f5cSXin LI           "of a man page."
179*f0574f5cSXin LI      echo "You may want to install the GNU Help2man package:"
180*f0574f5cSXin LI      echo "<$gnu_software_URL/help2man/>"
1812b15cb3dSCy Schubert    ;;
1822b15cb3dSCy Schubert    makeinfo*)
183*f0574f5cSXin LI      echo "You should only need it if you modified a '.texi' file, or"
184*f0574f5cSXin LI      echo "any other file indirectly affecting the aspect of the manual."
185*f0574f5cSXin LI      echo "You might want to install the Texinfo package:"
186*f0574f5cSXin LI      echo "<$gnu_software_URL/texinfo/>"
187*f0574f5cSXin LI      echo "The spurious makeinfo call might also be the consequence of"
188*f0574f5cSXin LI      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189*f0574f5cSXin LI      echo "want to install GNU make:"
190*f0574f5cSXin LI      echo "<$gnu_software_URL/make/>"
1912b15cb3dSCy Schubert      ;;
1922b15cb3dSCy Schubert    *)
193*f0574f5cSXin LI      echo "You might have modified some files without having the proper"
194*f0574f5cSXin LI      echo "tools for further handling them.  Check the 'README' file, it"
195*f0574f5cSXin LI      echo "often tells you about the needed prerequisites for installing"
196*f0574f5cSXin LI      echo "this package.  You may also peek at any GNU archive site, in"
197*f0574f5cSXin LI      echo "case some other package contains this missing '$1' program."
1982b15cb3dSCy Schubert      ;;
1992b15cb3dSCy Schubert  esac
200*f0574f5cSXin LI}
2012b15cb3dSCy Schubert
202*f0574f5cSXin LIgive_advice "$1" | sed -e '1s/^/WARNING: /' \
203*f0574f5cSXin LI                       -e '2,$s/^/         /' >&2
204*f0574f5cSXin LI
205*f0574f5cSXin LI# Propagate the correct exit status (expected to be 127 for a program
206*f0574f5cSXin LI# not found, 63 for a program that failed due to version mismatch).
207*f0574f5cSXin 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"
2132b15cb3dSCy Schubert# time-stamp-time-zone: "UTC"
2142b15cb3dSCy Schubert# time-stamp-end: "; # UTC"
2152b15cb3dSCy Schubert# End:
216