1100ae103Smrg#! /bin/sh 295cf0c00Smrg# Common wrapper for a few potentially missing GNU programs. 3100ae103Smrg 40103645bSmrgscriptversion=2018-03-07.03; # UTC 5100ae103Smrg 60103645bSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 795cf0c00Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8100ae103Smrg 9100ae103Smrg# This program is free software; you can redistribute it and/or modify 10100ae103Smrg# it under the terms of the GNU General Public License as published by 11100ae103Smrg# the Free Software Foundation; either version 2, or (at your option) 12100ae103Smrg# any later version. 13100ae103Smrg 14100ae103Smrg# This program is distributed in the hope that it will be useful, 15100ae103Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16100ae103Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17100ae103Smrg# GNU General Public License for more details. 18100ae103Smrg 19100ae103Smrg# You should have received a copy of the GNU General Public License 200103645bSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21100ae103Smrg 22100ae103Smrg# As a special exception to the GNU General Public License, if you 23100ae103Smrg# distribute this file as part of a program that contains a 24100ae103Smrg# configuration script generated by Autoconf, you may include it under 25100ae103Smrg# the same distribution terms that you use for the rest of that program. 26100ae103Smrg 27100ae103Smrgif test $# -eq 0; then 2895cf0c00Smrg echo 1>&2 "Try '$0 --help' for more information" 29100ae103Smrg exit 1 30100ae103Smrgfi 31100ae103Smrg 3295cf0c00Smrgcase $1 in 33100ae103Smrg 3495cf0c00Smrg --is-lightweight) 3595cf0c00Smrg # Used by our autoconf macros to check whether the available missing 3695cf0c00Smrg # script is modern enough. 3795cf0c00Smrg exit 0 3895cf0c00Smrg ;; 39100ae103Smrg 4095cf0c00Smrg --run) 4195cf0c00Smrg # Back-compat with the calling convention used by older automake. 4295cf0c00Smrg shift 4395cf0c00Smrg ;; 44100ae103Smrg 45100ae103Smrg -h|--h|--he|--hel|--help) 46100ae103Smrg echo "\ 47100ae103Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48100ae103Smrg 4995cf0c00SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5095cf0c00Smrgto PROGRAM being missing or too old. 51100ae103Smrg 52100ae103SmrgOptions: 53100ae103Smrg -h, --help display this help and exit 54100ae103Smrg -v, --version output version information and exit 55100ae103Smrg 56100ae103SmrgSupported PROGRAM values: 5795cf0c00Smrg aclocal autoconf autoheader autom4te automake makeinfo 5895cf0c00Smrg bison yacc flex lex help2man 59100ae103Smrg 6095cf0c00SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 6195cf0c00Smrg'g' are ignored when checking the name. 62165cb819Smrg 63100ae103SmrgSend bug reports to <bug-automake@gnu.org>." 64100ae103Smrg exit $? 65100ae103Smrg ;; 66100ae103Smrg 67100ae103Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68100ae103Smrg echo "missing $scriptversion (GNU Automake)" 69100ae103Smrg exit $? 70100ae103Smrg ;; 71100ae103Smrg 72100ae103Smrg -*) 7395cf0c00Smrg echo 1>&2 "$0: unknown '$1' option" 7495cf0c00Smrg echo 1>&2 "Try '$0 --help' for more information" 75100ae103Smrg exit 1 76100ae103Smrg ;; 77100ae103Smrg 78100ae103Smrgesac 79100ae103Smrg 8095cf0c00Smrg# Run the given program, remember its exit status. 8195cf0c00Smrg"$@"; st=$? 8295cf0c00Smrg 8395cf0c00Smrg# If it succeeded, we are done. 8495cf0c00Smrgtest $st -eq 0 && exit 0 8595cf0c00Smrg 8695cf0c00Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 8795cf0c00Smrg# passed; such an option is passed most likely to detect whether the 8895cf0c00Smrg# program is present and works. 8995cf0c00Smrgcase $2 in --version|--help) exit $st;; esac 9095cf0c00Smrg 9195cf0c00Smrg# Exit code 63 means version mismatch. This often happens when the user 9295cf0c00Smrg# tries to use an ancient version of a tool on a file that requires a 9395cf0c00Smrg# minimum version. 9495cf0c00Smrgif test $st -eq 63; then 9595cf0c00Smrg msg="probably too old" 9695cf0c00Smrgelif test $st -eq 127; then 9795cf0c00Smrg # Program was missing. 9895cf0c00Smrg msg="missing on your system" 9995cf0c00Smrgelse 10095cf0c00Smrg # Program was found and executed, but failed. Give up. 10195cf0c00Smrg exit $st 10295cf0c00Smrgfi 103100ae103Smrg 1040103645bSmrgperl_URL=https://www.perl.org/ 1050103645bSmrgflex_URL=https://github.com/westes/flex 1060103645bSmrggnu_software_URL=https://www.gnu.org/software 10795cf0c00Smrg 10895cf0c00Smrgprogram_details () 10995cf0c00Smrg{ 11095cf0c00Smrg case $1 in 11195cf0c00Smrg aclocal|automake) 11295cf0c00Smrg echo "The '$1' program is part of the GNU Automake package:" 11395cf0c00Smrg echo "<$gnu_software_URL/automake>" 11495cf0c00Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11595cf0c00Smrg echo "<$gnu_software_URL/autoconf>" 11695cf0c00Smrg echo "<$gnu_software_URL/m4/>" 11795cf0c00Smrg echo "<$perl_URL>" 11895cf0c00Smrg ;; 11995cf0c00Smrg autoconf|autom4te|autoheader) 12095cf0c00Smrg echo "The '$1' program is part of the GNU Autoconf package:" 12195cf0c00Smrg echo "<$gnu_software_URL/autoconf/>" 12295cf0c00Smrg echo "It also requires GNU m4 and Perl in order to run:" 12395cf0c00Smrg echo "<$gnu_software_URL/m4/>" 12495cf0c00Smrg echo "<$perl_URL>" 12595cf0c00Smrg ;; 12695cf0c00Smrg esac 12795cf0c00Smrg} 12895cf0c00Smrg 12995cf0c00Smrggive_advice () 13095cf0c00Smrg{ 13195cf0c00Smrg # Normalize program name to check for. 13295cf0c00Smrg normalized_program=`echo "$1" | sed ' 13395cf0c00Smrg s/^gnu-//; t 13495cf0c00Smrg s/^gnu//; t 13595cf0c00Smrg s/^g//; t'` 13695cf0c00Smrg 13795cf0c00Smrg printf '%s\n' "'$1' is $msg." 13895cf0c00Smrg 13995cf0c00Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14095cf0c00Smrg case $normalized_program in 14195cf0c00Smrg autoconf*) 14295cf0c00Smrg echo "You should only need it if you modified 'configure.ac'," 14395cf0c00Smrg echo "or m4 files included by it." 14495cf0c00Smrg program_details 'autoconf' 14595cf0c00Smrg ;; 14695cf0c00Smrg autoheader*) 14795cf0c00Smrg echo "You should only need it if you modified 'acconfig.h' or" 14895cf0c00Smrg echo "$configure_deps." 14995cf0c00Smrg program_details 'autoheader' 15095cf0c00Smrg ;; 15195cf0c00Smrg automake*) 15295cf0c00Smrg echo "You should only need it if you modified 'Makefile.am' or" 15395cf0c00Smrg echo "$configure_deps." 15495cf0c00Smrg program_details 'automake' 15595cf0c00Smrg ;; 15695cf0c00Smrg aclocal*) 15795cf0c00Smrg echo "You should only need it if you modified 'acinclude.m4' or" 15895cf0c00Smrg echo "$configure_deps." 15995cf0c00Smrg program_details 'aclocal' 16095cf0c00Smrg ;; 16195cf0c00Smrg autom4te*) 16295cf0c00Smrg echo "You might have modified some maintainer files that require" 16395cf0c00Smrg echo "the 'autom4te' program to be rebuilt." 16495cf0c00Smrg program_details 'autom4te' 16595cf0c00Smrg ;; 16695cf0c00Smrg bison*|yacc*) 16795cf0c00Smrg echo "You should only need it if you modified a '.y' file." 16895cf0c00Smrg echo "You may want to install the GNU Bison package:" 16995cf0c00Smrg echo "<$gnu_software_URL/bison/>" 17095cf0c00Smrg ;; 17195cf0c00Smrg lex*|flex*) 17295cf0c00Smrg echo "You should only need it if you modified a '.l' file." 17395cf0c00Smrg echo "You may want to install the Fast Lexical Analyzer package:" 17495cf0c00Smrg echo "<$flex_URL>" 17595cf0c00Smrg ;; 17695cf0c00Smrg help2man*) 17795cf0c00Smrg echo "You should only need it if you modified a dependency" \ 17895cf0c00Smrg "of a man page." 17995cf0c00Smrg echo "You may want to install the GNU Help2man package:" 18095cf0c00Smrg echo "<$gnu_software_URL/help2man/>" 18195cf0c00Smrg ;; 18295cf0c00Smrg makeinfo*) 18395cf0c00Smrg echo "You should only need it if you modified a '.texi' file, or" 18495cf0c00Smrg echo "any other file indirectly affecting the aspect of the manual." 18595cf0c00Smrg echo "You might want to install the Texinfo package:" 18695cf0c00Smrg echo "<$gnu_software_URL/texinfo/>" 18795cf0c00Smrg echo "The spurious makeinfo call might also be the consequence of" 18895cf0c00Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 18995cf0c00Smrg echo "want to install GNU make:" 19095cf0c00Smrg echo "<$gnu_software_URL/make/>" 19195cf0c00Smrg ;; 19295cf0c00Smrg *) 19395cf0c00Smrg echo "You might have modified some files without having the proper" 19495cf0c00Smrg echo "tools for further handling them. Check the 'README' file, it" 19595cf0c00Smrg echo "often tells you about the needed prerequisites for installing" 19695cf0c00Smrg echo "this package. You may also peek at any GNU archive site, in" 19795cf0c00Smrg echo "case some other package contains this missing '$1' program." 19895cf0c00Smrg ;; 19995cf0c00Smrg esac 20095cf0c00Smrg} 20195cf0c00Smrg 20295cf0c00Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 20395cf0c00Smrg -e '2,$s/^/ /' >&2 20495cf0c00Smrg 20595cf0c00Smrg# Propagate the correct exit status (expected to be 127 for a program 20695cf0c00Smrg# not found, 63 for a program that failed due to version mismatch). 20795cf0c00Smrgexit $st 208100ae103Smrg 209100ae103Smrg# Local variables: 2100103645bSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 211100ae103Smrg# time-stamp-start: "scriptversion=" 212100ae103Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2130103645bSmrg# time-stamp-time-zone: "UTC0" 214165cb819Smrg# time-stamp-end: "; # UTC" 215100ae103Smrg# End: 216