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