quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

missing (7733B)


      1 #! /bin/sh
      2 # Common wrapper for a few potentially missing GNU and other programs.
      3 
      4 scriptversion=2025-06-18.21; # UTC
      5 
      6 # shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells
      7 
      8 # Copyright (C) 1996-2025 Free Software Foundation, Inc.
      9 # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
     10 
     11 # This program is free software; you can redistribute it and/or modify
     12 # it under the terms of the GNU General Public License as published by
     13 # the Free Software Foundation; either version 2, or (at your option)
     14 # any later version.
     15 
     16 # This program is distributed in the hope that it will be useful,
     17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     19 # GNU General Public License for more details.
     20 
     21 # You should have received a copy of the GNU General Public License
     22 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
     23 
     24 # As a special exception to the GNU General Public License, if you
     25 # distribute this file as part of a program that contains a
     26 # configuration script generated by Autoconf, you may include it under
     27 # the same distribution terms that you use for the rest of that program.
     28 
     29 if test $# -eq 0; then
     30   echo 1>&2 "Try '$0 --help' for more information"
     31   exit 1
     32 fi
     33 
     34 case $1 in
     35 
     36   --is-lightweight)
     37     # Used by our autoconf macros to check whether the available missing
     38     # script is modern enough.
     39     exit 0
     40     ;;
     41 
     42   --run)
     43     # Back-compat with the calling convention used by older automake.
     44     shift
     45     ;;
     46 
     47   -h|--h|--he|--hel|--help)
     48     echo "\
     49 $0 [OPTION]... PROGRAM [ARGUMENT]...
     50 
     51 Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
     52 to PROGRAM being missing or too old.
     53 
     54 Options:
     55   -h, --help      display this help and exit
     56   -v, --version   output version information and exit
     57 
     58 Supported PROGRAM values:
     59 aclocal autoconf autogen  autoheader autom4te automake autoreconf
     60 bison   flex     help2man lex        makeinfo perl     yacc
     61 
     62 Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
     63 'g' are ignored when checking the name.
     64 
     65 Report bugs to <bug-automake@gnu.org>.
     66 GNU Automake home page: <https://www.gnu.org/software/automake/>.
     67 General help using GNU software: <https://www.gnu.org/gethelp/>."
     68     exit $?
     69     ;;
     70 
     71   -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
     72     echo "missing (GNU Automake) $scriptversion"
     73     exit $?
     74     ;;
     75 
     76   -*)
     77     echo 1>&2 "$0: unknown '$1' option"
     78     echo 1>&2 "Try '$0 --help' for more information"
     79     exit 1
     80     ;;
     81 
     82 esac
     83 
     84 # Run the given program, remember its exit status.
     85 "$@"; st=$?
     86 
     87 # If it succeeded, we are done.
     88 test $st -eq 0 && exit 0
     89 
     90 # Also exit now if we it failed (or wasn't found), and '--version' was
     91 # passed; such an option is passed most likely to detect whether the
     92 # program is present and works.
     93 case $2 in --version|--help) exit $st;; esac
     94 
     95 # Exit code 63 means version mismatch.  This often happens when the user
     96 # tries to use an ancient version of a tool on a file that requires a
     97 # minimum version.
     98 if test $st -eq 63; then
     99   msg="probably too old"
    100 elif test $st -eq 127; then
    101   # Program was missing.
    102   msg="missing on your system"
    103 else
    104   # Program was found and executed, but failed.  Give up.
    105   exit $st
    106 fi
    107 
    108 perl_URL=https://www.perl.org/
    109 flex_URL=https://github.com/westes/flex
    110 gnu_software_URL=https://www.gnu.org/software
    111 
    112 program_details ()
    113 {
    114   case $1 in
    115     aclocal|automake|autoreconf)
    116       echo "The '$1' program is part of the GNU Automake package:"
    117       echo "<$gnu_software_URL/automake>"
    118       echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
    119       echo "<$gnu_software_URL/autoconf>"
    120       echo "<$gnu_software_URL/m4/>"
    121       echo "<$perl_URL>"
    122       ;;
    123     autoconf|autom4te|autoheader)
    124       echo "The '$1' program is part of the GNU Autoconf package:"
    125       echo "<$gnu_software_URL/autoconf/>"
    126       echo "It also requires GNU m4 and Perl in order to run:"
    127       echo "<$gnu_software_URL/m4/>"
    128       echo "<$perl_URL>"
    129       ;;
    130     *)
    131       :
    132       ;;
    133   esac
    134 }
    135 
    136 give_advice ()
    137 {
    138   # Normalize program name to check for.
    139   normalized_program=`echo "$1" | sed '
    140     s/^gnu-//; t
    141     s/^gnu//; t
    142     s/^g//; t'`
    143 
    144   printf '%s\n' "'$1' is $msg."
    145 
    146   configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
    147   autoheader_deps="'acconfig.h'"
    148   automake_deps="'Makefile.am'"
    149   aclocal_deps="'acinclude.m4'"
    150   case $normalized_program in
    151     aclocal*)
    152       echo "You should only need it if you modified $aclocal_deps or"
    153       echo "$configure_deps."
    154       ;;
    155     autoconf*)
    156       echo "You should only need it if you modified $configure_deps."
    157       ;;
    158     autogen*)
    159       echo "You should only need it if you modified a '.def' or '.tpl' file."
    160       echo "You may want to install the GNU AutoGen package:"
    161       echo "<$gnu_software_URL/autogen/>"
    162       ;;
    163     autoheader*)
    164       echo "You should only need it if you modified $autoheader_deps or"
    165       echo "$configure_deps."
    166       ;;
    167     automake*)
    168       echo "You should only need it if you modified $automake_deps or"
    169       echo "$configure_deps."
    170       ;;
    171     autom4te*)
    172       echo "You might have modified some maintainer files that require"
    173       echo "the 'autom4te' program to be rebuilt."
    174       ;;
    175     autoreconf*)
    176       echo "You should only need it if you modified $aclocal_deps or"
    177       echo "$automake_deps or $autoheader_deps or $automake_deps or"
    178       echo "$configure_deps."
    179       ;;
    180     bison*|yacc*)
    181       echo "You should only need it if you modified a '.y' file."
    182       echo "You may want to install the GNU Bison package:"
    183       echo "<$gnu_software_URL/bison/>"
    184       ;;
    185     help2man*)
    186       echo "You should only need it if you modified a dependency" \
    187            "of a man page."
    188       echo "You may want to install the GNU Help2man package:"
    189       echo "<$gnu_software_URL/help2man/>"
    190     ;;
    191     lex*|flex*)
    192       echo "You should only need it if you modified a '.l' file."
    193       echo "You may want to install the Fast Lexical Analyzer package:"
    194       echo "<$flex_URL>"
    195       ;;
    196     makeinfo*)
    197       echo "You should only need it if you modified a '.texi' file, or"
    198       echo "any other file indirectly affecting the aspect of the manual."
    199       echo "You might want to install the Texinfo package:"
    200       echo "<$gnu_software_URL/texinfo/>"
    201       echo "The spurious makeinfo call might also be the consequence of"
    202       echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
    203       echo "want to install GNU make:"
    204       echo "<$gnu_software_URL/make/>"
    205       ;;
    206     perl*)
    207       echo "You should only need it to run GNU Autoconf, GNU Automake, "
    208       echo "  assorted other tools, or if you modified a Perl source file."
    209       echo "You may want to install the Perl 5 language interpreter:"
    210       echo "<$perl_URL>"
    211       ;;
    212     *)
    213       echo "You might have modified some files without having the proper"
    214       echo "tools for further handling them.  Check the 'README' file, it"
    215       echo "often tells you about the needed prerequisites for installing"
    216       echo "this package.  You may also peek at any GNU archive site, in"
    217       echo "case some other package contains this missing '$1' program."
    218       ;;
    219   esac
    220   program_details "$normalized_program"
    221 }
    222 
    223 give_advice "$1" | sed -e '1s/^/WARNING: /' \
    224                        -e '2,$s/^/         /' >&2
    225 
    226 # Propagate the correct exit status (expected to be 127 for a program
    227 # not found, 63 for a program that failed due to version mismatch).
    228 exit $st
    229 
    230 # Local variables:
    231 # eval: (add-hook 'before-save-hook 'time-stamp nil t)
    232 # time-stamp-start: "scriptversion="
    233 # time-stamp-format: "%Y-%02m-%02d.%02H"
    234 # time-stamp-time-zone: "UTC0"
    235 # time-stamp-end: "; # UTC"
    236 # End: