Make libncurses optional
authorJulien Desfossez <jdesfossez@efficios.com>
Wed, 12 Feb 2014 02:58:15 +0000 (21:58 -0500)
committerJulien Desfossez <jdesfossez@efficios.com>
Wed, 12 Feb 2014 02:58:15 +0000 (21:58 -0500)
During the configure, if ncurses is not detected, compile only the
textdump code and print an error if the user tries to use the GUI.
This will allow to create a package with only the textdump code for
platforms that don't have/want ncurses packages.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
configure.ac
src/Makefile.am
src/cursesdisplay.c
src/lttng-live-comm.c
src/lttngtop.c

index fb956538e6035189de5ecbcaa465f58885330a9f..f4cbfc356a803393b27a860172b7afb1be149252 100644 (file)
@@ -40,14 +40,12 @@ AC_CHECK_LIB([popt], [poptGetContext], [],
 )
 
 # Check for libncurses
-AC_CHECK_LIB([ncurses], [initscr], [],
-       [AC_MSG_ERROR([Cannot find the the ncurses library.])]
+AC_CHECK_LIB([ncurses], [initscr], [], [HAVE_NCURSES=0]
 )
 
 # Check for libpanel, also part of libncurses
 # (but this check will add the required -lpanel flag)
-AC_CHECK_LIB([panel], [update_panels], [],
-       [AC_MSG_ERROR([Cannot find the the ncurses library.])]
+AC_CHECK_LIB([panel], [update_panels], [], [HAVE_PANELS=0]
 )
 
 # Check for libbabeltrace
@@ -81,3 +79,15 @@ AC_CONFIG_FILES([
        utils/Makefile
 ])
 AC_OUTPUT
+
+AS_IF([test "x$HAVE_NCURSES" = "x0"],[
+       AS_ECHO()
+       AS_ECHO_N("Ncurses GUI won't be compiled install ncurses if you want it.")
+       ], [
+          CURSES_LIBS="-lcurses -lpanel"
+          AC_SUBST(CURSES_LIBS)
+          AS_ECHO()
+          AS_ECHO_N("Ncurses GUI will be compiled.")
+          ])
+AS_ECHO()
+
index 72599e22c25e524db40e5efb5c95b8407d38f735..302196e6ce97b3e0980b2c4d198840268c74fdc2 100644 (file)
@@ -29,7 +29,6 @@ lttngtop_SOURCES = \
 
 lttngtop_LDFLAGS = -Wl,--no-as-needed
 
-#lttngtop_LDADD = -lbabeltrace -lbabeltrace-ctf -llttngtop-helper -llttng-ctl -lurcu -llttngtopmmappacketseek -llttng-ust-ctl -lcurses -lpanel
-lttngtop_LDADD = -lbabeltrace -lbabeltrace-ctf -llttng-ctl -lurcu -llttng-ust-ctl -lcurses -lpanel \
+lttngtop_LDADD = -lbabeltrace -lbabeltrace-ctf -llttng-ctl \
+                -lurcu -llttng-ust-ctl \
                 $(top_builddir)/src/libbabeltrace-lttngtop-live.la
-
index 7f52c8b0e88bbc949b28bff376e2283dcca903d5..9e7afb2bcadf13ce91a45e757d5bd210858980dd 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <config.h>
+
+#ifdef HAVE_LIBNCURSES
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
@@ -1771,3 +1775,5 @@ void init_ncurses()
 
        pthread_create(&keyboard_thread, NULL, handle_keyboard, (void *)NULL);
 }
+
+#endif /* HAVE_LIBNCURSES */
index 988742ef3290c444b3d452a3ef37ce7d88778bab..15a3dd2f62ff1971190de83efb398b44c5ba43c1 100644 (file)
@@ -1452,10 +1452,16 @@ void lttng_live_read(struct lttng_live_ctx *ctx)
                }
 
                if (!opt_textdump) {
+#ifdef HAVE_LIBNCURSES
                        pthread_create(&display_thread, NULL, ncurses_display,
                                        (void *) NULL);
                        pthread_create(&timer_thread, NULL, refresh_thread,
                                        (void *) NULL);
+#else
+                       printf("Ncurses support not compiled, please install "
+                                       "the missing dependencies and recompile\n");
+                       goto end_free;
+#endif
                }
                iter_trace(ctx->bt_ctx);
                g_hash_table_foreach_remove(ctx->session->ctf_traces,
index c29c5a5443efc9a7d5e3c8f49d2a6ba4f67cb67b..173cc82e7facdb85f15bd0463710cac4fb56594b 100644 (file)
 #include "lttngtoptypes.h"
 #include "cputop.h"
 #include "iostreamtop.h"
-#include "cursesdisplay.h"
 #include "common.h"
 #include "network-live.h"
 
+#ifdef HAVE_LIBNCURSES
+#include "cursesdisplay.h"
+#endif
+
 #define NET_URL_PREFIX "net://"
 #define NET4_URL_PREFIX        "net4://"
 #define NET6_URL_PREFIX        "net6://"
@@ -153,6 +156,7 @@ void *refresh_thread(void *p)
        }
 }
 
+#ifdef HAVE_LIBNCURSES
 void *ncurses_display(void *p)
 {
        unsigned int current_display_index = 0;
@@ -184,6 +188,7 @@ void *ncurses_display(void *p)
                sem_post(&pause_sem);
        }
 }
+#endif /* HAVE_LIBNCURSES */
 
 void print_fields(struct bt_ctf_event *event, const char *procname,
                int pid)
@@ -1269,10 +1274,16 @@ int main(int argc, char **argv, char **envp)
                }
 
                if (!opt_textdump) {
+#ifdef HAVE_LIBNCURSES
                        pthread_create(&display_thread, NULL, ncurses_display,
                                        (void *) NULL);
                        pthread_create(&timer_thread, NULL, refresh_thread,
                                        (void *) NULL);
+#else
+                       printf("Ncurses support not compiled, please install "
+                                       "the missing dependencies and recompile\n");
+                       goto end;
+#endif
                }
 
                iter_trace(bt_ctx);
This page took 0.027181 seconds and 4 git commands to generate.