xref: /netbsd-src/external/lgpl3/mpc/dist/build-aux/missing (revision 367b82799ab709709d3c3b541df56a2a14644d3e)
190a8ff21Smrg#!/bin/sh
290a8ff21Smrg# Common wrapper for a few potentially missing GNU programs.
390a8ff21Smrg
490a8ff21Smrgscriptversion=2018-03-07.03; # UTC
590a8ff21Smrg
6*367b8279Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc.
790a8ff21Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
890a8ff21Smrg
990a8ff21Smrg# This program is free software; you can redistribute it and/or modify
1090a8ff21Smrg# it under the terms of the GNU General Public License as published by
1190a8ff21Smrg# the Free Software Foundation; either version 2, or (at your option)
1290a8ff21Smrg# any later version.
1390a8ff21Smrg
1490a8ff21Smrg# This program is distributed in the hope that it will be useful,
1590a8ff21Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1690a8ff21Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1790a8ff21Smrg# GNU General Public License for more details.
1890a8ff21Smrg
1990a8ff21Smrg# You should have received a copy of the GNU General Public License
2090a8ff21Smrg# along with this program.  If not, see <https://www.gnu.org/licenses/>.
2190a8ff21Smrg
2290a8ff21Smrg# As a special exception to the GNU General Public License, if you
2390a8ff21Smrg# distribute this file as part of a program that contains a
2490a8ff21Smrg# configuration script generated by Autoconf, you may include it under
2590a8ff21Smrg# the same distribution terms that you use for the rest of that program.
2690a8ff21Smrg
2790a8ff21Smrgif test $# -eq 0; then
2890a8ff21Smrg  echo 1>&2 "Try '$0 --help' for more information"
2990a8ff21Smrg  exit 1
3090a8ff21Smrgfi
3190a8ff21Smrg
3290a8ff21Smrgcase $1 in
3390a8ff21Smrg
3490a8ff21Smrg  --is-lightweight)
3590a8ff21Smrg    # Used by our autoconf macros to check whether the available missing
3690a8ff21Smrg    # script is modern enough.
3790a8ff21Smrg    exit 0
3890a8ff21Smrg    ;;
3990a8ff21Smrg
4090a8ff21Smrg  --run)
4190a8ff21Smrg    # Back-compat with the calling convention used by older automake.
4290a8ff21Smrg    shift
4390a8ff21Smrg    ;;
4490a8ff21Smrg
4590a8ff21Smrg  -h|--h|--he|--hel|--help)
4690a8ff21Smrg    echo "\
4790a8ff21Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
4890a8ff21Smrg
4990a8ff21SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
5090a8ff21Smrgto PROGRAM being missing or too old.
5190a8ff21Smrg
5290a8ff21SmrgOptions:
5390a8ff21Smrg  -h, --help      display this help and exit
5490a8ff21Smrg  -v, --version   output version information and exit
5590a8ff21Smrg
5690a8ff21SmrgSupported PROGRAM values:
5790a8ff21Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
5890a8ff21Smrg  bison     yacc      flex         lex       help2man
5990a8ff21Smrg
6090a8ff21SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
6190a8ff21Smrg'g' are ignored when checking the name.
6290a8ff21Smrg
6390a8ff21SmrgSend bug reports to <bug-automake@gnu.org>."
6490a8ff21Smrg    exit $?
6590a8ff21Smrg    ;;
6690a8ff21Smrg
6790a8ff21Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
6890a8ff21Smrg    echo "missing $scriptversion (GNU Automake)"
6990a8ff21Smrg    exit $?
7090a8ff21Smrg    ;;
7190a8ff21Smrg
7290a8ff21Smrg  -*)
7390a8ff21Smrg    echo 1>&2 "$0: unknown '$1' option"
7490a8ff21Smrg    echo 1>&2 "Try '$0 --help' for more information"
7590a8ff21Smrg    exit 1
7690a8ff21Smrg    ;;
7790a8ff21Smrg
7890a8ff21Smrgesac
7990a8ff21Smrg
8090a8ff21Smrg# Run the given program, remember its exit status.
8190a8ff21Smrg"$@"; st=$?
8290a8ff21Smrg
8390a8ff21Smrg# If it succeeded, we are done.
8490a8ff21Smrgtest $st -eq 0 && exit 0
8590a8ff21Smrg
8690a8ff21Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
8790a8ff21Smrg# passed; such an option is passed most likely to detect whether the
8890a8ff21Smrg# program is present and works.
8990a8ff21Smrgcase $2 in --version|--help) exit $st;; esac
9090a8ff21Smrg
9190a8ff21Smrg# Exit code 63 means version mismatch.  This often happens when the user
9290a8ff21Smrg# tries to use an ancient version of a tool on a file that requires a
9390a8ff21Smrg# minimum version.
9490a8ff21Smrgif test $st -eq 63; then
9590a8ff21Smrg  msg="probably too old"
9690a8ff21Smrgelif test $st -eq 127; then
9790a8ff21Smrg  # Program was missing.
9890a8ff21Smrg  msg="missing on your system"
9990a8ff21Smrgelse
10090a8ff21Smrg  # Program was found and executed, but failed.  Give up.
10190a8ff21Smrg  exit $st
10290a8ff21Smrgfi
10390a8ff21Smrg
10490a8ff21Smrgperl_URL=https://www.perl.org/
10590a8ff21Smrgflex_URL=https://github.com/westes/flex
10690a8ff21Smrggnu_software_URL=https://www.gnu.org/software
10790a8ff21Smrg
10890a8ff21Smrgprogram_details ()
10990a8ff21Smrg{
11090a8ff21Smrg  case $1 in
11190a8ff21Smrg    aclocal|automake)
11290a8ff21Smrg      echo "The '$1' program is part of the GNU Automake package:"
11390a8ff21Smrg      echo "<$gnu_software_URL/automake>"
11490a8ff21Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
11590a8ff21Smrg      echo "<$gnu_software_URL/autoconf>"
11690a8ff21Smrg      echo "<$gnu_software_URL/m4/>"
11790a8ff21Smrg      echo "<$perl_URL>"
11890a8ff21Smrg      ;;
11990a8ff21Smrg    autoconf|autom4te|autoheader)
12090a8ff21Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
12190a8ff21Smrg      echo "<$gnu_software_URL/autoconf/>"
12290a8ff21Smrg      echo "It also requires GNU m4 and Perl in order to run:"
12390a8ff21Smrg      echo "<$gnu_software_URL/m4/>"
12490a8ff21Smrg      echo "<$perl_URL>"
12590a8ff21Smrg      ;;
12690a8ff21Smrg  esac
12790a8ff21Smrg}
12890a8ff21Smrg
12990a8ff21Smrggive_advice ()
13090a8ff21Smrg{
13190a8ff21Smrg  # Normalize program name to check for.
13290a8ff21Smrg  normalized_program=`echo "$1" | sed '
13390a8ff21Smrg    s/^gnu-//; t
13490a8ff21Smrg    s/^gnu//; t
13590a8ff21Smrg    s/^g//; t'`
13690a8ff21Smrg
13790a8ff21Smrg  printf '%s\n' "'$1' is $msg."
13890a8ff21Smrg
13990a8ff21Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
14090a8ff21Smrg  case $normalized_program in
14190a8ff21Smrg    autoconf*)
14290a8ff21Smrg      echo "You should only need it if you modified 'configure.ac',"
14390a8ff21Smrg      echo "or m4 files included by it."
14490a8ff21Smrg      program_details 'autoconf'
14590a8ff21Smrg      ;;
14690a8ff21Smrg    autoheader*)
14790a8ff21Smrg      echo "You should only need it if you modified 'acconfig.h' or"
14890a8ff21Smrg      echo "$configure_deps."
14990a8ff21Smrg      program_details 'autoheader'
15090a8ff21Smrg      ;;
15190a8ff21Smrg    automake*)
15290a8ff21Smrg      echo "You should only need it if you modified 'Makefile.am' or"
15390a8ff21Smrg      echo "$configure_deps."
15490a8ff21Smrg      program_details 'automake'
15590a8ff21Smrg      ;;
15690a8ff21Smrg    aclocal*)
15790a8ff21Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
15890a8ff21Smrg      echo "$configure_deps."
15990a8ff21Smrg      program_details 'aclocal'
16090a8ff21Smrg      ;;
16190a8ff21Smrg   autom4te*)
16290a8ff21Smrg      echo "You might have modified some maintainer files that require"
16390a8ff21Smrg      echo "the 'autom4te' program to be rebuilt."
16490a8ff21Smrg      program_details 'autom4te'
16590a8ff21Smrg      ;;
16690a8ff21Smrg    bison*|yacc*)
16790a8ff21Smrg      echo "You should only need it if you modified a '.y' file."
16890a8ff21Smrg      echo "You may want to install the GNU Bison package:"
16990a8ff21Smrg      echo "<$gnu_software_URL/bison/>"
17090a8ff21Smrg      ;;
17190a8ff21Smrg    lex*|flex*)
17290a8ff21Smrg      echo "You should only need it if you modified a '.l' file."
17390a8ff21Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
17490a8ff21Smrg      echo "<$flex_URL>"
17590a8ff21Smrg      ;;
17690a8ff21Smrg    help2man*)
17790a8ff21Smrg      echo "You should only need it if you modified a dependency" \
17890a8ff21Smrg           "of a man page."
17990a8ff21Smrg      echo "You may want to install the GNU Help2man package:"
18090a8ff21Smrg      echo "<$gnu_software_URL/help2man/>"
18190a8ff21Smrg    ;;
18290a8ff21Smrg    makeinfo*)
18390a8ff21Smrg      echo "You should only need it if you modified a '.texi' file, or"
18490a8ff21Smrg      echo "any other file indirectly affecting the aspect of the manual."
18590a8ff21Smrg      echo "You might want to install the Texinfo package:"
18690a8ff21Smrg      echo "<$gnu_software_URL/texinfo/>"
18790a8ff21Smrg      echo "The spurious makeinfo call might also be the consequence of"
18890a8ff21Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
18990a8ff21Smrg      echo "want to install GNU make:"
19090a8ff21Smrg      echo "<$gnu_software_URL/make/>"
19190a8ff21Smrg      ;;
19290a8ff21Smrg    *)
19390a8ff21Smrg      echo "You might have modified some files without having the proper"
19490a8ff21Smrg      echo "tools for further handling them.  Check the 'README' file, it"
19590a8ff21Smrg      echo "often tells you about the needed prerequisites for installing"
19690a8ff21Smrg      echo "this package.  You may also peek at any GNU archive site, in"
19790a8ff21Smrg      echo "case some other package contains this missing '$1' program."
19890a8ff21Smrg      ;;
19990a8ff21Smrg  esac
20090a8ff21Smrg}
20190a8ff21Smrg
20290a8ff21Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
20390a8ff21Smrg                       -e '2,$s/^/         /' >&2
20490a8ff21Smrg
20590a8ff21Smrg# Propagate the correct exit status (expected to be 127 for a program
20690a8ff21Smrg# not found, 63 for a program that failed due to version mismatch).
20790a8ff21Smrgexit $st
20890a8ff21Smrg
20990a8ff21Smrg# Local variables:
21090a8ff21Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
21190a8ff21Smrg# time-stamp-start: "scriptversion="
21290a8ff21Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
21390a8ff21Smrg# time-stamp-time-zone: "UTC0"
21490a8ff21Smrg# time-stamp-end: "; # UTC"
21590a8ff21Smrg# End:
216