xref: /netbsd-src/external/bsd/tmux/dist/etc/missing (revision 8f3b94834e97ac2c2a7fe1b0ae81072bf0844b41)
14e179ddaSchristos#! /bin/sh
24e179ddaSchristos# Common wrapper for a few potentially missing GNU programs.
34e179ddaSchristos
4*8f3b9483Schristosscriptversion=2016-01-11.22; # UTC
54e179ddaSchristos
6*8f3b9483Schristos# Copyright (C) 1996-2017 Free Software Foundation, Inc.
74e179ddaSchristos# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
84e179ddaSchristos
94e179ddaSchristos# This program is free software; you can redistribute it and/or modify
104e179ddaSchristos# it under the terms of the GNU General Public License as published by
114e179ddaSchristos# the Free Software Foundation; either version 2, or (at your option)
124e179ddaSchristos# any later version.
134e179ddaSchristos
144e179ddaSchristos# This program is distributed in the hope that it will be useful,
154e179ddaSchristos# but WITHOUT ANY WARRANTY; without even the implied warranty of
164e179ddaSchristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
174e179ddaSchristos# GNU General Public License for more details.
184e179ddaSchristos
194e179ddaSchristos# You should have received a copy of the GNU General Public License
204e179ddaSchristos# along with this program.  If not, see <http://www.gnu.org/licenses/>.
214e179ddaSchristos
224e179ddaSchristos# As a special exception to the GNU General Public License, if you
234e179ddaSchristos# distribute this file as part of a program that contains a
244e179ddaSchristos# configuration script generated by Autoconf, you may include it under
254e179ddaSchristos# the same distribution terms that you use for the rest of that program.
264e179ddaSchristos
274e179ddaSchristosif test $# -eq 0; then
284e179ddaSchristos  echo 1>&2 "Try '$0 --help' for more information"
294e179ddaSchristos  exit 1
304e179ddaSchristosfi
314e179ddaSchristos
324e179ddaSchristoscase $1 in
334e179ddaSchristos
344e179ddaSchristos  --is-lightweight)
354e179ddaSchristos    # Used by our autoconf macros to check whether the available missing
364e179ddaSchristos    # script is modern enough.
374e179ddaSchristos    exit 0
384e179ddaSchristos    ;;
394e179ddaSchristos
404e179ddaSchristos  --run)
414e179ddaSchristos    # Back-compat with the calling convention used by older automake.
424e179ddaSchristos    shift
434e179ddaSchristos    ;;
444e179ddaSchristos
454e179ddaSchristos  -h|--h|--he|--hel|--help)
464e179ddaSchristos    echo "\
474e179ddaSchristos$0 [OPTION]... PROGRAM [ARGUMENT]...
484e179ddaSchristos
494e179ddaSchristosRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
504e179ddaSchristosto PROGRAM being missing or too old.
514e179ddaSchristos
524e179ddaSchristosOptions:
534e179ddaSchristos  -h, --help      display this help and exit
544e179ddaSchristos  -v, --version   output version information and exit
554e179ddaSchristos
564e179ddaSchristosSupported PROGRAM values:
574e179ddaSchristos  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
584e179ddaSchristos  bison     yacc      flex         lex       help2man
594e179ddaSchristos
604e179ddaSchristosVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
614e179ddaSchristos'g' are ignored when checking the name.
624e179ddaSchristos
634e179ddaSchristosSend bug reports to <bug-automake@gnu.org>."
644e179ddaSchristos    exit $?
654e179ddaSchristos    ;;
664e179ddaSchristos
674e179ddaSchristos  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
684e179ddaSchristos    echo "missing $scriptversion (GNU Automake)"
694e179ddaSchristos    exit $?
704e179ddaSchristos    ;;
714e179ddaSchristos
724e179ddaSchristos  -*)
734e179ddaSchristos    echo 1>&2 "$0: unknown '$1' option"
744e179ddaSchristos    echo 1>&2 "Try '$0 --help' for more information"
754e179ddaSchristos    exit 1
764e179ddaSchristos    ;;
774e179ddaSchristos
784e179ddaSchristosesac
794e179ddaSchristos
804e179ddaSchristos# Run the given program, remember its exit status.
814e179ddaSchristos"$@"; st=$?
824e179ddaSchristos
834e179ddaSchristos# If it succeeded, we are done.
844e179ddaSchristostest $st -eq 0 && exit 0
854e179ddaSchristos
864e179ddaSchristos# Also exit now if we it failed (or wasn't found), and '--version' was
874e179ddaSchristos# passed; such an option is passed most likely to detect whether the
884e179ddaSchristos# program is present and works.
894e179ddaSchristoscase $2 in --version|--help) exit $st;; esac
904e179ddaSchristos
914e179ddaSchristos# Exit code 63 means version mismatch.  This often happens when the user
924e179ddaSchristos# tries to use an ancient version of a tool on a file that requires a
934e179ddaSchristos# minimum version.
944e179ddaSchristosif test $st -eq 63; then
954e179ddaSchristos  msg="probably too old"
964e179ddaSchristoselif test $st -eq 127; then
974e179ddaSchristos  # Program was missing.
984e179ddaSchristos  msg="missing on your system"
994e179ddaSchristoselse
1004e179ddaSchristos  # Program was found and executed, but failed.  Give up.
1014e179ddaSchristos  exit $st
1024e179ddaSchristosfi
1034e179ddaSchristos
1044e179ddaSchristosperl_URL=http://www.perl.org/
1054e179ddaSchristosflex_URL=http://flex.sourceforge.net/
1064e179ddaSchristosgnu_software_URL=http://www.gnu.org/software
1074e179ddaSchristos
1084e179ddaSchristosprogram_details ()
1094e179ddaSchristos{
1104e179ddaSchristos  case $1 in
1114e179ddaSchristos    aclocal|automake)
1124e179ddaSchristos      echo "The '$1' program is part of the GNU Automake package:"
1134e179ddaSchristos      echo "<$gnu_software_URL/automake>"
1144e179ddaSchristos      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1154e179ddaSchristos      echo "<$gnu_software_URL/autoconf>"
1164e179ddaSchristos      echo "<$gnu_software_URL/m4/>"
1174e179ddaSchristos      echo "<$perl_URL>"
1184e179ddaSchristos      ;;
1194e179ddaSchristos    autoconf|autom4te|autoheader)
1204e179ddaSchristos      echo "The '$1' program is part of the GNU Autoconf package:"
1214e179ddaSchristos      echo "<$gnu_software_URL/autoconf/>"
1224e179ddaSchristos      echo "It also requires GNU m4 and Perl in order to run:"
1234e179ddaSchristos      echo "<$gnu_software_URL/m4/>"
1244e179ddaSchristos      echo "<$perl_URL>"
1254e179ddaSchristos      ;;
1264e179ddaSchristos  esac
1274e179ddaSchristos}
1284e179ddaSchristos
1294e179ddaSchristosgive_advice ()
1304e179ddaSchristos{
1314e179ddaSchristos  # Normalize program name to check for.
1324e179ddaSchristos  normalized_program=`echo "$1" | sed '
1334e179ddaSchristos    s/^gnu-//; t
1344e179ddaSchristos    s/^gnu//; t
1354e179ddaSchristos    s/^g//; t'`
1364e179ddaSchristos
1374e179ddaSchristos  printf '%s\n' "'$1' is $msg."
1384e179ddaSchristos
1394e179ddaSchristos  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1404e179ddaSchristos  case $normalized_program in
1414e179ddaSchristos    autoconf*)
1424e179ddaSchristos      echo "You should only need it if you modified 'configure.ac',"
1434e179ddaSchristos      echo "or m4 files included by it."
1444e179ddaSchristos      program_details 'autoconf'
1454e179ddaSchristos      ;;
1464e179ddaSchristos    autoheader*)
1474e179ddaSchristos      echo "You should only need it if you modified 'acconfig.h' or"
1484e179ddaSchristos      echo "$configure_deps."
1494e179ddaSchristos      program_details 'autoheader'
1504e179ddaSchristos      ;;
1514e179ddaSchristos    automake*)
1524e179ddaSchristos      echo "You should only need it if you modified 'Makefile.am' or"
1534e179ddaSchristos      echo "$configure_deps."
1544e179ddaSchristos      program_details 'automake'
1554e179ddaSchristos      ;;
1564e179ddaSchristos    aclocal*)
1574e179ddaSchristos      echo "You should only need it if you modified 'acinclude.m4' or"
1584e179ddaSchristos      echo "$configure_deps."
1594e179ddaSchristos      program_details 'aclocal'
1604e179ddaSchristos      ;;
1614e179ddaSchristos   autom4te*)
1624e179ddaSchristos      echo "You might have modified some maintainer files that require"
1634e179ddaSchristos      echo "the 'autom4te' program to be rebuilt."
1644e179ddaSchristos      program_details 'autom4te'
1654e179ddaSchristos      ;;
1664e179ddaSchristos    bison*|yacc*)
1674e179ddaSchristos      echo "You should only need it if you modified a '.y' file."
1684e179ddaSchristos      echo "You may want to install the GNU Bison package:"
1694e179ddaSchristos      echo "<$gnu_software_URL/bison/>"
1704e179ddaSchristos      ;;
1714e179ddaSchristos    lex*|flex*)
1724e179ddaSchristos      echo "You should only need it if you modified a '.l' file."
1734e179ddaSchristos      echo "You may want to install the Fast Lexical Analyzer package:"
1744e179ddaSchristos      echo "<$flex_URL>"
1754e179ddaSchristos      ;;
1764e179ddaSchristos    help2man*)
1774e179ddaSchristos      echo "You should only need it if you modified a dependency" \
1784e179ddaSchristos           "of a man page."
1794e179ddaSchristos      echo "You may want to install the GNU Help2man package:"
1804e179ddaSchristos      echo "<$gnu_software_URL/help2man/>"
1814e179ddaSchristos    ;;
1824e179ddaSchristos    makeinfo*)
1834e179ddaSchristos      echo "You should only need it if you modified a '.texi' file, or"
1844e179ddaSchristos      echo "any other file indirectly affecting the aspect of the manual."
1854e179ddaSchristos      echo "You might want to install the Texinfo package:"
1864e179ddaSchristos      echo "<$gnu_software_URL/texinfo/>"
1874e179ddaSchristos      echo "The spurious makeinfo call might also be the consequence of"
1884e179ddaSchristos      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1894e179ddaSchristos      echo "want to install GNU make:"
1904e179ddaSchristos      echo "<$gnu_software_URL/make/>"
1914e179ddaSchristos      ;;
1924e179ddaSchristos    *)
1934e179ddaSchristos      echo "You might have modified some files without having the proper"
1944e179ddaSchristos      echo "tools for further handling them.  Check the 'README' file, it"
1954e179ddaSchristos      echo "often tells you about the needed prerequisites for installing"
1964e179ddaSchristos      echo "this package.  You may also peek at any GNU archive site, in"
1974e179ddaSchristos      echo "case some other package contains this missing '$1' program."
1984e179ddaSchristos      ;;
1994e179ddaSchristos  esac
2004e179ddaSchristos}
2014e179ddaSchristos
2024e179ddaSchristosgive_advice "$1" | sed -e '1s/^/WARNING: /' \
2034e179ddaSchristos                       -e '2,$s/^/         /' >&2
2044e179ddaSchristos
2054e179ddaSchristos# Propagate the correct exit status (expected to be 127 for a program
2064e179ddaSchristos# not found, 63 for a program that failed due to version mismatch).
2074e179ddaSchristosexit $st
2084e179ddaSchristos
2094e179ddaSchristos# Local variables:
2104e179ddaSchristos# eval: (add-hook 'write-file-hooks 'time-stamp)
2114e179ddaSchristos# time-stamp-start: "scriptversion="
2124e179ddaSchristos# time-stamp-format: "%:y-%02m-%02d.%02H"
213*8f3b9483Schristos# time-stamp-time-zone: "UTC0"
2144e179ddaSchristos# time-stamp-end: "; # UTC"
2154e179ddaSchristos# End:
216