From: Matt Kimball Date: Fri, 30 Dec 2016 16:22:32 +0000 (+0000) Subject: build: if linking with ncurses fails, try curses (for NetBSD) X-Git-Tag: v0.88~12^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42651675e68f685c09f6c39f8824e982a8dbbd68;p=thirdparty%2Fmtr.git build: if linking with ncurses fails, try curses (for NetBSD) 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. --- diff --git a/Makefile.am b/Makefile.am index ba8299c..c0709ca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index 05ac452..5d6f4ab 100644 --- a/configure.ac +++ b/configure.ac @@ -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], diff --git a/packet/probe.h b/packet/probe.h index 4a343fe..1bb2bb0 100644 --- a/packet/probe.h +++ b/packet/probe.h @@ -23,6 +23,7 @@ #include #include +#include #include #include "portability/queue.h" diff --git a/ui/display.c b/ui/display.c index 4616c94..58ba2c0 100644 --- a/ui/display.c +++ b/ui/display.c @@ -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 diff --git a/ui/display.h b/ui/display.h index f9bba14..956d1cd 100644 --- a/ui/display.h +++ b/ui/display.h @@ -29,7 +29,7 @@ enum { ActionNone, ActionQuit, ActionReset, ActionDisplay, enum { DisplayReport, -#ifdef HAVE_LIBNCURSES +#ifdef HAVE_CURSES DisplayCurses, #endif #ifdef HAVE_GTK diff --git a/ui/mtr.c b/ui/mtr.c index 9a356bd..c9f48b4 100644 --- a/ui/mtr.c +++ b/ui/mtr.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -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; diff --git a/ui/split.c b/ui/split.c index d5b97da..1bcce4e 100644 --- a/ui/split.c +++ b/ui/split.c @@ -36,7 +36,7 @@ #include "split.h" #include "utils.h" -#ifdef HAVE_LIBNCURSES +#ifdef HAVE_CURSES # if defined(HAVE_NCURSES_H) # include # 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;