15eefee25Smacallan#! /bin/sh 25c30ecadSmrg# Common wrapper for a few potentially missing GNU programs. 35eefee25Smacallan 45c30ecadSmrgscriptversion=2018-03-07.03; # UTC 55eefee25Smacallan 65c30ecadSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 75c30ecadSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 85eefee25Smacallan 95eefee25Smacallan# This program is free software; you can redistribute it and/or modify 105eefee25Smacallan# it under the terms of the GNU General Public License as published by 115eefee25Smacallan# the Free Software Foundation; either version 2, or (at your option) 125eefee25Smacallan# any later version. 135eefee25Smacallan 145eefee25Smacallan# This program is distributed in the hope that it will be useful, 155eefee25Smacallan# but WITHOUT ANY WARRANTY; without even the implied warranty of 165eefee25Smacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 175eefee25Smacallan# GNU General Public License for more details. 185eefee25Smacallan 195eefee25Smacallan# You should have received a copy of the GNU General Public License 205c30ecadSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 215eefee25Smacallan 225eefee25Smacallan# As a special exception to the GNU General Public License, if you 235eefee25Smacallan# distribute this file as part of a program that contains a 245eefee25Smacallan# configuration script generated by Autoconf, you may include it under 255eefee25Smacallan# the same distribution terms that you use for the rest of that program. 265eefee25Smacallan 275eefee25Smacallanif test $# -eq 0; then 28dc99b369Smrg echo 1>&2 "Try '$0 --help' for more information" 295eefee25Smacallan exit 1 305eefee25Smacallanfi 315eefee25Smacallan 325c30ecadSmrgcase $1 in 335eefee25Smacallan 345c30ecadSmrg --is-lightweight) 355c30ecadSmrg # Used by our autoconf macros to check whether the available missing 365c30ecadSmrg # script is modern enough. 375c30ecadSmrg exit 0 385c30ecadSmrg ;; 395eefee25Smacallan 405c30ecadSmrg --run) 415c30ecadSmrg # Back-compat with the calling convention used by older automake. 425c30ecadSmrg shift 435c30ecadSmrg ;; 445eefee25Smacallan 455eefee25Smacallan -h|--h|--he|--hel|--help) 465eefee25Smacallan echo "\ 475eefee25Smacallan$0 [OPTION]... PROGRAM [ARGUMENT]... 485eefee25Smacallan 495c30ecadSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 505c30ecadSmrgto PROGRAM being missing or too old. 515eefee25Smacallan 525eefee25SmacallanOptions: 535eefee25Smacallan -h, --help display this help and exit 545eefee25Smacallan -v, --version output version information and exit 555eefee25Smacallan 565eefee25SmacallanSupported PROGRAM values: 575c30ecadSmrg aclocal autoconf autoheader autom4te automake makeinfo 585c30ecadSmrg bison yacc flex lex help2man 59dc99b369Smrg 60dc99b369SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61dc99b369Smrg'g' are ignored when checking the name. 625eefee25Smacallan 635eefee25SmacallanSend bug reports to <bug-automake@gnu.org>." 645eefee25Smacallan exit $? 655eefee25Smacallan ;; 665eefee25Smacallan 675eefee25Smacallan -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 685eefee25Smacallan echo "missing $scriptversion (GNU Automake)" 695eefee25Smacallan exit $? 705eefee25Smacallan ;; 715eefee25Smacallan 725eefee25Smacallan -*) 735c30ecadSmrg echo 1>&2 "$0: unknown '$1' option" 74dc99b369Smrg echo 1>&2 "Try '$0 --help' for more information" 755eefee25Smacallan exit 1 765eefee25Smacallan ;; 775eefee25Smacallan 785eefee25Smacallanesac 795eefee25Smacallan 805c30ecadSmrg# Run the given program, remember its exit status. 815c30ecadSmrg"$@"; st=$? 825c30ecadSmrg 835c30ecadSmrg# If it succeeded, we are done. 845c30ecadSmrgtest $st -eq 0 && exit 0 855c30ecadSmrg 865c30ecadSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 875c30ecadSmrg# passed; such an option is passed most likely to detect whether the 885c30ecadSmrg# program is present and works. 895c30ecadSmrgcase $2 in --version|--help) exit $st;; esac 905c30ecadSmrg 915c30ecadSmrg# Exit code 63 means version mismatch. This often happens when the user 925c30ecadSmrg# tries to use an ancient version of a tool on a file that requires a 935c30ecadSmrg# minimum version. 945c30ecadSmrgif test $st -eq 63; then 955c30ecadSmrg msg="probably too old" 965c30ecadSmrgelif test $st -eq 127; then 975c30ecadSmrg # Program was missing. 985c30ecadSmrg msg="missing on your system" 995c30ecadSmrgelse 1005c30ecadSmrg # Program was found and executed, but failed. Give up. 1015c30ecadSmrg exit $st 1025c30ecadSmrgfi 1035eefee25Smacallan 1045c30ecadSmrgperl_URL=https://www.perl.org/ 1055c30ecadSmrgflex_URL=https://github.com/westes/flex 1065c30ecadSmrggnu_software_URL=https://www.gnu.org/software 1075c30ecadSmrg 1085c30ecadSmrgprogram_details () 1095c30ecadSmrg{ 1105c30ecadSmrg case $1 in 1115c30ecadSmrg aclocal|automake) 1125c30ecadSmrg echo "The '$1' program is part of the GNU Automake package:" 1135c30ecadSmrg echo "<$gnu_software_URL/automake>" 1145c30ecadSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 1155c30ecadSmrg echo "<$gnu_software_URL/autoconf>" 1165c30ecadSmrg echo "<$gnu_software_URL/m4/>" 1175c30ecadSmrg echo "<$perl_URL>" 1185c30ecadSmrg ;; 1195c30ecadSmrg autoconf|autom4te|autoheader) 1205c30ecadSmrg echo "The '$1' program is part of the GNU Autoconf package:" 1215c30ecadSmrg echo "<$gnu_software_URL/autoconf/>" 1225c30ecadSmrg echo "It also requires GNU m4 and Perl in order to run:" 1235c30ecadSmrg echo "<$gnu_software_URL/m4/>" 1245c30ecadSmrg echo "<$perl_URL>" 1255c30ecadSmrg ;; 1265c30ecadSmrg esac 1275c30ecadSmrg} 1285c30ecadSmrg 1295c30ecadSmrggive_advice () 1305c30ecadSmrg{ 1315c30ecadSmrg # Normalize program name to check for. 1325c30ecadSmrg normalized_program=`echo "$1" | sed ' 1335c30ecadSmrg s/^gnu-//; t 1345c30ecadSmrg s/^gnu//; t 1355c30ecadSmrg s/^g//; t'` 1365c30ecadSmrg 1375c30ecadSmrg printf '%s\n' "'$1' is $msg." 1385c30ecadSmrg 1395c30ecadSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 1405c30ecadSmrg case $normalized_program in 1415c30ecadSmrg autoconf*) 1425c30ecadSmrg echo "You should only need it if you modified 'configure.ac'," 1435c30ecadSmrg echo "or m4 files included by it." 1445c30ecadSmrg program_details 'autoconf' 1455c30ecadSmrg ;; 1465c30ecadSmrg autoheader*) 1475c30ecadSmrg echo "You should only need it if you modified 'acconfig.h' or" 1485c30ecadSmrg echo "$configure_deps." 1495c30ecadSmrg program_details 'autoheader' 1505c30ecadSmrg ;; 1515c30ecadSmrg automake*) 1525c30ecadSmrg echo "You should only need it if you modified 'Makefile.am' or" 1535c30ecadSmrg echo "$configure_deps." 1545c30ecadSmrg program_details 'automake' 1555c30ecadSmrg ;; 1565c30ecadSmrg aclocal*) 1575c30ecadSmrg echo "You should only need it if you modified 'acinclude.m4' or" 1585c30ecadSmrg echo "$configure_deps." 1595c30ecadSmrg program_details 'aclocal' 1605c30ecadSmrg ;; 1615c30ecadSmrg autom4te*) 1625c30ecadSmrg echo "You might have modified some maintainer files that require" 1635c30ecadSmrg echo "the 'autom4te' program to be rebuilt." 1645c30ecadSmrg program_details 'autom4te' 1655c30ecadSmrg ;; 1665c30ecadSmrg bison*|yacc*) 1675c30ecadSmrg echo "You should only need it if you modified a '.y' file." 1685c30ecadSmrg echo "You may want to install the GNU Bison package:" 1695c30ecadSmrg echo "<$gnu_software_URL/bison/>" 1705c30ecadSmrg ;; 1715c30ecadSmrg lex*|flex*) 1725c30ecadSmrg echo "You should only need it if you modified a '.l' file." 1735c30ecadSmrg echo "You may want to install the Fast Lexical Analyzer package:" 1745c30ecadSmrg echo "<$flex_URL>" 1755c30ecadSmrg ;; 1765c30ecadSmrg help2man*) 1775c30ecadSmrg echo "You should only need it if you modified a dependency" \ 1785c30ecadSmrg "of a man page." 1795c30ecadSmrg echo "You may want to install the GNU Help2man package:" 1805c30ecadSmrg echo "<$gnu_software_URL/help2man/>" 1815eefee25Smacallan ;; 1825c30ecadSmrg makeinfo*) 1835c30ecadSmrg echo "You should only need it if you modified a '.texi' file, or" 1845c30ecadSmrg echo "any other file indirectly affecting the aspect of the manual." 1855c30ecadSmrg echo "You might want to install the Texinfo package:" 1865c30ecadSmrg echo "<$gnu_software_URL/texinfo/>" 1875c30ecadSmrg echo "The spurious makeinfo call might also be the consequence of" 1885c30ecadSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 1895c30ecadSmrg echo "want to install GNU make:" 1905c30ecadSmrg echo "<$gnu_software_URL/make/>" 1915c30ecadSmrg ;; 1925c30ecadSmrg *) 1935c30ecadSmrg echo "You might have modified some files without having the proper" 1945c30ecadSmrg echo "tools for further handling them. Check the 'README' file, it" 1955c30ecadSmrg echo "often tells you about the needed prerequisites for installing" 1965c30ecadSmrg echo "this package. You may also peek at any GNU archive site, in" 1975c30ecadSmrg echo "case some other package contains this missing '$1' program." 1985c30ecadSmrg ;; 1995c30ecadSmrg esac 2005c30ecadSmrg} 2015c30ecadSmrg 2025c30ecadSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 2035c30ecadSmrg -e '2,$s/^/ /' >&2 2045c30ecadSmrg 2055c30ecadSmrg# Propagate the correct exit status (expected to be 127 for a program 2065c30ecadSmrg# not found, 63 for a program that failed due to version mismatch). 2075c30ecadSmrgexit $st 2085eefee25Smacallan 2095eefee25Smacallan# Local variables: 2105c30ecadSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2115eefee25Smacallan# time-stamp-start: "scriptversion=" 2125eefee25Smacallan# time-stamp-format: "%:y-%02m-%02d.%02H" 2135c30ecadSmrg# time-stamp-time-zone: "UTC0" 214dc99b369Smrg# time-stamp-end: "; # UTC" 2155eefee25Smacallan# End: 216