From 65734533be4b5ebc5acc0c842582ab18496cc299 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 3 Sep 2022 18:42:13 +0200 Subject: [PATCH] termcap: Fix link error on AIX 7. * m4/termcap.m4 (gl_TERMCAP_BODY): Search also for libxcurses and for libcurses, like gl_TERMINFO_BODY does. * m4/terminfo.m4 (gl_TERMINFO_BODY): Update platform list in comment. --- ChangeLog | 7 ++++++ m4/termcap.m4 | 60 ++++++++++++++++++++++++++++++++++++++++++++++++-- m4/terminfo.m4 | 2 +- 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0834c53031..9100ca7d30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2022-09-03 Bruno Haible + + termcap: Fix link error on AIX 7. + * m4/termcap.m4 (gl_TERMCAP_BODY): Search also for libxcurses and for + libcurses, like gl_TERMINFO_BODY does. + * m4/terminfo.m4 (gl_TERMINFO_BODY): Update platform list in comment. + 2022-09-02 Bruno Haible getrandom: Fix compilation error in C++ mode on FreeBSD 12. diff --git a/m4/termcap.m4 b/m4/termcap.m4 index 89765a5352..ce14890be5 100644 --- a/m4/termcap.m4 +++ b/m4/termcap.m4 @@ -1,4 +1,4 @@ -# termcap.m4 serial 9 +# termcap.m4 serial 10 dnl Copyright (C) 2000-2022 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -52,6 +52,14 @@ AC_DEFUN([gl_TERMCAP_BODY], dnl accordingly. AC_LIB_LINKFLAGS_BODY([termcap]) + dnl Search for libxcurses and define LIBXCURSES, LTLIBXCURSES and INCXCURSES + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([xcurses]) + + dnl Search for libcurses and define LIBCURSES, LTLIBCURSES and INCCURSES + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([curses]) + else LIBNCURSES= @@ -62,6 +70,14 @@ AC_DEFUN([gl_TERMCAP_BODY], LTLIBTERMCAP= INCTERMCAP= + LIBXCURSES= + LTLIBXCURSES= + INCXCURSES= + + LIBCURSES= + LTLIBCURSES= + INCCURSES= + fi AC_CACHE_CHECK([where termcap library functions come from], [gl_cv_termcap], [ @@ -104,6 +120,36 @@ AC_DEFUN([gl_TERMCAP_BODY], [[return tgetent ((char *) 0, "xterm");]])], [gl_cv_termcap=libtermcap]) LIBS="$gl_save_LIBS" + if test "$gl_cv_termcap" != libtermcap; then + gl_save_LIBS="$LIBS" + LIBS="$LIBS $LIBXCURSES" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[extern + #ifdef __cplusplus + "C" + #endif + int tgetent (char *, const char *); + ]], + [[return tgetent ((char *) 0, "xterm");]])], + [gl_cv_termcap=libxcurses]) + LIBS="$gl_save_LIBS" + if test "$gl_cv_termcap" != libxcurses; then + gl_save_LIBS="$LIBS" + LIBS="$LIBS $LIBCURSES" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[extern + #ifdef __cplusplus + "C" + #endif + int tgetent (char *, const char *); + ]], + [[return tgetent ((char *) 0, "xterm");]])], + [gl_cv_termcap=libcurses]) + LIBS="$gl_save_LIBS" + fi + fi fi fi ]) @@ -120,6 +166,16 @@ AC_DEFUN([gl_TERMCAP_BODY], ;; libtermcap) ;; + libxcurses) + LIBTERMCAP="$LIBXCURSES" + LTLIBTERMCAP="$LTLIBXCURSES" + INCTERMCAP="$INCXCURSES" + ;; + libcurses) + LIBTERMCAP="$LIBCURSES" + LTLIBTERMCAP="$LTLIBCURSES" + INCTERMCAP="$INCCURSES" + ;; "not found"*) LIBTERMCAP= LTLIBTERMCAP= @@ -127,7 +183,7 @@ AC_DEFUN([gl_TERMCAP_BODY], ;; esac case "$gl_cv_termcap" in - libc | libncurses | libtermcap) + libc | libncurses | libtermcap | libxcurses | libcurses) AC_DEFINE([HAVE_TERMCAP], 1, [Define if tgetent(), tgetnum(), tgetstr(), tgetflag() are among the termcap library functions.]) diff --git a/m4/terminfo.m4 b/m4/terminfo.m4 index 7daa4d5513..4e9af63699 100644 --- a/m4/terminfo.m4 +++ b/m4/terminfo.m4 @@ -30,7 +30,7 @@ AC_DEFUN([gl_TERMINFO_BODY], dnl tgetflag(), e.g. Linux (in libncurses) or Solaris (in libtermcap = dnl libncurses). dnl Some systems have them in a different library, e.g. OSF/1 (in libcurses, - dnl not in libtermcap) or HP-UX (in libxcurses, not in libtermcap). + dnl not in libtermcap) or AIX, HP-UX (in libxcurses, not in libtermcap). dnl Some systems, like NetBSD or BeOS, don't have these functions at all; dnl they have only a libtermcap. dnl Some systems, like BeOS, use GNU termcap, which has tparam() instead of -- 2.39.5