18ae04fa6Smrg#! /bin/sh 280f56f3aSmrg# Common wrapper for a few potentially missing GNU programs. 38ae04fa6Smrg 4138a9f8aSmrgscriptversion=2018-03-07.03; # UTC 58ae04fa6Smrg 6138a9f8aSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 780f56f3aSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 88ae04fa6Smrg 98ae04fa6Smrg# This program is free software; you can redistribute it and/or modify 108ae04fa6Smrg# it under the terms of the GNU General Public License as published by 118ae04fa6Smrg# the Free Software Foundation; either version 2, or (at your option) 128ae04fa6Smrg# any later version. 138ae04fa6Smrg 148ae04fa6Smrg# This program is distributed in the hope that it will be useful, 158ae04fa6Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 168ae04fa6Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 178ae04fa6Smrg# GNU General Public License for more details. 188ae04fa6Smrg 198ae04fa6Smrg# You should have received a copy of the GNU General Public License 20138a9f8aSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 218ae04fa6Smrg 228ae04fa6Smrg# As a special exception to the GNU General Public License, if you 238ae04fa6Smrg# distribute this file as part of a program that contains a 248ae04fa6Smrg# configuration script generated by Autoconf, you may include it under 258ae04fa6Smrg# the same distribution terms that you use for the rest of that program. 268ae04fa6Smrg 278ae04fa6Smrgif test $# -eq 0; then 2880f56f3aSmrg echo 1>&2 "Try '$0 --help' for more information" 298ae04fa6Smrg exit 1 308ae04fa6Smrgfi 318ae04fa6Smrg 3280f56f3aSmrgcase $1 in 338ae04fa6Smrg 3480f56f3aSmrg --is-lightweight) 3580f56f3aSmrg # Used by our autoconf macros to check whether the available missing 3680f56f3aSmrg # script is modern enough. 3780f56f3aSmrg exit 0 3880f56f3aSmrg ;; 398ae04fa6Smrg 4080f56f3aSmrg --run) 4180f56f3aSmrg # Back-compat with the calling convention used by older automake. 4280f56f3aSmrg shift 4380f56f3aSmrg ;; 448ae04fa6Smrg 458ae04fa6Smrg -h|--h|--he|--hel|--help) 468ae04fa6Smrg echo "\ 478ae04fa6Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 488ae04fa6Smrg 4980f56f3aSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5080f56f3aSmrgto PROGRAM being missing or too old. 518ae04fa6Smrg 528ae04fa6SmrgOptions: 538ae04fa6Smrg -h, --help display this help and exit 548ae04fa6Smrg -v, --version output version information and exit 558ae04fa6Smrg 568ae04fa6SmrgSupported PROGRAM values: 5780f56f3aSmrg aclocal autoconf autoheader autom4te automake makeinfo 5880f56f3aSmrg bison yacc flex lex help2man 598ae04fa6Smrg 6080f56f3aSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 6180f56f3aSmrg'g' are ignored when checking the name. 6244af7230Smrg 638ae04fa6SmrgSend bug reports to <bug-automake@gnu.org>." 648ae04fa6Smrg exit $? 658ae04fa6Smrg ;; 668ae04fa6Smrg 678ae04fa6Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 688ae04fa6Smrg echo "missing $scriptversion (GNU Automake)" 698ae04fa6Smrg exit $? 708ae04fa6Smrg ;; 718ae04fa6Smrg 728ae04fa6Smrg -*) 7380f56f3aSmrg echo 1>&2 "$0: unknown '$1' option" 7480f56f3aSmrg echo 1>&2 "Try '$0 --help' for more information" 758ae04fa6Smrg exit 1 768ae04fa6Smrg ;; 778ae04fa6Smrg 788ae04fa6Smrgesac 798ae04fa6Smrg 8080f56f3aSmrg# Run the given program, remember its exit status. 8180f56f3aSmrg"$@"; st=$? 8280f56f3aSmrg 8380f56f3aSmrg# If it succeeded, we are done. 8480f56f3aSmrgtest $st -eq 0 && exit 0 8580f56f3aSmrg 8680f56f3aSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 8780f56f3aSmrg# passed; such an option is passed most likely to detect whether the 8880f56f3aSmrg# program is present and works. 8980f56f3aSmrgcase $2 in --version|--help) exit $st;; esac 9080f56f3aSmrg 9180f56f3aSmrg# Exit code 63 means version mismatch. This often happens when the user 9280f56f3aSmrg# tries to use an ancient version of a tool on a file that requires a 9380f56f3aSmrg# minimum version. 9480f56f3aSmrgif test $st -eq 63; then 9580f56f3aSmrg msg="probably too old" 9680f56f3aSmrgelif test $st -eq 127; then 9780f56f3aSmrg # Program was missing. 9880f56f3aSmrg msg="missing on your system" 9980f56f3aSmrgelse 10080f56f3aSmrg # Program was found and executed, but failed. Give up. 10180f56f3aSmrg exit $st 10280f56f3aSmrgfi 1038ae04fa6Smrg 104138a9f8aSmrgperl_URL=https://www.perl.org/ 105138a9f8aSmrgflex_URL=https://github.com/westes/flex 106138a9f8aSmrggnu_software_URL=https://www.gnu.org/software 10780f56f3aSmrg 10880f56f3aSmrgprogram_details () 10980f56f3aSmrg{ 11080f56f3aSmrg case $1 in 11180f56f3aSmrg aclocal|automake) 11280f56f3aSmrg echo "The '$1' program is part of the GNU Automake package:" 11380f56f3aSmrg echo "<$gnu_software_URL/automake>" 11480f56f3aSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11580f56f3aSmrg echo "<$gnu_software_URL/autoconf>" 11680f56f3aSmrg echo "<$gnu_software_URL/m4/>" 11780f56f3aSmrg echo "<$perl_URL>" 11880f56f3aSmrg ;; 11980f56f3aSmrg autoconf|autom4te|autoheader) 12080f56f3aSmrg echo "The '$1' program is part of the GNU Autoconf package:" 12180f56f3aSmrg echo "<$gnu_software_URL/autoconf/>" 12280f56f3aSmrg echo "It also requires GNU m4 and Perl in order to run:" 12380f56f3aSmrg echo "<$gnu_software_URL/m4/>" 12480f56f3aSmrg echo "<$perl_URL>" 12580f56f3aSmrg ;; 12680f56f3aSmrg esac 12780f56f3aSmrg} 12880f56f3aSmrg 12980f56f3aSmrggive_advice () 13080f56f3aSmrg{ 13180f56f3aSmrg # Normalize program name to check for. 13280f56f3aSmrg normalized_program=`echo "$1" | sed ' 13380f56f3aSmrg s/^gnu-//; t 13480f56f3aSmrg s/^gnu//; t 13580f56f3aSmrg s/^g//; t'` 13680f56f3aSmrg 13780f56f3aSmrg printf '%s\n' "'$1' is $msg." 13880f56f3aSmrg 13980f56f3aSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14080f56f3aSmrg case $normalized_program in 14180f56f3aSmrg autoconf*) 14280f56f3aSmrg echo "You should only need it if you modified 'configure.ac'," 14380f56f3aSmrg echo "or m4 files included by it." 14480f56f3aSmrg program_details 'autoconf' 14580f56f3aSmrg ;; 14680f56f3aSmrg autoheader*) 14780f56f3aSmrg echo "You should only need it if you modified 'acconfig.h' or" 14880f56f3aSmrg echo "$configure_deps." 14980f56f3aSmrg program_details 'autoheader' 15080f56f3aSmrg ;; 15180f56f3aSmrg automake*) 15280f56f3aSmrg echo "You should only need it if you modified 'Makefile.am' or" 15380f56f3aSmrg echo "$configure_deps." 15480f56f3aSmrg program_details 'automake' 15580f56f3aSmrg ;; 15680f56f3aSmrg aclocal*) 15780f56f3aSmrg echo "You should only need it if you modified 'acinclude.m4' or" 15880f56f3aSmrg echo "$configure_deps." 15980f56f3aSmrg program_details 'aclocal' 16080f56f3aSmrg ;; 16180f56f3aSmrg autom4te*) 16280f56f3aSmrg echo "You might have modified some maintainer files that require" 16380f56f3aSmrg echo "the 'autom4te' program to be rebuilt." 16480f56f3aSmrg program_details 'autom4te' 16580f56f3aSmrg ;; 16680f56f3aSmrg bison*|yacc*) 16780f56f3aSmrg echo "You should only need it if you modified a '.y' file." 16880f56f3aSmrg echo "You may want to install the GNU Bison package:" 16980f56f3aSmrg echo "<$gnu_software_URL/bison/>" 17080f56f3aSmrg ;; 17180f56f3aSmrg lex*|flex*) 17280f56f3aSmrg echo "You should only need it if you modified a '.l' file." 17380f56f3aSmrg echo "You may want to install the Fast Lexical Analyzer package:" 17480f56f3aSmrg echo "<$flex_URL>" 17580f56f3aSmrg ;; 17680f56f3aSmrg help2man*) 17780f56f3aSmrg echo "You should only need it if you modified a dependency" \ 17880f56f3aSmrg "of a man page." 17980f56f3aSmrg echo "You may want to install the GNU Help2man package:" 18080f56f3aSmrg echo "<$gnu_software_URL/help2man/>" 18180f56f3aSmrg ;; 18280f56f3aSmrg makeinfo*) 18380f56f3aSmrg echo "You should only need it if you modified a '.texi' file, or" 18480f56f3aSmrg echo "any other file indirectly affecting the aspect of the manual." 18580f56f3aSmrg echo "You might want to install the Texinfo package:" 18680f56f3aSmrg echo "<$gnu_software_URL/texinfo/>" 18780f56f3aSmrg echo "The spurious makeinfo call might also be the consequence of" 18880f56f3aSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 18980f56f3aSmrg echo "want to install GNU make:" 19080f56f3aSmrg echo "<$gnu_software_URL/make/>" 19180f56f3aSmrg ;; 19280f56f3aSmrg *) 19380f56f3aSmrg echo "You might have modified some files without having the proper" 19480f56f3aSmrg echo "tools for further handling them. Check the 'README' file, it" 19580f56f3aSmrg echo "often tells you about the needed prerequisites for installing" 19680f56f3aSmrg echo "this package. You may also peek at any GNU archive site, in" 19780f56f3aSmrg echo "case some other package contains this missing '$1' program." 19880f56f3aSmrg ;; 19980f56f3aSmrg esac 20080f56f3aSmrg} 20180f56f3aSmrg 20280f56f3aSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 20380f56f3aSmrg -e '2,$s/^/ /' >&2 20480f56f3aSmrg 20580f56f3aSmrg# Propagate the correct exit status (expected to be 127 for a program 20680f56f3aSmrg# not found, 63 for a program that failed due to version mismatch). 20780f56f3aSmrgexit $st 2088ae04fa6Smrg 2098ae04fa6Smrg# Local variables: 210138a9f8aSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2118ae04fa6Smrg# time-stamp-start: "scriptversion=" 2128ae04fa6Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213138a9f8aSmrg# time-stamp-time-zone: "UTC0" 21444af7230Smrg# time-stamp-end: "; # UTC" 2158ae04fa6Smrg# End: 216