115fb4814Smrg#! /bin/sh 2cf503b78Smrg# Common wrapper for a few potentially missing GNU programs. 315fb4814Smrg 4f010a93dSmrgscriptversion=2018-03-07.03; # UTC 515fb4814Smrg 6f010a93dSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7cf503b78Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 815fb4814Smrg 915fb4814Smrg# This program is free software; you can redistribute it and/or modify 1015fb4814Smrg# it under the terms of the GNU General Public License as published by 1115fb4814Smrg# the Free Software Foundation; either version 2, or (at your option) 1215fb4814Smrg# any later version. 1315fb4814Smrg 1415fb4814Smrg# This program is distributed in the hope that it will be useful, 1515fb4814Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1615fb4814Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1715fb4814Smrg# GNU General Public License for more details. 1815fb4814Smrg 1915fb4814Smrg# You should have received a copy of the GNU General Public License 20f010a93dSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 2115fb4814Smrg 2215fb4814Smrg# As a special exception to the GNU General Public License, if you 2315fb4814Smrg# distribute this file as part of a program that contains a 2415fb4814Smrg# configuration script generated by Autoconf, you may include it under 2515fb4814Smrg# the same distribution terms that you use for the rest of that program. 2615fb4814Smrg 2715fb4814Smrgif test $# -eq 0; then 28cf503b78Smrg echo 1>&2 "Try '$0 --help' for more information" 2915fb4814Smrg exit 1 3015fb4814Smrgfi 3115fb4814Smrg 32cf503b78Smrgcase $1 in 3315fb4814Smrg 34cf503b78Smrg --is-lightweight) 35cf503b78Smrg # Used by our autoconf macros to check whether the available missing 36cf503b78Smrg # script is modern enough. 37cf503b78Smrg exit 0 38cf503b78Smrg ;; 3915fb4814Smrg 40cf503b78Smrg --run) 41cf503b78Smrg # Back-compat with the calling convention used by older automake. 42cf503b78Smrg shift 43cf503b78Smrg ;; 4415fb4814Smrg 4515fb4814Smrg -h|--h|--he|--hel|--help) 4615fb4814Smrg echo "\ 4715fb4814Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 4815fb4814Smrg 49cf503b78SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50cf503b78Smrgto PROGRAM being missing or too old. 5115fb4814Smrg 5215fb4814SmrgOptions: 5315fb4814Smrg -h, --help display this help and exit 5415fb4814Smrg -v, --version output version information and exit 5515fb4814Smrg 5615fb4814SmrgSupported PROGRAM values: 57cf503b78Smrg aclocal autoconf autoheader autom4te automake makeinfo 58cf503b78Smrg bison yacc flex lex help2man 5915fb4814Smrg 60cf503b78SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61cf503b78Smrg'g' are ignored when checking the name. 62b4d38c65Smrg 6315fb4814SmrgSend bug reports to <bug-automake@gnu.org>." 6415fb4814Smrg exit $? 6515fb4814Smrg ;; 6615fb4814Smrg 6715fb4814Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 6815fb4814Smrg echo "missing $scriptversion (GNU Automake)" 6915fb4814Smrg exit $? 7015fb4814Smrg ;; 7115fb4814Smrg 7215fb4814Smrg -*) 73cf503b78Smrg echo 1>&2 "$0: unknown '$1' option" 74cf503b78Smrg echo 1>&2 "Try '$0 --help' for more information" 7515fb4814Smrg exit 1 7615fb4814Smrg ;; 7715fb4814Smrg 7815fb4814Smrgesac 7915fb4814Smrg 80cf503b78Smrg# Run the given program, remember its exit status. 81cf503b78Smrg"$@"; st=$? 82cf503b78Smrg 83cf503b78Smrg# If it succeeded, we are done. 84cf503b78Smrgtest $st -eq 0 && exit 0 85cf503b78Smrg 86cf503b78Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87cf503b78Smrg# passed; such an option is passed most likely to detect whether the 88cf503b78Smrg# program is present and works. 89cf503b78Smrgcase $2 in --version|--help) exit $st;; esac 90cf503b78Smrg 91cf503b78Smrg# Exit code 63 means version mismatch. This often happens when the user 92cf503b78Smrg# tries to use an ancient version of a tool on a file that requires a 93cf503b78Smrg# minimum version. 94cf503b78Smrgif test $st -eq 63; then 95cf503b78Smrg msg="probably too old" 96cf503b78Smrgelif test $st -eq 127; then 97cf503b78Smrg # Program was missing. 98cf503b78Smrg msg="missing on your system" 99cf503b78Smrgelse 100cf503b78Smrg # Program was found and executed, but failed. Give up. 101cf503b78Smrg exit $st 102cf503b78Smrgfi 10315fb4814Smrg 104f010a93dSmrgperl_URL=https://www.perl.org/ 105f010a93dSmrgflex_URL=https://github.com/westes/flex 106f010a93dSmrggnu_software_URL=https://www.gnu.org/software 107cf503b78Smrg 108cf503b78Smrgprogram_details () 109cf503b78Smrg{ 110cf503b78Smrg case $1 in 111cf503b78Smrg aclocal|automake) 112cf503b78Smrg echo "The '$1' program is part of the GNU Automake package:" 113cf503b78Smrg echo "<$gnu_software_URL/automake>" 114cf503b78Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115cf503b78Smrg echo "<$gnu_software_URL/autoconf>" 116cf503b78Smrg echo "<$gnu_software_URL/m4/>" 117cf503b78Smrg echo "<$perl_URL>" 118cf503b78Smrg ;; 119cf503b78Smrg autoconf|autom4te|autoheader) 120cf503b78Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121cf503b78Smrg echo "<$gnu_software_URL/autoconf/>" 122cf503b78Smrg echo "It also requires GNU m4 and Perl in order to run:" 123cf503b78Smrg echo "<$gnu_software_URL/m4/>" 124cf503b78Smrg echo "<$perl_URL>" 125cf503b78Smrg ;; 126cf503b78Smrg esac 127cf503b78Smrg} 128cf503b78Smrg 129cf503b78Smrggive_advice () 130cf503b78Smrg{ 131cf503b78Smrg # Normalize program name to check for. 132cf503b78Smrg normalized_program=`echo "$1" | sed ' 133cf503b78Smrg s/^gnu-//; t 134cf503b78Smrg s/^gnu//; t 135cf503b78Smrg s/^g//; t'` 136cf503b78Smrg 137cf503b78Smrg printf '%s\n' "'$1' is $msg." 138cf503b78Smrg 139cf503b78Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140cf503b78Smrg case $normalized_program in 141cf503b78Smrg autoconf*) 142cf503b78Smrg echo "You should only need it if you modified 'configure.ac'," 143cf503b78Smrg echo "or m4 files included by it." 144cf503b78Smrg program_details 'autoconf' 145cf503b78Smrg ;; 146cf503b78Smrg autoheader*) 147cf503b78Smrg echo "You should only need it if you modified 'acconfig.h' or" 148cf503b78Smrg echo "$configure_deps." 149cf503b78Smrg program_details 'autoheader' 150cf503b78Smrg ;; 151cf503b78Smrg automake*) 152cf503b78Smrg echo "You should only need it if you modified 'Makefile.am' or" 153cf503b78Smrg echo "$configure_deps." 154cf503b78Smrg program_details 'automake' 155cf503b78Smrg ;; 156cf503b78Smrg aclocal*) 157cf503b78Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158cf503b78Smrg echo "$configure_deps." 159cf503b78Smrg program_details 'aclocal' 160cf503b78Smrg ;; 161cf503b78Smrg autom4te*) 162cf503b78Smrg echo "You might have modified some maintainer files that require" 163f010a93dSmrg echo "the 'autom4te' program to be rebuilt." 164cf503b78Smrg program_details 'autom4te' 165cf503b78Smrg ;; 166cf503b78Smrg bison*|yacc*) 167cf503b78Smrg echo "You should only need it if you modified a '.y' file." 168cf503b78Smrg echo "You may want to install the GNU Bison package:" 169cf503b78Smrg echo "<$gnu_software_URL/bison/>" 170cf503b78Smrg ;; 171cf503b78Smrg lex*|flex*) 172cf503b78Smrg echo "You should only need it if you modified a '.l' file." 173cf503b78Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174cf503b78Smrg echo "<$flex_URL>" 175cf503b78Smrg ;; 176cf503b78Smrg help2man*) 177cf503b78Smrg echo "You should only need it if you modified a dependency" \ 178cf503b78Smrg "of a man page." 179cf503b78Smrg echo "You may want to install the GNU Help2man package:" 180cf503b78Smrg echo "<$gnu_software_URL/help2man/>" 181cf503b78Smrg ;; 182cf503b78Smrg makeinfo*) 183cf503b78Smrg echo "You should only need it if you modified a '.texi' file, or" 184cf503b78Smrg echo "any other file indirectly affecting the aspect of the manual." 185cf503b78Smrg echo "You might want to install the Texinfo package:" 186cf503b78Smrg echo "<$gnu_software_URL/texinfo/>" 187cf503b78Smrg echo "The spurious makeinfo call might also be the consequence of" 188cf503b78Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189cf503b78Smrg echo "want to install GNU make:" 190cf503b78Smrg echo "<$gnu_software_URL/make/>" 191cf503b78Smrg ;; 192cf503b78Smrg *) 193cf503b78Smrg echo "You might have modified some files without having the proper" 194cf503b78Smrg echo "tools for further handling them. Check the 'README' file, it" 195cf503b78Smrg echo "often tells you about the needed prerequisites for installing" 196cf503b78Smrg echo "this package. You may also peek at any GNU archive site, in" 197cf503b78Smrg echo "case some other package contains this missing '$1' program." 198cf503b78Smrg ;; 199cf503b78Smrg esac 200cf503b78Smrg} 201cf503b78Smrg 202cf503b78Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203cf503b78Smrg -e '2,$s/^/ /' >&2 204cf503b78Smrg 205cf503b78Smrg# Propagate the correct exit status (expected to be 127 for a program 206cf503b78Smrg# not found, 63 for a program that failed due to version mismatch). 207cf503b78Smrgexit $st 20815fb4814Smrg 20915fb4814Smrg# Local variables: 210f010a93dSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 21115fb4814Smrg# time-stamp-start: "scriptversion=" 21215fb4814Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213f010a93dSmrg# time-stamp-time-zone: "UTC0" 214b4d38c65Smrg# time-stamp-end: "; # UTC" 21515fb4814Smrg# End: 216