Add support for both, ncurses and ncursesw.
authorFlorian Forster <ff@octo.it>
Fri, 10 Jan 2014 11:28:02 +0000 (12:28 +0100)
committerFlorian Forster <ff@octo.it>
Fri, 10 Jan 2014 11:28:02 +0000 (12:28 +0100)
configure.ac
src/Makefile.am
src/oping.c

index 6eb4b4b..f9be869 100644 (file)
@@ -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")
 
index c266883..844e0a4 100644 (file)
@@ -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
index a19c420..4a60553 100644 (file)
 # define NCURSES_OPAQUE 1
 /* http://newsgroups.derkeiler.com/Archive/Rec/rec.games.roguelike.development/2010-09/msg00050.html */
 # define _X_OPEN_SOURCE_EXTENDED
-# include <ncursesw/ncurses.h>
+
+# if HAVE_NCURSESW_NCURSES_H
+#  include <ncursesw/ncurses.h>
+# elif HAVE_NCURSES_H
+#  include <ncurses.h>
+# 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, /* {{{ */