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