11fb077a1Smrg#! /bin/sh 2ae51dfb6Smrg# Common wrapper for a few potentially missing GNU programs. 31fb077a1Smrg 4ebcdf611Smrgscriptversion=2018-03-07.03; # UTC 51fb077a1Smrg 6ebcdf611Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7ae51dfb6Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 81fb077a1Smrg 91fb077a1Smrg# This program is free software; you can redistribute it and/or modify 101fb077a1Smrg# it under the terms of the GNU General Public License as published by 111fb077a1Smrg# the Free Software Foundation; either version 2, or (at your option) 121fb077a1Smrg# any later version. 131fb077a1Smrg 141fb077a1Smrg# This program is distributed in the hope that it will be useful, 151fb077a1Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 161fb077a1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 171fb077a1Smrg# GNU General Public License for more details. 181fb077a1Smrg 191fb077a1Smrg# You should have received a copy of the GNU General Public License 20ebcdf611Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 211fb077a1Smrg 221fb077a1Smrg# As a special exception to the GNU General Public License, if you 231fb077a1Smrg# distribute this file as part of a program that contains a 241fb077a1Smrg# configuration script generated by Autoconf, you may include it under 251fb077a1Smrg# the same distribution terms that you use for the rest of that program. 261fb077a1Smrg 271fb077a1Smrgif test $# -eq 0; then 28ae51dfb6Smrg echo 1>&2 "Try '$0 --help' for more information" 291fb077a1Smrg exit 1 301fb077a1Smrgfi 311fb077a1Smrg 32ae51dfb6Smrgcase $1 in 331fb077a1Smrg 34ae51dfb6Smrg --is-lightweight) 35ae51dfb6Smrg # Used by our autoconf macros to check whether the available missing 36ae51dfb6Smrg # script is modern enough. 37ae51dfb6Smrg exit 0 38ae51dfb6Smrg ;; 391fb077a1Smrg 40ae51dfb6Smrg --run) 41ae51dfb6Smrg # Back-compat with the calling convention used by older automake. 42ae51dfb6Smrg shift 43ae51dfb6Smrg ;; 441fb077a1Smrg 451fb077a1Smrg -h|--h|--he|--hel|--help) 461fb077a1Smrg echo "\ 471fb077a1Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 481fb077a1Smrg 49ae51dfb6SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50ae51dfb6Smrgto PROGRAM being missing or too old. 511fb077a1Smrg 521fb077a1SmrgOptions: 531fb077a1Smrg -h, --help display this help and exit 541fb077a1Smrg -v, --version output version information and exit 551fb077a1Smrg 561fb077a1SmrgSupported PROGRAM values: 57ae51dfb6Smrg aclocal autoconf autoheader autom4te automake makeinfo 58ae51dfb6Smrg bison yacc flex lex help2man 591fb077a1Smrg 60ae51dfb6SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61ae51dfb6Smrg'g' are ignored when checking the name. 62a5a92c01Smrg 631fb077a1SmrgSend bug reports to <bug-automake@gnu.org>." 641fb077a1Smrg exit $? 651fb077a1Smrg ;; 661fb077a1Smrg 671fb077a1Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 681fb077a1Smrg echo "missing $scriptversion (GNU Automake)" 691fb077a1Smrg exit $? 701fb077a1Smrg ;; 711fb077a1Smrg 721fb077a1Smrg -*) 73ae51dfb6Smrg echo 1>&2 "$0: unknown '$1' option" 74ae51dfb6Smrg echo 1>&2 "Try '$0 --help' for more information" 751fb077a1Smrg exit 1 761fb077a1Smrg ;; 771fb077a1Smrg 781fb077a1Smrgesac 791fb077a1Smrg 80ae51dfb6Smrg# Run the given program, remember its exit status. 81ae51dfb6Smrg"$@"; st=$? 82ae51dfb6Smrg 83ae51dfb6Smrg# If it succeeded, we are done. 84ae51dfb6Smrgtest $st -eq 0 && exit 0 85ae51dfb6Smrg 86ae51dfb6Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87ae51dfb6Smrg# passed; such an option is passed most likely to detect whether the 88ae51dfb6Smrg# program is present and works. 89ae51dfb6Smrgcase $2 in --version|--help) exit $st;; esac 90ae51dfb6Smrg 91ae51dfb6Smrg# Exit code 63 means version mismatch. This often happens when the user 92ae51dfb6Smrg# tries to use an ancient version of a tool on a file that requires a 93ae51dfb6Smrg# minimum version. 94ae51dfb6Smrgif test $st -eq 63; then 95ae51dfb6Smrg msg="probably too old" 96ae51dfb6Smrgelif test $st -eq 127; then 97ae51dfb6Smrg # Program was missing. 98ae51dfb6Smrg msg="missing on your system" 99ae51dfb6Smrgelse 100ae51dfb6Smrg # Program was found and executed, but failed. Give up. 101ae51dfb6Smrg exit $st 102ae51dfb6Smrgfi 1031fb077a1Smrg 104ebcdf611Smrgperl_URL=https://www.perl.org/ 105ebcdf611Smrgflex_URL=https://github.com/westes/flex 106ebcdf611Smrggnu_software_URL=https://www.gnu.org/software 107ae51dfb6Smrg 108ae51dfb6Smrgprogram_details () 109ae51dfb6Smrg{ 110ae51dfb6Smrg case $1 in 111ae51dfb6Smrg aclocal|automake) 112ae51dfb6Smrg echo "The '$1' program is part of the GNU Automake package:" 113ae51dfb6Smrg echo "<$gnu_software_URL/automake>" 114ae51dfb6Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115ae51dfb6Smrg echo "<$gnu_software_URL/autoconf>" 116ae51dfb6Smrg echo "<$gnu_software_URL/m4/>" 117ae51dfb6Smrg echo "<$perl_URL>" 118ae51dfb6Smrg ;; 119ae51dfb6Smrg autoconf|autom4te|autoheader) 120ae51dfb6Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121ae51dfb6Smrg echo "<$gnu_software_URL/autoconf/>" 122ae51dfb6Smrg echo "It also requires GNU m4 and Perl in order to run:" 123ae51dfb6Smrg echo "<$gnu_software_URL/m4/>" 124ae51dfb6Smrg echo "<$perl_URL>" 125ae51dfb6Smrg ;; 126ae51dfb6Smrg esac 127ae51dfb6Smrg} 128ae51dfb6Smrg 129ae51dfb6Smrggive_advice () 130ae51dfb6Smrg{ 131ae51dfb6Smrg # Normalize program name to check for. 132ae51dfb6Smrg normalized_program=`echo "$1" | sed ' 133ae51dfb6Smrg s/^gnu-//; t 134ae51dfb6Smrg s/^gnu//; t 135ae51dfb6Smrg s/^g//; t'` 136ae51dfb6Smrg 137ae51dfb6Smrg printf '%s\n' "'$1' is $msg." 138ae51dfb6Smrg 139ae51dfb6Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140ae51dfb6Smrg case $normalized_program in 141ae51dfb6Smrg autoconf*) 142ae51dfb6Smrg echo "You should only need it if you modified 'configure.ac'," 143ae51dfb6Smrg echo "or m4 files included by it." 144ae51dfb6Smrg program_details 'autoconf' 145ae51dfb6Smrg ;; 146ae51dfb6Smrg autoheader*) 147ae51dfb6Smrg echo "You should only need it if you modified 'acconfig.h' or" 148ae51dfb6Smrg echo "$configure_deps." 149ae51dfb6Smrg program_details 'autoheader' 150ae51dfb6Smrg ;; 151ae51dfb6Smrg automake*) 152ae51dfb6Smrg echo "You should only need it if you modified 'Makefile.am' or" 153ae51dfb6Smrg echo "$configure_deps." 154ae51dfb6Smrg program_details 'automake' 155ae51dfb6Smrg ;; 156ae51dfb6Smrg aclocal*) 157ae51dfb6Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158ae51dfb6Smrg echo "$configure_deps." 159ae51dfb6Smrg program_details 'aclocal' 160ae51dfb6Smrg ;; 161ae51dfb6Smrg autom4te*) 162ae51dfb6Smrg echo "You might have modified some maintainer files that require" 163ae51dfb6Smrg echo "the 'autom4te' program to be rebuilt." 164ae51dfb6Smrg program_details 'autom4te' 165ae51dfb6Smrg ;; 166ae51dfb6Smrg bison*|yacc*) 167ae51dfb6Smrg echo "You should only need it if you modified a '.y' file." 168ae51dfb6Smrg echo "You may want to install the GNU Bison package:" 169ae51dfb6Smrg echo "<$gnu_software_URL/bison/>" 170ae51dfb6Smrg ;; 171ae51dfb6Smrg lex*|flex*) 172ae51dfb6Smrg echo "You should only need it if you modified a '.l' file." 173ae51dfb6Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174ae51dfb6Smrg echo "<$flex_URL>" 175ae51dfb6Smrg ;; 176ae51dfb6Smrg help2man*) 177ae51dfb6Smrg echo "You should only need it if you modified a dependency" \ 178ae51dfb6Smrg "of a man page." 179ae51dfb6Smrg echo "You may want to install the GNU Help2man package:" 180ae51dfb6Smrg echo "<$gnu_software_URL/help2man/>" 181ae51dfb6Smrg ;; 182ae51dfb6Smrg makeinfo*) 183ae51dfb6Smrg echo "You should only need it if you modified a '.texi' file, or" 184ae51dfb6Smrg echo "any other file indirectly affecting the aspect of the manual." 185ae51dfb6Smrg echo "You might want to install the Texinfo package:" 186ae51dfb6Smrg echo "<$gnu_software_URL/texinfo/>" 187ae51dfb6Smrg echo "The spurious makeinfo call might also be the consequence of" 188ae51dfb6Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189ae51dfb6Smrg echo "want to install GNU make:" 190ae51dfb6Smrg echo "<$gnu_software_URL/make/>" 191ae51dfb6Smrg ;; 192ae51dfb6Smrg *) 193ae51dfb6Smrg echo "You might have modified some files without having the proper" 194ae51dfb6Smrg echo "tools for further handling them. Check the 'README' file, it" 195ae51dfb6Smrg echo "often tells you about the needed prerequisites for installing" 196ae51dfb6Smrg echo "this package. You may also peek at any GNU archive site, in" 197ae51dfb6Smrg echo "case some other package contains this missing '$1' program." 198ae51dfb6Smrg ;; 199ae51dfb6Smrg esac 200ae51dfb6Smrg} 201ae51dfb6Smrg 202ae51dfb6Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203ae51dfb6Smrg -e '2,$s/^/ /' >&2 204ae51dfb6Smrg 205ae51dfb6Smrg# Propagate the correct exit status (expected to be 127 for a program 206ae51dfb6Smrg# not found, 63 for a program that failed due to version mismatch). 207ae51dfb6Smrgexit $st 2081fb077a1Smrg 2091fb077a1Smrg# Local variables: 210ebcdf611Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 2111fb077a1Smrg# time-stamp-start: "scriptversion=" 2121fb077a1Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213ebcdf611Smrg# time-stamp-time-zone: "UTC0" 214a5a92c01Smrg# time-stamp-end: "; # UTC" 2151fb077a1Smrg# End: 216