From 94a8bf0d6c869b1e6bde637dd25666d2f4cb7052 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 10 Jan 2014 12:28:02 +0100 Subject: [PATCH] Add support for both, ncurses and ncursesw. --- configure.ac | 20 +++++++++++++++++--- src/Makefile.am | 2 +- src/oping.c | 11 ++++++++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 6eb4b4b..f9be869 100644 --- a/configure.ac +++ b/configure.ac @@ -185,11 +185,25 @@ AC_CHECK_FUNCS(nanosleep, [], AC_MSG_ERROR(cannot find nanosleep))) AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes") -with_ncurses="yes" -AC_CHECK_HEADERS(ncursesw/ncurses.h, [with_ncurses="yes"], [with_ncurses="no"]) +with_ncurses="no" +AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses.h, [with_ncurses="yes"], []) if test "x$with_ncurses" = "xyes" then - AC_CHECK_LIB(ncursesw, mvwprintw, [with_ncurses="yes"], [with_ncurses="no"]) + have_ncursesw="no" + have_ncurses="no" + NCURSES_LIB="" + + AC_CHECK_LIB(ncursesw, mvwprintw, [have_ncursesw="yes"], [have_ncursesw="no"]) + AC_CHECK_LIB(ncurses, mvwprintw, [have_ncurses="yes"], [have_ncurses="no"]) + + if test "x$have_ncursesw" = "xyes"; then + NCURSES_LIB="-lncursesw" + else if test "x$have_ncurses" = "xyes"; then + NCURSES_LIB="-lncurses" + else + with_ncurses="no" + fi; fi + AC_SUBST(NCURSES_LIB) fi AM_CONDITIONAL(BUILD_WITH_LIBNCURSES, test "x$with_ncurses" = "xyes") diff --git a/src/Makefile.am b/src/Makefile.am index c266883..844e0a4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,7 @@ bin_PROGRAMS += noping noping_SOURCES = oping.c noping_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_NCURSES=1 -noping_LDADD = liboping.la -lm -lncursesw +noping_LDADD = liboping.la -lm $(NCURSES_LIB) if BUILD_WITH_LIBRT noping_LDADD += -lrt endif diff --git a/src/oping.c b/src/oping.c index a19c420..4a60553 100644 --- a/src/oping.c +++ b/src/oping.c @@ -81,7 +81,12 @@ # define NCURSES_OPAQUE 1 /* http://newsgroups.derkeiler.com/Archive/Rec/rec.games.roguelike.development/2010-09/msg00050.html */ # define _X_OPEN_SOURCE_EXTENDED -# include + +# if HAVE_NCURSESW_NCURSES_H +# include +# elif HAVE_NCURSES_H +# include +# endif # define OPING_GREEN 1 # define OPING_YELLOW 2 @@ -652,6 +657,7 @@ static void time_calc (struct timespec *ts_dest, /* {{{ */ #if USE_NCURSES static _Bool has_utf8() /* {{{ */ { +# if HAVE_NCURSESW_NCURSES_H if (!opt_utf8) { /* Automatically determine */ @@ -661,6 +667,9 @@ static _Bool has_utf8() /* {{{ */ opt_utf8 = 1; } return ((_Bool) (opt_utf8 - 1)); +# else + return (0); +# endif } /* }}} _Bool has_utf8 */ static int update_prettyping_graph (ping_context_t *ctx, /* {{{ */ -- 2.30.2