113498266Sopenharmony_ci#! /bin/sh 213498266Sopenharmony_ci# Common wrapper for a few potentially missing GNU programs. 313498266Sopenharmony_ci 413498266Sopenharmony_ciscriptversion=2018-03-07.03; # UTC 513498266Sopenharmony_ci 613498266Sopenharmony_ci# Copyright (C) 1996-2021 Free Software Foundation, Inc. 713498266Sopenharmony_ci# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 813498266Sopenharmony_ci 913498266Sopenharmony_ci# This program is free software; you can redistribute it and/or modify 1013498266Sopenharmony_ci# it under the terms of the GNU General Public License as published by 1113498266Sopenharmony_ci# the Free Software Foundation; either version 2, or (at your option) 1213498266Sopenharmony_ci# any later version. 1313498266Sopenharmony_ci 1413498266Sopenharmony_ci# This program is distributed in the hope that it will be useful, 1513498266Sopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of 1613498266Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1713498266Sopenharmony_ci# GNU General Public License for more details. 1813498266Sopenharmony_ci 1913498266Sopenharmony_ci# You should have received a copy of the GNU General Public License 2013498266Sopenharmony_ci# along with this program. If not, see <https://www.gnu.org/licenses/>. 2113498266Sopenharmony_ci 2213498266Sopenharmony_ci# As a special exception to the GNU General Public License, if you 2313498266Sopenharmony_ci# distribute this file as part of a program that contains a 2413498266Sopenharmony_ci# configuration script generated by Autoconf, you may include it under 2513498266Sopenharmony_ci# the same distribution terms that you use for the rest of that program. 2613498266Sopenharmony_ci 2713498266Sopenharmony_ciif test $# -eq 0; then 2813498266Sopenharmony_ci echo 1>&2 "Try '$0 --help' for more information" 2913498266Sopenharmony_ci exit 1 3013498266Sopenharmony_cifi 3113498266Sopenharmony_ci 3213498266Sopenharmony_cicase $1 in 3313498266Sopenharmony_ci 3413498266Sopenharmony_ci --is-lightweight) 3513498266Sopenharmony_ci # Used by our autoconf macros to check whether the available missing 3613498266Sopenharmony_ci # script is modern enough. 3713498266Sopenharmony_ci exit 0 3813498266Sopenharmony_ci ;; 3913498266Sopenharmony_ci 4013498266Sopenharmony_ci --run) 4113498266Sopenharmony_ci # Back-compat with the calling convention used by older automake. 4213498266Sopenharmony_ci shift 4313498266Sopenharmony_ci ;; 4413498266Sopenharmony_ci 4513498266Sopenharmony_ci -h|--h|--he|--hel|--help) 4613498266Sopenharmony_ci echo "\ 4713498266Sopenharmony_ci$0 [OPTION]... PROGRAM [ARGUMENT]... 4813498266Sopenharmony_ci 4913498266Sopenharmony_ciRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5013498266Sopenharmony_cito PROGRAM being missing or too old. 5113498266Sopenharmony_ci 5213498266Sopenharmony_ciOptions: 5313498266Sopenharmony_ci -h, --help display this help and exit 5413498266Sopenharmony_ci -v, --version output version information and exit 5513498266Sopenharmony_ci 5613498266Sopenharmony_ciSupported PROGRAM values: 5713498266Sopenharmony_ci aclocal autoconf autoheader autom4te automake makeinfo 5813498266Sopenharmony_ci bison yacc flex lex help2man 5913498266Sopenharmony_ci 6013498266Sopenharmony_ciVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 6113498266Sopenharmony_ci'g' are ignored when checking the name. 6213498266Sopenharmony_ci 6313498266Sopenharmony_ciSend bug reports to <bug-automake@gnu.org>." 6413498266Sopenharmony_ci exit $? 6513498266Sopenharmony_ci ;; 6613498266Sopenharmony_ci 6713498266Sopenharmony_ci -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 6813498266Sopenharmony_ci echo "missing $scriptversion (GNU Automake)" 6913498266Sopenharmony_ci exit $? 7013498266Sopenharmony_ci ;; 7113498266Sopenharmony_ci 7213498266Sopenharmony_ci -*) 7313498266Sopenharmony_ci echo 1>&2 "$0: unknown '$1' option" 7413498266Sopenharmony_ci echo 1>&2 "Try '$0 --help' for more information" 7513498266Sopenharmony_ci exit 1 7613498266Sopenharmony_ci ;; 7713498266Sopenharmony_ci 7813498266Sopenharmony_ciesac 7913498266Sopenharmony_ci 8013498266Sopenharmony_ci# Run the given program, remember its exit status. 8113498266Sopenharmony_ci"$@"; st=$? 8213498266Sopenharmony_ci 8313498266Sopenharmony_ci# If it succeeded, we are done. 8413498266Sopenharmony_citest $st -eq 0 && exit 0 8513498266Sopenharmony_ci 8613498266Sopenharmony_ci# Also exit now if we it failed (or wasn't found), and '--version' was 8713498266Sopenharmony_ci# passed; such an option is passed most likely to detect whether the 8813498266Sopenharmony_ci# program is present and works. 8913498266Sopenharmony_cicase $2 in --version|--help) exit $st;; esac 9013498266Sopenharmony_ci 9113498266Sopenharmony_ci# Exit code 63 means version mismatch. This often happens when the user 9213498266Sopenharmony_ci# tries to use an ancient version of a tool on a file that requires a 9313498266Sopenharmony_ci# minimum version. 9413498266Sopenharmony_ciif test $st -eq 63; then 9513498266Sopenharmony_ci msg="probably too old" 9613498266Sopenharmony_cielif test $st -eq 127; then 9713498266Sopenharmony_ci # Program was missing. 9813498266Sopenharmony_ci msg="missing on your system" 9913498266Sopenharmony_cielse 10013498266Sopenharmony_ci # Program was found and executed, but failed. Give up. 10113498266Sopenharmony_ci exit $st 10213498266Sopenharmony_cifi 10313498266Sopenharmony_ci 10413498266Sopenharmony_ciperl_URL=https://www.perl.org/ 10513498266Sopenharmony_ciflex_URL=https://github.com/westes/flex 10613498266Sopenharmony_cignu_software_URL=https://www.gnu.org/software 10713498266Sopenharmony_ci 10813498266Sopenharmony_ciprogram_details () 10913498266Sopenharmony_ci{ 11013498266Sopenharmony_ci case $1 in 11113498266Sopenharmony_ci aclocal|automake) 11213498266Sopenharmony_ci echo "The '$1' program is part of the GNU Automake package:" 11313498266Sopenharmony_ci echo "<$gnu_software_URL/automake>" 11413498266Sopenharmony_ci echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11513498266Sopenharmony_ci echo "<$gnu_software_URL/autoconf>" 11613498266Sopenharmony_ci echo "<$gnu_software_URL/m4/>" 11713498266Sopenharmony_ci echo "<$perl_URL>" 11813498266Sopenharmony_ci ;; 11913498266Sopenharmony_ci autoconf|autom4te|autoheader) 12013498266Sopenharmony_ci echo "The '$1' program is part of the GNU Autoconf package:" 12113498266Sopenharmony_ci echo "<$gnu_software_URL/autoconf/>" 12213498266Sopenharmony_ci echo "It also requires GNU m4 and Perl in order to run:" 12313498266Sopenharmony_ci echo "<$gnu_software_URL/m4/>" 12413498266Sopenharmony_ci echo "<$perl_URL>" 12513498266Sopenharmony_ci ;; 12613498266Sopenharmony_ci esac 12713498266Sopenharmony_ci} 12813498266Sopenharmony_ci 12913498266Sopenharmony_cigive_advice () 13013498266Sopenharmony_ci{ 13113498266Sopenharmony_ci # Normalize program name to check for. 13213498266Sopenharmony_ci normalized_program=`echo "$1" | sed ' 13313498266Sopenharmony_ci s/^gnu-//; t 13413498266Sopenharmony_ci s/^gnu//; t 13513498266Sopenharmony_ci s/^g//; t'` 13613498266Sopenharmony_ci 13713498266Sopenharmony_ci printf '%s\n' "'$1' is $msg." 13813498266Sopenharmony_ci 13913498266Sopenharmony_ci configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14013498266Sopenharmony_ci case $normalized_program in 14113498266Sopenharmony_ci autoconf*) 14213498266Sopenharmony_ci echo "You should only need it if you modified 'configure.ac'," 14313498266Sopenharmony_ci echo "or m4 files included by it." 14413498266Sopenharmony_ci program_details 'autoconf' 14513498266Sopenharmony_ci ;; 14613498266Sopenharmony_ci autoheader*) 14713498266Sopenharmony_ci echo "You should only need it if you modified 'acconfig.h' or" 14813498266Sopenharmony_ci echo "$configure_deps." 14913498266Sopenharmony_ci program_details 'autoheader' 15013498266Sopenharmony_ci ;; 15113498266Sopenharmony_ci automake*) 15213498266Sopenharmony_ci echo "You should only need it if you modified 'Makefile.am' or" 15313498266Sopenharmony_ci echo "$configure_deps." 15413498266Sopenharmony_ci program_details 'automake' 15513498266Sopenharmony_ci ;; 15613498266Sopenharmony_ci aclocal*) 15713498266Sopenharmony_ci echo "You should only need it if you modified 'acinclude.m4' or" 15813498266Sopenharmony_ci echo "$configure_deps." 15913498266Sopenharmony_ci program_details 'aclocal' 16013498266Sopenharmony_ci ;; 16113498266Sopenharmony_ci autom4te*) 16213498266Sopenharmony_ci echo "You might have modified some maintainer files that require" 16313498266Sopenharmony_ci echo "the 'autom4te' program to be rebuilt." 16413498266Sopenharmony_ci program_details 'autom4te' 16513498266Sopenharmony_ci ;; 16613498266Sopenharmony_ci bison*|yacc*) 16713498266Sopenharmony_ci echo "You should only need it if you modified a '.y' file." 16813498266Sopenharmony_ci echo "You may want to install the GNU Bison package:" 16913498266Sopenharmony_ci echo "<$gnu_software_URL/bison/>" 17013498266Sopenharmony_ci ;; 17113498266Sopenharmony_ci lex*|flex*) 17213498266Sopenharmony_ci echo "You should only need it if you modified a '.l' file." 17313498266Sopenharmony_ci echo "You may want to install the Fast Lexical Analyzer package:" 17413498266Sopenharmony_ci echo "<$flex_URL>" 17513498266Sopenharmony_ci ;; 17613498266Sopenharmony_ci help2man*) 17713498266Sopenharmony_ci echo "You should only need it if you modified a dependency" \ 17813498266Sopenharmony_ci "of a man page." 17913498266Sopenharmony_ci echo "You may want to install the GNU Help2man package:" 18013498266Sopenharmony_ci echo "<$gnu_software_URL/help2man/>" 18113498266Sopenharmony_ci ;; 18213498266Sopenharmony_ci makeinfo*) 18313498266Sopenharmony_ci echo "You should only need it if you modified a '.texi' file, or" 18413498266Sopenharmony_ci echo "any other file indirectly affecting the aspect of the manual." 18513498266Sopenharmony_ci echo "You might want to install the Texinfo package:" 18613498266Sopenharmony_ci echo "<$gnu_software_URL/texinfo/>" 18713498266Sopenharmony_ci echo "The spurious makeinfo call might also be the consequence of" 18813498266Sopenharmony_ci echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 18913498266Sopenharmony_ci echo "want to install GNU make:" 19013498266Sopenharmony_ci echo "<$gnu_software_URL/make/>" 19113498266Sopenharmony_ci ;; 19213498266Sopenharmony_ci *) 19313498266Sopenharmony_ci echo "You might have modified some files without having the proper" 19413498266Sopenharmony_ci echo "tools for further handling them. Check the 'README' file, it" 19513498266Sopenharmony_ci echo "often tells you about the needed prerequisites for installing" 19613498266Sopenharmony_ci echo "this package. You may also peek at any GNU archive site, in" 19713498266Sopenharmony_ci echo "case some other package contains this missing '$1' program." 19813498266Sopenharmony_ci ;; 19913498266Sopenharmony_ci esac 20013498266Sopenharmony_ci} 20113498266Sopenharmony_ci 20213498266Sopenharmony_cigive_advice "$1" | sed -e '1s/^/WARNING: /' \ 20313498266Sopenharmony_ci -e '2,$s/^/ /' >&2 20413498266Sopenharmony_ci 20513498266Sopenharmony_ci# Propagate the correct exit status (expected to be 127 for a program 20613498266Sopenharmony_ci# not found, 63 for a program that failed due to version mismatch). 20713498266Sopenharmony_ciexit $st 20813498266Sopenharmony_ci 20913498266Sopenharmony_ci# Local variables: 21013498266Sopenharmony_ci# eval: (add-hook 'before-save-hook 'time-stamp) 21113498266Sopenharmony_ci# time-stamp-start: "scriptversion=" 21213498266Sopenharmony_ci# time-stamp-format: "%:y-%02m-%02d.%02H" 21313498266Sopenharmony_ci# time-stamp-time-zone: "UTC0" 21413498266Sopenharmony_ci# time-stamp-end: "; # UTC" 21513498266Sopenharmony_ci# End: 216