1937a2000SPeter Wemm#! /bin/sh 2d915215eSBaptiste Daroussin# Common wrapper for a few potentially missing GNU programs. 3937a2000SPeter Wemm 4*70b56f4bSCy Schubertscriptversion=2018-03-07.03; # UTC 5937a2000SPeter Wemm 6*70b56f4bSCy Schubert# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7d915215eSBaptiste Daroussin# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8937a2000SPeter Wemm 9937a2000SPeter Wemm# This program is free software; you can redistribute it and/or modify 10937a2000SPeter Wemm# it under the terms of the GNU General Public License as published by 11937a2000SPeter Wemm# the Free Software Foundation; either version 2, or (at your option) 12937a2000SPeter Wemm# any later version. 13937a2000SPeter Wemm 14937a2000SPeter Wemm# This program is distributed in the hope that it will be useful, 15937a2000SPeter Wemm# but WITHOUT ANY WARRANTY; without even the implied warranty of 16937a2000SPeter Wemm# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17937a2000SPeter Wemm# GNU General Public License for more details. 18937a2000SPeter Wemm 19937a2000SPeter Wemm# You should have received a copy of the GNU General Public License 20*70b56f4bSCy Schubert# along with this program. If not, see <https://www.gnu.org/licenses/>. 21937a2000SPeter Wemm 22937a2000SPeter Wemm# As a special exception to the GNU General Public License, if you 23937a2000SPeter Wemm# distribute this file as part of a program that contains a 24937a2000SPeter Wemm# configuration script generated by Autoconf, you may include it under 25937a2000SPeter Wemm# the same distribution terms that you use for the rest of that program. 26937a2000SPeter Wemm 27937a2000SPeter Wemmif test $# -eq 0; then 28d915215eSBaptiste Daroussin echo 1>&2 "Try '$0 --help' for more information" 29937a2000SPeter Wemm exit 1 30937a2000SPeter Wemmfi 31937a2000SPeter Wemm 328bc5c7c0SPeter Wemmcase $1 in 33d915215eSBaptiste Daroussin 34d915215eSBaptiste Daroussin --is-lightweight) 35d915215eSBaptiste Daroussin # Used by our autoconf macros to check whether the available missing 36d915215eSBaptiste Daroussin # script is modern enough. 37d915215eSBaptiste Daroussin exit 0 38d915215eSBaptiste Daroussin ;; 39d915215eSBaptiste Daroussin 40937a2000SPeter Wemm --run) 41d915215eSBaptiste Daroussin # Back-compat with the calling convention used by older automake. 42937a2000SPeter Wemm shift 43937a2000SPeter Wemm ;; 44937a2000SPeter Wemm 45937a2000SPeter Wemm -h|--h|--he|--hel|--help) 46937a2000SPeter Wemm echo "\ 47937a2000SPeter Wemm$0 [OPTION]... PROGRAM [ARGUMENT]... 48937a2000SPeter Wemm 49d915215eSBaptiste DaroussinRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50d915215eSBaptiste Daroussinto PROGRAM being missing or too old. 51937a2000SPeter Wemm 52937a2000SPeter WemmOptions: 53937a2000SPeter Wemm -h, --help display this help and exit 54937a2000SPeter Wemm -v, --version output version information and exit 55937a2000SPeter Wemm 56937a2000SPeter WemmSupported PROGRAM values: 57d915215eSBaptiste Daroussin aclocal autoconf autoheader autom4te automake makeinfo 58d915215eSBaptiste Daroussin bison yacc flex lex help2man 59937a2000SPeter Wemm 60d915215eSBaptiste DaroussinVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61d915215eSBaptiste Daroussin'g' are ignored when checking the name. 628bc5c7c0SPeter Wemm 63937a2000SPeter WemmSend bug reports to <bug-automake@gnu.org>." 64937a2000SPeter Wemm exit $? 65937a2000SPeter Wemm ;; 66937a2000SPeter Wemm 67937a2000SPeter Wemm -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68937a2000SPeter Wemm echo "missing $scriptversion (GNU Automake)" 69937a2000SPeter Wemm exit $? 70937a2000SPeter Wemm ;; 71937a2000SPeter Wemm 72937a2000SPeter Wemm -*) 73d915215eSBaptiste Daroussin echo 1>&2 "$0: unknown '$1' option" 74d915215eSBaptiste Daroussin echo 1>&2 "Try '$0 --help' for more information" 75937a2000SPeter Wemm exit 1 76937a2000SPeter Wemm ;; 77937a2000SPeter Wemm 78937a2000SPeter Wemmesac 79937a2000SPeter Wemm 80d915215eSBaptiste Daroussin# Run the given program, remember its exit status. 81d915215eSBaptiste Daroussin"$@"; st=$? 82d915215eSBaptiste Daroussin 83d915215eSBaptiste Daroussin# If it succeeded, we are done. 84d915215eSBaptiste Daroussintest $st -eq 0 && exit 0 85d915215eSBaptiste Daroussin 86d915215eSBaptiste Daroussin# Also exit now if we it failed (or wasn't found), and '--version' was 87d915215eSBaptiste Daroussin# passed; such an option is passed most likely to detect whether the 88d915215eSBaptiste Daroussin# program is present and works. 89d915215eSBaptiste Daroussincase $2 in --version|--help) exit $st;; esac 90d915215eSBaptiste Daroussin 91d915215eSBaptiste Daroussin# Exit code 63 means version mismatch. This often happens when the user 92d915215eSBaptiste Daroussin# tries to use an ancient version of a tool on a file that requires a 93d915215eSBaptiste Daroussin# minimum version. 94d915215eSBaptiste Daroussinif test $st -eq 63; then 95d915215eSBaptiste Daroussin msg="probably too old" 96d915215eSBaptiste Daroussinelif test $st -eq 127; then 97d915215eSBaptiste Daroussin # Program was missing. 98d915215eSBaptiste Daroussin msg="missing on your system" 99d915215eSBaptiste Daroussinelse 100d915215eSBaptiste Daroussin # Program was found and executed, but failed. Give up. 101d915215eSBaptiste Daroussin exit $st 102d915215eSBaptiste Daroussinfi 103d915215eSBaptiste Daroussin 104*70b56f4bSCy Schubertperl_URL=https://www.perl.org/ 105*70b56f4bSCy Schubertflex_URL=https://github.com/westes/flex 106*70b56f4bSCy Schubertgnu_software_URL=https://www.gnu.org/software 107d915215eSBaptiste Daroussin 108d915215eSBaptiste Daroussinprogram_details () 109d915215eSBaptiste Daroussin{ 110d915215eSBaptiste Daroussin case $1 in 111d915215eSBaptiste Daroussin aclocal|automake) 112d915215eSBaptiste Daroussin echo "The '$1' program is part of the GNU Automake package:" 113d915215eSBaptiste Daroussin echo "<$gnu_software_URL/automake>" 114d915215eSBaptiste Daroussin echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115d915215eSBaptiste Daroussin echo "<$gnu_software_URL/autoconf>" 116d915215eSBaptiste Daroussin echo "<$gnu_software_URL/m4/>" 117d915215eSBaptiste Daroussin echo "<$perl_URL>" 118d915215eSBaptiste Daroussin ;; 119d915215eSBaptiste Daroussin autoconf|autom4te|autoheader) 120d915215eSBaptiste Daroussin echo "The '$1' program is part of the GNU Autoconf package:" 121d915215eSBaptiste Daroussin echo "<$gnu_software_URL/autoconf/>" 122d915215eSBaptiste Daroussin echo "It also requires GNU m4 and Perl in order to run:" 123d915215eSBaptiste Daroussin echo "<$gnu_software_URL/m4/>" 124d915215eSBaptiste Daroussin echo "<$perl_URL>" 125d915215eSBaptiste Daroussin ;; 126d915215eSBaptiste Daroussin esac 127d915215eSBaptiste Daroussin} 128d915215eSBaptiste Daroussin 129d915215eSBaptiste Daroussingive_advice () 130d915215eSBaptiste Daroussin{ 131d915215eSBaptiste Daroussin # Normalize program name to check for. 132d915215eSBaptiste Daroussin normalized_program=`echo "$1" | sed ' 1338bc5c7c0SPeter Wemm s/^gnu-//; t 1348bc5c7c0SPeter Wemm s/^gnu//; t 1358bc5c7c0SPeter Wemm s/^g//; t'` 1368bc5c7c0SPeter Wemm 137d915215eSBaptiste Daroussin printf '%s\n' "'$1' is $msg." 138937a2000SPeter Wemm 139d915215eSBaptiste Daroussin configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140d915215eSBaptiste Daroussin case $normalized_program in 1418bc5c7c0SPeter Wemm autoconf*) 142d915215eSBaptiste Daroussin echo "You should only need it if you modified 'configure.ac'," 143d915215eSBaptiste Daroussin echo "or m4 files included by it." 144d915215eSBaptiste Daroussin program_details 'autoconf' 145937a2000SPeter Wemm ;; 1468bc5c7c0SPeter Wemm autoheader*) 147d915215eSBaptiste Daroussin echo "You should only need it if you modified 'acconfig.h' or" 148d915215eSBaptiste Daroussin echo "$configure_deps." 149d915215eSBaptiste Daroussin program_details 'autoheader' 150937a2000SPeter Wemm ;; 151937a2000SPeter Wemm automake*) 152d915215eSBaptiste Daroussin echo "You should only need it if you modified 'Makefile.am' or" 153d915215eSBaptiste Daroussin echo "$configure_deps." 154d915215eSBaptiste Daroussin program_details 'automake' 155937a2000SPeter Wemm ;; 156d915215eSBaptiste Daroussin aclocal*) 157d915215eSBaptiste Daroussin echo "You should only need it if you modified 'acinclude.m4' or" 158d915215eSBaptiste Daroussin echo "$configure_deps." 159d915215eSBaptiste Daroussin program_details 'aclocal' 160d915215eSBaptiste Daroussin ;; 1618bc5c7c0SPeter Wemm autom4te*) 162d915215eSBaptiste Daroussin echo "You might have modified some maintainer files that require" 163d915215eSBaptiste Daroussin echo "the 'autom4te' program to be rebuilt." 164d915215eSBaptiste Daroussin program_details 'autom4te' 165937a2000SPeter Wemm ;; 1668bc5c7c0SPeter Wemm bison*|yacc*) 167d915215eSBaptiste Daroussin echo "You should only need it if you modified a '.y' file." 168d915215eSBaptiste Daroussin echo "You may want to install the GNU Bison package:" 169d915215eSBaptiste Daroussin echo "<$gnu_software_URL/bison/>" 170937a2000SPeter Wemm ;; 1718bc5c7c0SPeter Wemm lex*|flex*) 172d915215eSBaptiste Daroussin echo "You should only need it if you modified a '.l' file." 173d915215eSBaptiste Daroussin echo "You may want to install the Fast Lexical Analyzer package:" 174d915215eSBaptiste Daroussin echo "<$flex_URL>" 175937a2000SPeter Wemm ;; 1768bc5c7c0SPeter Wemm help2man*) 177d915215eSBaptiste Daroussin echo "You should only need it if you modified a dependency" \ 178d915215eSBaptiste Daroussin "of a man page." 179d915215eSBaptiste Daroussin echo "You may want to install the GNU Help2man package:" 180d915215eSBaptiste Daroussin echo "<$gnu_software_URL/help2man/>" 181937a2000SPeter Wemm ;; 1828bc5c7c0SPeter Wemm makeinfo*) 183d915215eSBaptiste Daroussin echo "You should only need it if you modified a '.texi' file, or" 184d915215eSBaptiste Daroussin echo "any other file indirectly affecting the aspect of the manual." 185d915215eSBaptiste Daroussin echo "You might want to install the Texinfo package:" 186d915215eSBaptiste Daroussin echo "<$gnu_software_URL/texinfo/>" 187d915215eSBaptiste Daroussin echo "The spurious makeinfo call might also be the consequence of" 188d915215eSBaptiste Daroussin echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189d915215eSBaptiste Daroussin echo "want to install GNU make:" 190d915215eSBaptiste Daroussin echo "<$gnu_software_URL/make/>" 191937a2000SPeter Wemm ;; 192937a2000SPeter Wemm *) 193d915215eSBaptiste Daroussin echo "You might have modified some files without having the proper" 194d915215eSBaptiste Daroussin echo "tools for further handling them. Check the 'README' file, it" 195d915215eSBaptiste Daroussin echo "often tells you about the needed prerequisites for installing" 196d915215eSBaptiste Daroussin echo "this package. You may also peek at any GNU archive site, in" 197d915215eSBaptiste Daroussin echo "case some other package contains this missing '$1' program." 198937a2000SPeter Wemm ;; 199937a2000SPeter Wemm esac 200d915215eSBaptiste Daroussin} 201937a2000SPeter Wemm 202d915215eSBaptiste Daroussingive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203d915215eSBaptiste Daroussin -e '2,$s/^/ /' >&2 204d915215eSBaptiste Daroussin 205d915215eSBaptiste Daroussin# Propagate the correct exit status (expected to be 127 for a program 206d915215eSBaptiste Daroussin# not found, 63 for a program that failed due to version mismatch). 207d915215eSBaptiste Daroussinexit $st 208937a2000SPeter Wemm 209937a2000SPeter Wemm# Local variables: 210*70b56f4bSCy Schubert# eval: (add-hook 'before-save-hook 'time-stamp) 211937a2000SPeter Wemm# time-stamp-start: "scriptversion=" 212937a2000SPeter Wemm# time-stamp-format: "%:y-%02m-%02d.%02H" 213*70b56f4bSCy Schubert# time-stamp-time-zone: "UTC0" 2148bc5c7c0SPeter Wemm# time-stamp-end: "; # UTC" 215937a2000SPeter Wemm# End: 216