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