]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
build: if linking with ncurses fails, try curses (for NetBSD)
authorMatt Kimball <matt.kimball@gmail.com>
Fri, 30 Dec 2016 16:22:32 +0000 (16:22 +0000)
committerMatt Kimball <matt.kimball@gmail.com>
Fri, 30 Dec 2016 21:09:11 +0000 (13:09 -0800)
NetBSD doesn't use ncurses, but instead has its own version of curses.
So, if we don't find ncurses during configure, try linking against
curses.

On NetBSD, we must include limits.h to find CHAR_MAX.

On OpenBSD, we must include sys/socket.h to get sockaddr_storage.

Makefile.am
configure.ac
packet/probe.h
ui/display.c
ui/display.h
ui/mtr.c
ui/split.c

index ba8299c3677b23735480e825296fcc045aacf0a1..c0709ca2ddf1e43e2a4e5322562bb70b316878c5 100644 (file)
@@ -76,7 +76,7 @@ if WITH_IPINFO
 mtr_SOURCES += ui/asn.c ui/asn.h
 endif
 
-if WITH_NCURSES
+if WITH_CURSES
 mtr_SOURCES += ui/curses.c
 endif
 
index 05ac452cb5555b90c7543b36d8a848e349b991d3..5d6f4ab62eb2460b985a17d3d44571a9537a8f0c 100644 (file)
@@ -95,9 +95,12 @@ AC_ARG_WITH([ncurses],
   [AS_HELP_STRING([--without-ncurses], [Build without the ncurses interface])],
   [], [with_ncurses=yes])
 AS_IF([test "x$with_ncurses" = "xyes"],
-  [AC_CHECK_LIB([ncurses], [initscr], [], [with_ncurses=no])
+  [AC_SEARCH_LIBS(
+    [initscr], [ncurses curses],
+    [AC_DEFINE([HAVE_CURSES], [1], [Define if a curses library available])],
+    [with_ncurses=no])
 ])
-AM_CONDITIONAL([WITH_NCURSES], [test "x$with_ncurses" = xyes])
+AM_CONDITIONAL([WITH_CURSES], [test "x$with_ncurses" = xyes])
 
 AC_CHECK_LIB([cap], [cap_set_proc], [],
   AS_IF([test "$host_os" = linux-gnu],
index 4a343fe3edc1570e5ea257068833e2d70e3133bd..1bb2bb000ac62d4cc39e8340c5235892709210b5 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <netinet/in.h>
 #include <stdbool.h>
+#include <sys/socket.h>
 #include <sys/time.h>
 
 #include "portability/queue.h"
index 4616c94712c388f3943c56021c288e5b312c0ce4..58ba2c07df28ac72fbe0f4441b7a2d36c6e53607 100644 (file)
@@ -31,7 +31,7 @@
 #include "dns.h"
 #include "asn.h"
 
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
 # include "mtr-curses.h"
 #endif
 
@@ -41,7 +41,7 @@
 
 #include "split.h"
 
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
 # define DEFAULT_DISPLAY DisplayCurses
 #else
 # define DEFAULT_DISPLAY DisplayReport
@@ -85,7 +85,7 @@ extern void display_open(struct mtr_ctl *ctl)
   case DisplayCSV:
     csv_open();
     break;
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
   case DisplayCurses:
     mtr_curses_open(ctl);
 # ifdef HAVE_IPINFO
@@ -130,7 +130,7 @@ extern void display_close(struct mtr_ctl *ctl)
   case DisplayCSV:
     csv_close(ctl, now);
     break;
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
   case DisplayCurses:
 # ifdef HAVE_IPINFO
     asn_close(ctl);
@@ -154,7 +154,7 @@ extern void display_redraw(struct mtr_ctl *ctl)
 {
   switch(ctl->DisplayMode) {
 
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
   case DisplayCurses:
     mtr_curses_redraw(ctl);
     break;
@@ -176,7 +176,7 @@ extern void display_redraw(struct mtr_ctl *ctl)
 extern int display_keyaction(struct mtr_ctl *ctl)
 {
   switch(ctl->DisplayMode) {
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
   case DisplayCurses:
     return mtr_curses_keyaction(ctl);
 #endif
@@ -227,7 +227,7 @@ extern void display_loop(struct mtr_ctl *ctl)
 
 extern void display_clear(struct mtr_ctl *ctl)
 {
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
   if (ctl->DisplayMode == DisplayCurses)
     mtr_curses_clear(ctl);
 #endif
index f9bba14420108b8764f3d8a26efa73605b98acc0..956d1cd092a30bd7108b4bf4dc1c36f7ffe6592f 100644 (file)
@@ -29,7 +29,7 @@ enum { ActionNone,  ActionQuit,  ActionReset,  ActionDisplay,
 
 enum {
   DisplayReport,
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
   DisplayCurses,
 #endif
 #ifdef HAVE_GTK
index 9a356bd1f33ad5af900840294b2169740b910dea..c9f48b433411ac832475c00e7327e9d1d7ae35d4 100644 (file)
--- a/ui/mtr.c
+++ b/ui/mtr.c
@@ -44,6 +44,7 @@
 #include <ctype.h>
 #include <assert.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 
@@ -130,7 +131,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
   fputs(" -C, --csv                  output comma separated values\n", out);
   fputs(" -l, --raw                  output raw format\n", out);
   fputs(" -p, --split                split output\n", out);
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
   fputs(" -t, --curses               use curses terminal interface\n", out);
 #endif
   fputs("     --displaymode MODE     select initial display mode\n", out);
@@ -296,7 +297,7 @@ static void parse_arg (struct mtr_ctl *ctl, names_t **names, int argc, char **ar
     { "report",         0, NULL, 'r' },
     { "report-wide",    0, NULL, 'w' },
     { "xml",            0, NULL, 'x' },
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
     { "curses",         0, NULL, 't' },
 #endif
 #ifdef HAVE_GTK
@@ -380,7 +381,7 @@ static void parse_arg (struct mtr_ctl *ctl, names_t **names, int argc, char **ar
       ctl->reportwide = 1;
       ctl->DisplayMode = DisplayReport;
       break;
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
     case 't':
       ctl->DisplayMode = DisplayCurses;
       break;
index d5b97da0faeb5080ac5a28c5a591ddf80f44cccc..1bcce4ee31405de4f253d92771131f4687f1272f 100644 (file)
@@ -36,7 +36,7 @@
 #include "split.h"
 #include "utils.h"
 
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
 # if defined(HAVE_NCURSES_H)
 #  include <ncurses.h>
 # elif defined(HAVE_NCURSES_CURSES_H)
@@ -149,7 +149,7 @@ extern void split_close(void)
 
 extern int split_keyaction(void) 
 {
-#ifdef HAVE_LIBNCURSES
+#ifdef HAVE_CURSES
   char c = getch();
 #else
   fd_set readfds;