1159b3361Sopenharmony_ci#! /bin/sh 2159b3361Sopenharmony_ci# Common wrapper for a few potentially missing GNU programs. 3159b3361Sopenharmony_ci 4159b3361Sopenharmony_ciscriptversion=2018-03-07.03; # UTC 5159b3361Sopenharmony_ci 6159b3361Sopenharmony_ci# Copyright (C) 1996-2020 Free Software Foundation, Inc. 7159b3361Sopenharmony_ci# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8159b3361Sopenharmony_ci 9159b3361Sopenharmony_ci# This program is free software; you can redistribute it and/or modify 10159b3361Sopenharmony_ci# it under the terms of the GNU General Public License as published by 11159b3361Sopenharmony_ci# the Free Software Foundation; either version 2, or (at your option) 12159b3361Sopenharmony_ci# any later version. 13159b3361Sopenharmony_ci 14159b3361Sopenharmony_ci# This program is distributed in the hope that it will be useful, 15159b3361Sopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of 16159b3361Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17159b3361Sopenharmony_ci# GNU General Public License for more details. 18159b3361Sopenharmony_ci 19159b3361Sopenharmony_ci# You should have received a copy of the GNU General Public License 20159b3361Sopenharmony_ci# along with this program. If not, see <https://www.gnu.org/licenses/>. 21159b3361Sopenharmony_ci 22159b3361Sopenharmony_ci# As a special exception to the GNU General Public License, if you 23159b3361Sopenharmony_ci# distribute this file as part of a program that contains a 24159b3361Sopenharmony_ci# configuration script generated by Autoconf, you may include it under 25159b3361Sopenharmony_ci# the same distribution terms that you use for the rest of that program. 26159b3361Sopenharmony_ci 27159b3361Sopenharmony_ciif test $# -eq 0; then 28159b3361Sopenharmony_ci echo 1>&2 "Try '$0 --help' for more information" 29159b3361Sopenharmony_ci exit 1 30159b3361Sopenharmony_cifi 31159b3361Sopenharmony_ci 32159b3361Sopenharmony_cicase $1 in 33159b3361Sopenharmony_ci 34159b3361Sopenharmony_ci --is-lightweight) 35159b3361Sopenharmony_ci # Used by our autoconf macros to check whether the available missing 36159b3361Sopenharmony_ci # script is modern enough. 37159b3361Sopenharmony_ci exit 0 38159b3361Sopenharmony_ci ;; 39159b3361Sopenharmony_ci 40159b3361Sopenharmony_ci --run) 41159b3361Sopenharmony_ci # Back-compat with the calling convention used by older automake. 42159b3361Sopenharmony_ci shift 43159b3361Sopenharmony_ci ;; 44159b3361Sopenharmony_ci 45159b3361Sopenharmony_ci -h|--h|--he|--hel|--help) 46159b3361Sopenharmony_ci echo "\ 47159b3361Sopenharmony_ci$0 [OPTION]... PROGRAM [ARGUMENT]... 48159b3361Sopenharmony_ci 49159b3361Sopenharmony_ciRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50159b3361Sopenharmony_cito PROGRAM being missing or too old. 51159b3361Sopenharmony_ci 52159b3361Sopenharmony_ciOptions: 53159b3361Sopenharmony_ci -h, --help display this help and exit 54159b3361Sopenharmony_ci -v, --version output version information and exit 55159b3361Sopenharmony_ci 56159b3361Sopenharmony_ciSupported PROGRAM values: 57159b3361Sopenharmony_ci aclocal autoconf autoheader autom4te automake makeinfo 58159b3361Sopenharmony_ci bison yacc flex lex help2man 59159b3361Sopenharmony_ci 60159b3361Sopenharmony_ciVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61159b3361Sopenharmony_ci'g' are ignored when checking the name. 62159b3361Sopenharmony_ci 63159b3361Sopenharmony_ciSend bug reports to <bug-automake@gnu.org>." 64159b3361Sopenharmony_ci exit $? 65159b3361Sopenharmony_ci ;; 66159b3361Sopenharmony_ci 67159b3361Sopenharmony_ci -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68159b3361Sopenharmony_ci echo "missing $scriptversion (GNU Automake)" 69159b3361Sopenharmony_ci exit $? 70159b3361Sopenharmony_ci ;; 71159b3361Sopenharmony_ci 72159b3361Sopenharmony_ci -*) 73159b3361Sopenharmony_ci echo 1>&2 "$0: unknown '$1' option" 74159b3361Sopenharmony_ci echo 1>&2 "Try '$0 --help' for more information" 75159b3361Sopenharmony_ci exit 1 76159b3361Sopenharmony_ci ;; 77159b3361Sopenharmony_ci 78159b3361Sopenharmony_ciesac 79159b3361Sopenharmony_ci 80159b3361Sopenharmony_ci# Run the given program, remember its exit status. 81159b3361Sopenharmony_ci"$@"; st=$? 82159b3361Sopenharmony_ci 83159b3361Sopenharmony_ci# If it succeeded, we are done. 84159b3361Sopenharmony_citest $st -eq 0 && exit 0 85159b3361Sopenharmony_ci 86159b3361Sopenharmony_ci# Also exit now if we it failed (or wasn't found), and '--version' was 87159b3361Sopenharmony_ci# passed; such an option is passed most likely to detect whether the 88159b3361Sopenharmony_ci# program is present and works. 89159b3361Sopenharmony_cicase $2 in --version|--help) exit $st;; esac 90159b3361Sopenharmony_ci 91159b3361Sopenharmony_ci# Exit code 63 means version mismatch. This often happens when the user 92159b3361Sopenharmony_ci# tries to use an ancient version of a tool on a file that requires a 93159b3361Sopenharmony_ci# minimum version. 94159b3361Sopenharmony_ciif test $st -eq 63; then 95159b3361Sopenharmony_ci msg="probably too old" 96159b3361Sopenharmony_cielif test $st -eq 127; then 97159b3361Sopenharmony_ci # Program was missing. 98159b3361Sopenharmony_ci msg="missing on your system" 99159b3361Sopenharmony_cielse 100159b3361Sopenharmony_ci # Program was found and executed, but failed. Give up. 101159b3361Sopenharmony_ci exit $st 102159b3361Sopenharmony_cifi 103159b3361Sopenharmony_ci 104159b3361Sopenharmony_ciperl_URL=https://www.perl.org/ 105159b3361Sopenharmony_ciflex_URL=https://github.com/westes/flex 106159b3361Sopenharmony_cignu_software_URL=https://www.gnu.org/software 107159b3361Sopenharmony_ci 108159b3361Sopenharmony_ciprogram_details () 109159b3361Sopenharmony_ci{ 110159b3361Sopenharmony_ci case $1 in 111159b3361Sopenharmony_ci aclocal|automake) 112159b3361Sopenharmony_ci echo "The '$1' program is part of the GNU Automake package:" 113159b3361Sopenharmony_ci echo "<$gnu_software_URL/automake>" 114159b3361Sopenharmony_ci echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115159b3361Sopenharmony_ci echo "<$gnu_software_URL/autoconf>" 116159b3361Sopenharmony_ci echo "<$gnu_software_URL/m4/>" 117159b3361Sopenharmony_ci echo "<$perl_URL>" 118159b3361Sopenharmony_ci ;; 119159b3361Sopenharmony_ci autoconf|autom4te|autoheader) 120159b3361Sopenharmony_ci echo "The '$1' program is part of the GNU Autoconf package:" 121159b3361Sopenharmony_ci echo "<$gnu_software_URL/autoconf/>" 122159b3361Sopenharmony_ci echo "It also requires GNU m4 and Perl in order to run:" 123159b3361Sopenharmony_ci echo "<$gnu_software_URL/m4/>" 124159b3361Sopenharmony_ci echo "<$perl_URL>" 125159b3361Sopenharmony_ci ;; 126159b3361Sopenharmony_ci esac 127159b3361Sopenharmony_ci} 128159b3361Sopenharmony_ci 129159b3361Sopenharmony_cigive_advice () 130159b3361Sopenharmony_ci{ 131159b3361Sopenharmony_ci # Normalize program name to check for. 132159b3361Sopenharmony_ci normalized_program=`echo "$1" | sed ' 133159b3361Sopenharmony_ci s/^gnu-//; t 134159b3361Sopenharmony_ci s/^gnu//; t 135159b3361Sopenharmony_ci s/^g//; t'` 136159b3361Sopenharmony_ci 137159b3361Sopenharmony_ci printf '%s\n' "'$1' is $msg." 138159b3361Sopenharmony_ci 139159b3361Sopenharmony_ci configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140159b3361Sopenharmony_ci case $normalized_program in 141159b3361Sopenharmony_ci autoconf*) 142159b3361Sopenharmony_ci echo "You should only need it if you modified 'configure.ac'," 143159b3361Sopenharmony_ci echo "or m4 files included by it." 144159b3361Sopenharmony_ci program_details 'autoconf' 145159b3361Sopenharmony_ci ;; 146159b3361Sopenharmony_ci autoheader*) 147159b3361Sopenharmony_ci echo "You should only need it if you modified 'acconfig.h' or" 148159b3361Sopenharmony_ci echo "$configure_deps." 149159b3361Sopenharmony_ci program_details 'autoheader' 150159b3361Sopenharmony_ci ;; 151159b3361Sopenharmony_ci automake*) 152159b3361Sopenharmony_ci echo "You should only need it if you modified 'Makefile.am' or" 153159b3361Sopenharmony_ci echo "$configure_deps." 154159b3361Sopenharmony_ci program_details 'automake' 155159b3361Sopenharmony_ci ;; 156159b3361Sopenharmony_ci aclocal*) 157159b3361Sopenharmony_ci echo "You should only need it if you modified 'acinclude.m4' or" 158159b3361Sopenharmony_ci echo "$configure_deps." 159159b3361Sopenharmony_ci program_details 'aclocal' 160159b3361Sopenharmony_ci ;; 161159b3361Sopenharmony_ci autom4te*) 162159b3361Sopenharmony_ci echo "You might have modified some maintainer files that require" 163159b3361Sopenharmony_ci echo "the 'autom4te' program to be rebuilt." 164159b3361Sopenharmony_ci program_details 'autom4te' 165159b3361Sopenharmony_ci ;; 166159b3361Sopenharmony_ci bison*|yacc*) 167159b3361Sopenharmony_ci echo "You should only need it if you modified a '.y' file." 168159b3361Sopenharmony_ci echo "You may want to install the GNU Bison package:" 169159b3361Sopenharmony_ci echo "<$gnu_software_URL/bison/>" 170159b3361Sopenharmony_ci ;; 171159b3361Sopenharmony_ci lex*|flex*) 172159b3361Sopenharmony_ci echo "You should only need it if you modified a '.l' file." 173159b3361Sopenharmony_ci echo "You may want to install the Fast Lexical Analyzer package:" 174159b3361Sopenharmony_ci echo "<$flex_URL>" 175159b3361Sopenharmony_ci ;; 176159b3361Sopenharmony_ci help2man*) 177159b3361Sopenharmony_ci echo "You should only need it if you modified a dependency" \ 178159b3361Sopenharmony_ci "of a man page." 179159b3361Sopenharmony_ci echo "You may want to install the GNU Help2man package:" 180159b3361Sopenharmony_ci echo "<$gnu_software_URL/help2man/>" 181159b3361Sopenharmony_ci ;; 182159b3361Sopenharmony_ci makeinfo*) 183159b3361Sopenharmony_ci echo "You should only need it if you modified a '.texi' file, or" 184159b3361Sopenharmony_ci echo "any other file indirectly affecting the aspect of the manual." 185159b3361Sopenharmony_ci echo "You might want to install the Texinfo package:" 186159b3361Sopenharmony_ci echo "<$gnu_software_URL/texinfo/>" 187159b3361Sopenharmony_ci echo "The spurious makeinfo call might also be the consequence of" 188159b3361Sopenharmony_ci echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189159b3361Sopenharmony_ci echo "want to install GNU make:" 190159b3361Sopenharmony_ci echo "<$gnu_software_URL/make/>" 191159b3361Sopenharmony_ci ;; 192159b3361Sopenharmony_ci *) 193159b3361Sopenharmony_ci echo "You might have modified some files without having the proper" 194159b3361Sopenharmony_ci echo "tools for further handling them. Check the 'README' file, it" 195159b3361Sopenharmony_ci echo "often tells you about the needed prerequisites for installing" 196159b3361Sopenharmony_ci echo "this package. You may also peek at any GNU archive site, in" 197159b3361Sopenharmony_ci echo "case some other package contains this missing '$1' program." 198159b3361Sopenharmony_ci ;; 199159b3361Sopenharmony_ci esac 200159b3361Sopenharmony_ci} 201159b3361Sopenharmony_ci 202159b3361Sopenharmony_cigive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203159b3361Sopenharmony_ci -e '2,$s/^/ /' >&2 204159b3361Sopenharmony_ci 205159b3361Sopenharmony_ci# Propagate the correct exit status (expected to be 127 for a program 206159b3361Sopenharmony_ci# not found, 63 for a program that failed due to version mismatch). 207159b3361Sopenharmony_ciexit $st 208159b3361Sopenharmony_ci 209159b3361Sopenharmony_ci# Local variables: 210159b3361Sopenharmony_ci# eval: (add-hook 'before-save-hook 'time-stamp) 211159b3361Sopenharmony_ci# time-stamp-start: "scriptversion=" 212159b3361Sopenharmony_ci# time-stamp-format: "%:y-%02m-%02d.%02H" 213159b3361Sopenharmony_ci# time-stamp-time-zone: "UTC0" 214159b3361Sopenharmony_ci# time-stamp-end: "; # UTC" 215159b3361Sopenharmony_ci# End: 216