]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
build-sys: use pkg-config to find ncurses
authorSami Kerola <kerolasa@iki.fi>
Thu, 18 Aug 2016 20:52:39 +0000 (21:52 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 21 Aug 2016 14:51:42 +0000 (15:51 +0100)
The curses function attron() has been part of posix since 1997.  There is no
need to go-around for it.

Reference: http://pubs.opengroup.org/onlinepubs/7908799/xcurses/attron.html

Makefile.am
configure.ac
curses.c
display.c
split.c

index 0e740a933864547d70919a9b0a0ebabfdffd34a1..5ee48c3dc1e42b6a25885d2de55d1e76025a8ea2 100644 (file)
@@ -23,14 +23,14 @@ if IPINFO
 mtr_SOURCES += asn.c asn.h
 endif
 
-EXTRA_mtr_SOURCES = curses.c
+if WITH_NCURSES
+mtr_SOURCES += curses.c
+endif
 
 if WITH_GTK
 mtr_SOURCES += gtk.c
 endif
 
-mtr_DEPENDENCIES = $(CURSES_OBJ)
-mtr_LDFLAGS = $(CURSES_OBJ)
 mtr_INCLUDES = $(GLIB_CFLAGS) -I$(top_builddir) -I$(top_srcdir)
 mtr_CFLAGS = $(GTK_CFLAGS) $(NCURSES_CFLAGS)
-mtr_LDADD = $(GTK_LIBS) $(NCURSES_LDADD) $(RESOLV_LIBS)
+mtr_LDADD = $(GTK_LIBS) $(NCURSES_LIBS) $(RESOLV_LIBS)
index 92e2cefb575e965af6acad305a0c8ffb367c7543..5b73470603976ab8c4d60a2e71d3f2debbb07bd4 100644 (file)
@@ -15,9 +15,6 @@ m4_ifdef([AM_SILENT_RULES],
   [AM_SILENT_RULES([yes])],
   [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
 
-AC_SUBST([CURSES_OBJ])
-CURSES_OBJ=curses.o
-
 AC_PROG_CC
 
 # Check pkg-config availability.
@@ -50,24 +47,8 @@ AC_CHECK_HEADERS([ \
   sys/xti.h \
 ])
 
-# Find ncursses.
-AC_SEARCH_LIBS([initscr],
-  [ncurses curses cursesX],
-  [],
-  [AC_MSG_WARN([Building without curses display support])
-  AC_DEFINE([NO_CURSES], [1], [Define if you don't have the curses libraries available.])
-  CURSES_OBJ=])
-
-AC_CHECK_LIB([ncurses],
-  [use_default_colors],
-  [AC_DEFINE([HAVE_USE_DEFAULT_COLORS],
-    [1],
-    [Define this if your curses library has the use_default_colors() command.])
-  ])
-
 # Check functions.
 AC_CHECK_FUNCS([ \
-  attron \
   fcntl \
 ])
 
@@ -84,6 +65,24 @@ AS_IF([test "x$with_gtk" = "xyes"],
 ])
 AM_CONDITIONAL([WITH_GTK], [test "x$with_gtk" = xyes])
 
+# Find ncurses
+AC_ARG_WITH([ncurses],
+  [AS_HELP_STRING([--without-ncurses], [Build without the ncurses interface])],
+  [], [with_ncurses=yes])
+AS_IF([test "x$with_ncurses" = "xyes"],
+  [PKG_CHECK_MODULES([NCURSES], [ncurses], [
+      AC_DEFINE([HAVE_NCURSES], [1], [Define if ncurses library available])
+      AC_CHECK_LIB([ncurses],
+        [use_default_colors],
+        [AC_DEFINE([HAVE_USE_DEFAULT_COLORS], [1],
+          [Define this if your curses library has the use_default_colors() command.]
+        )
+      ])
+    ],
+    [with_ncurses=no])
+])
+AM_CONDITIONAL([WITH_NCURSES], [test "x$with_ncurses" = xyes])
+
 # Enable ipinfo
 AC_ARG_WITH([ipinfo],
   [AS_HELP_STRING([--without-ipinfo], [Do not try to use ipinfo lookup at all])],
index 4850589333375e0f25cc247ea2f1914319ebfeae..4d8f43606acb5513281f3547c1986518755c1261 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -21,7 +21,7 @@
 #include <strings.h>
 #include <unistd.h>
 
-#ifndef NO_CURSES
+#ifdef HAVE_NCURSES
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 #  error No curses header file available
 #endif
 
-#ifndef HAVE_ATTRON
-#define attron(x) 
-#define attroff(x) 
-#endif
-
 #ifndef getmaxyx
 #  define getmaxyx(win,y,x)    ((y) = (win)->_maxy + 1, (x) = (win)->_maxx + 1)
 #endif
index 0c5b0e9a08f7efee7e7520c8dd5fd89b2dc502a2..1f0d294f221aff5f65eee5ab4cbdb8c708dd0ae3 100644 (file)
--- a/display.c
+++ b/display.c
 
 extern int DisplayMode;
 
-#ifdef NO_CURSES
+#ifdef HAVE_NCURSES
+#include "mtr-curses.h"
+#else
 // No support for curses mode, allow the calls to remain in the code.
 #define mtr_curses_open()
 #define mtr_curses_close()
 #define mtr_curses_redraw()
 #define mtr_curses_keyaction() 0
 #define mtr_curses_clear()
-#else
-#include "mtr-curses.h"
 #endif
 
 #ifdef HAVE_GTK
@@ -72,10 +72,10 @@ extern int DisplayMode;
 #define asn_close()
 #endif
 
-#ifdef NO_CURSES
-#define DEFAULT_DISPLAY DisplayReport
-#else
+#ifdef HAVE_NCURSES
 #define DEFAULT_DISPLAY DisplayCurses
+#else
+#define DEFAULT_DISPLAY DisplayReport
 #endif
 
 #ifdef HAVE_GTK
diff --git a/split.c b/split.c
index 5ead23538b94df0b040d6cf4c258583bcc77a736..937ab9d9fd0c777b5553a7102cd29a395cf45caa 100644 (file)
--- a/split.c
+++ b/split.c
 #include "net.h"
 #include "split.h"
 
-#ifdef NO_CURSES
-#include <sys/time.h>
-#include <sys/types.h>
-#include <unistd.h>
-#else
-/* Use the curses variant */
-
-#if defined(HAVE_NCURSES_H)
+#ifdef HAVE_NCURSES
+# if defined(HAVE_NCURSES_H)
 #  include <ncurses.h>
-#elif defined(HAVE_NCURSES_CURSES_H)
+# elif defined(HAVE_NCURSES_CURSES_H)
 #  include <ncurses/curses.h>
-#elif defined(HAVE_CURSES_H)
+# elif defined(HAVE_CURSES_H)
 #  include <curses.h>
-#else
+# else
 #  error No curses header file available
-#endif
-
+# endif
+#else
+# include <sys/time.h>
+# include <sys/types.h>
+# include <unistd.h>
 #endif
 
 
@@ -155,7 +152,9 @@ void split_close(void)
 
 int split_keyaction(void) 
 {
-#ifdef NO_CURSES
+#ifdef HAVE_NCURSES
+  char c = getch();
+#else
   fd_set readfds;
   struct timeval tv;
   char c;
@@ -169,8 +168,6 @@ int split_keyaction(void)
     read (0, &c, 1);
   } else 
     return 0;
-#else
-  char c = getch();
 #endif
 
 #if DEBUG