Skip to content

Commit f27b8fd

Browse files
committed
Low: build: Ignore curses library unless it's ncurses
INSTALL.md already documents the need for ncurses if a user wants to use crm_mon in interactive mode. Also, we require NCURSES_CONST to be defined in that case; this has been true since bd203b2. So we might as well require ncurses explicitly and drop support for "regular" curses. This shouldn't change behavior. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
1 parent a4d65ca commit f27b8fd

3 files changed

Lines changed: 33 additions & 37 deletions

File tree

configure.ac

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,46 +1292,41 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]], [[sighandler_t *f;]]
12921292
dnl ========================================================================
12931293
dnl ncurses
12941294
dnl ========================================================================
1295-
dnl
1296-
dnl A few OSes (e.g. Linux) deliver a default "ncurses" alongside "curses".
1297-
dnl Many non-Linux deliver "curses"; sites may add "ncurses".
1298-
dnl
1299-
dnl However, the source-code recommendation for both is to #include "curses.h"
1300-
dnl (i.e. "ncurses" still wants the include to be simple, no-'n', "curses.h").
1301-
dnl
1302-
dnl ncurses takes precedence.
1303-
dnl
1304-
found_curses_header=0
1295+
1296+
found_ncurses_header=0
13051297

13061298
m4_foreach(
1307-
[header],
1308-
[[curses.h], [curses/curses.h], [ncurses.h], [ncurses/ncurses.h]],
1299+
[header], [[ncurses.h], [ncurses/ncurses.h]],
13091300
[AS_IF(
1310-
[test "$found_curses_header" -eq 0],
1301+
[test "$found_ncurses_header" -eq 0],
13111302
[AC_CHECK_HEADER(
13121303
header,
13131304
[
1314-
found_curses_header=1
1315-
AC_DEFINE([PCMK__CURSES_H], [<header>], [Curses header file])
1305+
found_ncurses_header=1
1306+
AC_DEFINE([PCMK__NCURSES_H], [<header>], [Ncurses header file])
13161307
]
13171308
)]
13181309
)]
13191310
)
13201311

13211312
save_LIBS="$LIBS"
1322-
found_curses=0
1323-
CURSES_LIBS=""
1313+
found_ncurses=0
1314+
NCURSES_LIBS=""
13241315
LIBS=""
1325-
AC_SEARCH_LIBS([printw], [ncurses curses],
1326-
[test "$ac_cv_search_printw" = "none required" || CURSES_LIBS="$LIBS"
1327-
found_curses=1],
1328-
[found_curses=0])
1316+
AC_SEARCH_LIBS(
1317+
[printw], [ncurses],
1318+
[
1319+
test "$ac_cv_search_printw" = "none required" || NCURSES_LIBS="$LIBS"
1320+
found_ncurses=1
1321+
],
1322+
[found_ncurses=0]
1323+
)
13291324
LIBS="$save_LIBS"
13301325

13311326
dnl Check for printw() prototype compatibility
1332-
AS_IF([test $found_curses -eq 1 && cc_supports_flag -Wcast-qual], [
1327+
AS_IF([test $found_ncurses -eq 1 && cc_supports_flag -Wcast-qual], [
13331328
ac_save_LIBS="$LIBS"
1334-
LIBS="$CURSES_LIBS"
1329+
LIBS="$NCURSES_LIBS"
13351330
13361331
# avoid broken test because of hardened build environment in Fedora 23+
13371332
# - https://fedoraproject.org/wiki/Changes/Harden_All_Packages
@@ -1340,12 +1335,12 @@ AS_IF([test $found_curses -eq 1 && cc_supports_flag -Wcast-qual], [
13401335
[cc_temp_flags "-Wcast-qual $WERROR -fPIC"],
13411336
[cc_temp_flags "-Wcast-qual $WERROR"])
13421337
1343-
AC_MSG_CHECKING([whether curses library is compatible])
1338+
AC_MSG_CHECKING([whether ncurses library is compatible])
13441339
AC_LINK_IFELSE(
13451340
[AC_LANG_PROGRAM(
13461341
[
1347-
#ifdef PCMK__CURSES_H
1348-
#include PCMK__CURSES_H
1342+
#ifdef PCMK__NCURSES_H
1343+
#include PCMK__NCURSES_H
13491344
#endif
13501345
],
13511346
[printw((NCURSES_CONST char *) "Test");]
@@ -1354,12 +1349,12 @@ AS_IF([test $found_curses -eq 1 && cc_supports_flag -Wcast-qual], [
13541349
PCMK_FEATURES="$PCMK_FEATURES ncurses"
13551350
],
13561351
[
1357-
found_curses=0
1358-
CURSES_LIBS=""
1352+
found_ncurses=0
1353+
NCURSES_LIBS=""
13591354
AC_MSG_RESULT([no])
1360-
AC_MSG_WARN(m4_normalize([Disabling curses because the printw()
1361-
function of your (n)curses library is old.
1362-
If you wish to enable curses, update to a
1355+
AC_MSG_WARN(m4_normalize([Disabling ncurses because the printw()
1356+
function of your ncurses library is old.
1357+
If you wish to enable ncurses, update to a
13631358
newer version (ncurses 5.4 or later is
13641359
recommended, available from
13651360
https://invisible-island.net/ncurses/)
@@ -1371,8 +1366,9 @@ AS_IF([test $found_curses -eq 1 && cc_supports_flag -Wcast-qual], [
13711366
cc_restore_flags
13721367
])
13731368

1374-
AC_DEFINE_UNQUOTED([PCMK__ENABLE_CURSES], [$found_curses], [have ncurses library])
1375-
AC_SUBST(CURSES_LIBS)
1369+
AC_DEFINE_UNQUOTED([PCMK__ENABLE_CURSES], [$found_ncurses],
1370+
[have ncurses library])
1371+
AC_SUBST(NCURSES_LIBS)
13761372

13771373
dnl ========================================================================
13781374
dnl Profiling and GProf

tools/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ crm_mon_LDADD += $(top_builddir)/lib/pengine/libpe_status.la
9999
crm_mon_LDADD += $(top_builddir)/lib/fencing/libstonithd.la
100100
crm_mon_LDADD += $(top_builddir)/lib/cib/libcib.la
101101
crm_mon_LDADD += $(top_builddir)/lib/common/libcrmcommon.la
102-
crm_mon_LDADD += $(CURSES_LIBS)
102+
crm_mon_LDADD += $(NCURSES_LIBS)
103103

104104
crm_verify_SOURCES = crm_verify.c
105105
crm_verify_LDADD = $(top_builddir)/lib/pacemaker/libpacemaker.la

tools/crm_mon.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
#include <crm/common/scheduler.h>
1919
#include <crm/stonith-ng.h>
2020

21-
#if (PCMK__ENABLE_CURSES && defined(PCMK__CURSES_H))
22-
#include PCMK__CURSES_H
23-
#endif // (PCMK__ENABLE_CURSES && defined(PCMK__CURSES_H))
21+
#if (PCMK__ENABLE_CURSES && defined(PCMK__NCURSES_H))
22+
#include PCMK__NCURSES_H
23+
#endif // (PCMK__ENABLE_CURSES && defined(PCMK__NCURSES_H))
2424

2525
typedef enum {
2626
mon_output_unset,

0 commit comments

Comments
 (0)