| 1 |
dnl |
| 2 |
dnl Copyright (C) 1996-2026 Free Software Foundation, Inc. |
| 3 |
dnl |
| 4 |
dnl This file is part of GNU Inetutils. |
| 5 |
dnl |
| 6 |
dnl GNU Inetutils is free software: you can redistribute it and/or modify |
| 7 |
dnl it under the terms of the GNU General Public License as published by |
| 8 |
dnl the Free Software Foundation, either version 3 of the License, or (at |
| 9 |
dnl your option) any later version. |
| 10 |
dnl |
| 11 |
dnl GNU Inetutils is distributed in the hope that it will be useful, but |
| 12 |
dnl WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
dnl General Public License for more details. |
| 15 |
dnl |
| 16 |
dnl You should have received a copy of the GNU General Public License |
| 17 |
dnl along with this program. If not, see `http://www.gnu.org/licenses/'. |
| 18 |
|
| 19 |
dnl Written by Miles Bader. |
| 20 |
|
| 21 |
dnl IU_LIB_NCURSES -- check for, and configure, ncurses |
| 22 |
dnl |
| 23 |
dnl If libncurses is found to exist on this system and the --disable-ncurses |
| 24 |
dnl flag wasn't specified, defines LIBNCURSES with the appropriate linker |
| 25 |
dnl specification, and possibly defines NCURSES_INCLUDE with the appropriate |
| 26 |
dnl -I flag to get access to ncurses include files. |
| 27 |
dnl |
| 28 |
AC_DEFUN([IU_LIB_NCURSES], [ |
| 29 |
AC_ARG_ENABLE([ncurses], |
| 30 |
AS_HELP_STRING([--disable-ncurses], |
| 31 |
[don't prefer -lncurses over -lcurses]), |
| 32 |
, [enable_ncurses=yes]) |
| 33 |
if test "$enable_ncurses" = yes; then |
| 34 |
AC_CHECK_LIB(ncurses, initscr, LIBNCURSES="-lncurses") |
| 35 |
if test "$LIBNCURSES"; then |
| 36 |
# Use ncurses header files instead of the ordinary ones, if possible; |
| 37 |
# is there a better way of doing this, that avoids looking in specific |
| 38 |
# directories? |
| 39 |
AC_ARG_WITH([ncurses-include-dir], |
| 40 |
AS_HELP_STRING([--with-ncurses-include-dir=DIR], |
| 41 |
[Set directory containing the include files for |
| 42 |
use with -lncurses, when it isn't installed as |
| 43 |
the default curses library. If DIR is "none", |
| 44 |
then no special ncurses include files are used.])) |
| 45 |
if test "${with_ncurses_include_dir+set}" = set; then |
| 46 |
AC_MSG_CHECKING(for ncurses include dir) |
| 47 |
case "$with_ncurses_include_dir" in |
| 48 |
no|none) |
| 49 |
inetutils_cv_includedir_ncurses=none;; |
| 50 |
*) |
| 51 |
inetutils_cv_includedir_ncurses="$with_ncurses_include_dir";; |
| 52 |
esac |
| 53 |
AC_MSG_RESULT($inetutils_cv_includedir_ncurses) |
| 54 |
else |
| 55 |
AC_CACHE_CHECK(for ncurses include dir, |
| 56 |
inetutils_cv_includedir_ncurses, |
| 57 |
for D in $includedir $prefix/include /local/include /usr/local/include /include /usr/include; do |
| 58 |
if test -d $D/ncurses; then |
| 59 |
inetutils_cv_includedir_ncurses="$D/ncurses" |
| 60 |
break |
| 61 |
fi |
| 62 |
test "$inetutils_cv_includedir_ncurses" \ |
| 63 |
|| inetutils_cv_includedir_ncurses=none |
| 64 |
done) |
| 65 |
fi |
| 66 |
if test "$inetutils_cv_includedir_ncurses" = none; then |
| 67 |
NCURSES_INCLUDE="" |
| 68 |
LIBNCURSES='' |
| 69 |
else |
| 70 |
NCURSES_INCLUDE="-I$inetutils_cv_includedir_ncurses" |
| 71 |
fi |
| 72 |
fi |
| 73 |
fi |
| 74 |
AC_SUBST(NCURSES_INCLUDE) |
| 75 |
AC_SUBST(LIBNCURSES)])dnl |
| 76 |
|
| 77 |
dnl IU_LIB_TERMCAP -- check for various termcap libraries |
| 78 |
dnl |
| 79 |
dnl Checks for various common libraries implementing the termcap interface, |
| 80 |
dnl including ncurses (unless --disable ncurses is specified), curses (which |
| 81 |
dnl does so on some systems), termcap, and termlib. If termcap is found, then |
| 82 |
dnl LIBTERMCAP is defined with the appropriate linker specification. |
| 83 |
dnl |
| 84 |
dnl Solaris is known to offer tgetent encapsulated in libtermcap, but to |
| 85 |
dnl declare tgetent also in <term.h>! When X/Open Curses is present as |
| 86 |
dnl primary implementation, the header file <term.h> is included already |
| 87 |
dnl in <curses.h>, and the first available <term.h> may in fact cause |
| 88 |
dnl contradictions. |
| 89 |
dnl |
| 90 |
AC_DEFUN([IU_LIB_TERMCAP], [ |
| 91 |
AC_REQUIRE([IU_LIB_NCURSES]) |
| 92 |
if test "$LIBNCURSES"; then |
| 93 |
LIBTERMCAP="$LIBNCURSES" |
| 94 |
else |
| 95 |
dnl Must check declaration in different settings, |
| 96 |
dnl so caching in AC_CHECK_DECL is too destructive. |
| 97 |
dnl |
| 98 |
_IU_SAVE_LIBS=$LIBS |
| 99 |
AC_CHECK_LIB(termcap, tgetent, LIBTERMCAP=-ltermcap) |
| 100 |
AC_MSG_CHECKING([whether tgetent needs support]) |
| 101 |
location_tgetent=no |
| 102 |
LIBS="$LIBS $LIBTERMCAP" |
| 103 |
AC_LINK_IFELSE( |
| 104 |
[AC_LANG_PROGRAM([[#include <termcap.h>]], |
| 105 |
[[(void) tgetent((char *) 0, (char *) 0);]])], |
| 106 |
[AC_DEFINE([HAVE_TERMCAP_TGETENT], 1, |
| 107 |
[Define to 1 if tgetent() exists in <termcap.h>.]) |
| 108 |
ac_cv_have_decl_tgetent=yes |
| 109 |
location_tgetent=termcap.h], |
| 110 |
[AC_LINK_IFELSE( |
| 111 |
[AC_LANG_PROGRAM([[#include <curses.h> |
| 112 |
#ifndef _XOPEN_CURSES |
| 113 |
# include <term.h> |
| 114 |
#endif]], |
| 115 |
[[(void) tgetent((char *) 0, (char *) 0);]])], |
| 116 |
[AC_DEFINE([HAVE_CURSES_TGETENT], 1, |
| 117 |
[Define to 1 if tgetent() exists in <term.h>.]) |
| 118 |
ac_cv_have_decl_tgetent=yes |
| 119 |
location_tgetent=term.h]) |
| 120 |
]) |
| 121 |
LIBS=$_IU_SAVE_LIBS |
| 122 |
AC_MSG_RESULT($location_tgetent) |
| 123 |
|
| 124 |
if test "$ac_cv_lib_termcap_tgetent" = yes \ |
| 125 |
&& test "$ac_cv_have_decl_tgetent" = yes; then |
| 126 |
: |
| 127 |
else |
| 128 |
AC_CHECK_LIB(curses, tgetent, LIBTERMCAP=-lcurses) |
| 129 |
AC_CHECK_DECLS([tgetent], , , [[#include <curses.h> |
| 130 |
#ifndef _XOPEN_CURSES |
| 131 |
# include <term.h> |
| 132 |
#endif]]) |
| 133 |
if test "$ac_cv_lib_curses_tgetent" = yes \ |
| 134 |
&& test "$ac_cv_have_decl_tgetent" = yes; then |
| 135 |
AC_DEFINE([HAVE_CURSES_TGETENT], 1) |
| 136 |
fi |
| 137 |
fi |
| 138 |
if test "$ac_cv_lib_curses_tgetent" = no \ |
| 139 |
&& test "$ac_cv_lib_termcap_tgetent" = no; then |
| 140 |
AC_CHECK_LIB(termlib, tgetent, LIBTERMCAP=-ltermlib) |
| 141 |
if test "$ac_cv_lib_termlib_tgetent" = yes; then |
| 142 |
AC_DEFINE([HAVE_TERMLIB_TGETENT], 1, |
| 143 |
[Define to 1 if tgetent() exists in libtermlib.]) |
| 144 |
else |
| 145 |
LIBTERMCAP= |
| 146 |
fi |
| 147 |
fi |
| 148 |
if test -n "$LIBTERMCAP"; then |
| 149 |
AC_DEFINE([HAVE_TGETENT], 1, [Define to 1 if tgetent() exists.]) |
| 150 |
fi |
| 151 |
fi |
| 152 |
AC_SUBST(LIBTERMCAP)])dnl |
| 153 |
|
| 154 |
dnl IU_LIB_CURSES -- check for curses, and associated libraries |
| 155 |
dnl |
| 156 |
dnl Checks for various libraries implementing the curses interface, and if |
| 157 |
dnl found, defines LIBCURSES to be the appropriate linker specification, |
| 158 |
dnl *including* any termcap libraries if needed (some versions of curses |
| 159 |
dnl don't need termcap). |
| 160 |
dnl |
| 161 |
AC_DEFUN([IU_LIB_CURSES], [ |
| 162 |
AC_REQUIRE([IU_LIB_TERMCAP]) |
| 163 |
AC_REQUIRE([IU_LIB_NCURSES]) |
| 164 |
if test "$LIBNCURSES"; then |
| 165 |
LIBCURSES="$LIBNCURSES" # ncurses doesn't require termcap |
| 166 |
else |
| 167 |
_IU_SAVE_LIBS="$LIBS" |
| 168 |
LIBS="$LIBTERMCAP" |
| 169 |
AC_CHECK_LIB(curses, initscr, LIBCURSES="-lcurses") |
| 170 |
if test "$LIBCURSES" \ |
| 171 |
&& test "$LIBTERMCAP" \ |
| 172 |
&& test "$LIBCURSES" != "$LIBTERMCAP"; then |
| 173 |
AC_CACHE_CHECK(whether curses needs $LIBTERMCAP, |
| 174 |
inetutils_cv_curses_needs_termcap, |
| 175 |
LIBS="$LIBCURSES" |
| 176 |
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[initscr ();]])],[inetutils_cv_curses_needs_termcap=no],[inetutils_cv_curses_needs_termcap=yes])) |
| 177 |
if test $inetutils_cv_curses_needs_termcap = yes; then |
| 178 |
LIBCURSES="$LIBCURSES $LIBTERMCAP" |
| 179 |
fi |
| 180 |
fi |
| 181 |
LIBS="$_IU_SAVE_LIBS" |
| 182 |
fi |
| 183 |
AC_SUBST(LIBCURSES)])dnl |