[sysprof] build: allow disabling the GTK interface with --disable-gtk



commit a8205c7c290dfa10be015509ab14fc795bf5d936
Author: Christian Hergert <christian hergert me>
Date:   Wed Apr 13 21:32:01 2016 -0700

    build: allow disabling the GTK interface with --disable-gtk
    
    For some systems, such as embedded Linux including ARM, we might want to
    just compile libsysprof/sysprof-cli without the GTK user interface. This
    allows for that. You can copy the capture files to your visualization
    host to render the results.

 configure.ac      |   34 +++++++++++++++++++++++++++-------
 lib/Makefile.am   |    4 ++++
 src/Makefile.am   |    4 ++++
 tests/Makefile.am |   17 +++++++++++------
 4 files changed, 46 insertions(+), 13 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1e290f4..676985a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,20 +82,39 @@ VAPIGEN_CHECK
 dnl ***********************************************************************
 dnl Check for required packages
 dnl ***********************************************************************
-PKG_CHECK_MODULES(SYSPROF,    [gio-2.0 >= 2.44
-                              gio-unix-2.0 >= 2.44
-                               polkit-gobject-1])
-PKG_CHECK_MODULES(SYSPROF_UI, [gio-2.0 >= 2.44
-                               gtk+-3.0 >= 3.16
+m4_define([glib_required_version], [2.44.0])
+m4_define([gtk_required_version], [3.16.0])
+m4_define([systemd_required_version], [222])
+
+PKG_CHECK_MODULES(SYSPROF,    [gio-2.0 >= glib_required_version
+                              gio-unix-2.0 >= glib_required_version
                                polkit-gobject-1])
-PKG_CHECK_MODULES(SYSTEMD,    [libsystemd >= 222],
+PKG_CHECK_MODULES(SYSPROF_UI, [gio-2.0 >= glib_required_version
+                               gtk+-3.0 >= gtk_required_version
+                               polkit-gobject-1],
+                              [have_uilibs=yes],
+                              [have_uilibs=no])
+PKG_CHECK_MODULES(SYSTEMD,    [libsystemd >= systemd_required_version],
                               [have_systemd=yes],
                               [have_systemd=no])
 
-
 # we require systemd for sysprofd
 AM_CONDITIONAL(ENABLE_SYSPROFD, [test x$have_systemd = xyes])
 
+# we might be building sysprof-cli without the UI
+AC_ARG_ENABLE([gtk],
+              [AS_HELP_STRING([--enable-gtk=@<:@yes/no/auto@:>@],
+                              [Build GTK user interface.])],
+              [enable_gtk=$enableval],
+              [enable_gtk=auto])
+AS_IF([test "$enable_gtk" != no],[
+       AS_IF([test "$enable_gtk" = "yes" && test "$have_uilibs" = "no"],[
+               AC_MSG_ERROR([--enable-gtk requires gtk+-3.0 >= gtk_required_version])
+       ])
+       enable_gtk=$have_uilibs
+])
+AM_CONDITIONAL(ENABLE_GTK, test "$enable_gtk" = "yes")
+
 
 # where to place systemd units if necessary
 AC_ARG_WITH([systemdsystemunitdir],
@@ -196,5 +215,6 @@ echo ""
 echo "  Debug Directory ...................... : ${debugdir}"
 echo ""
 echo "  Sysprofd ............................. : ${have_systemd}"
+echo "  Sysprof GTK Interface  ............... : ${enable_gtk}"
 echo "  Systemd System Units ................. : ${with_systemdsystemunitdir}"
 echo ""
diff --git a/lib/Makefile.am b/lib/Makefile.am
index a2cad63..313aee9 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -116,6 +116,8 @@ libsysprof_ API_VERSION@_la_LDFLAGS = \
        $(NULL)
 
 
+if ENABLE_GTK
+
 # This is our GTK library containing the widgets suitable for viewing
 # and manipulating the various profiler API in libsysprof.  This is
 # meant to be used by IDEs and the sysprof gui.
@@ -181,5 +183,7 @@ glib_resources_h = sp-resources.h
 glib_resources_namespace = sp
 include $(top_srcdir)/gresources.mk
 
+endif
+
 
 -include $(top_srcdir)/git.mk
diff --git a/src/Makefile.am b/src/Makefile.am
index d789526..5af40c2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,3 +1,5 @@
+if ENABLE_GTK
+
 bin_PROGRAMS = sysprof
 
 sysprof_CFLAGS = \
@@ -37,4 +39,6 @@ glib_resources_h = sp-resources.h
 glib_resources_namespace = sysprof
 include $(top_srcdir)/gresources.mk
 
+endif
+
 -include $(top_srcdir)/git.mk
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4b64ad5..0f121f7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,5 @@
 TESTS =
+TEST_PROGS =
 
 test_cflags = \
        $(SYSPROF_CFLAGS) \
@@ -9,11 +10,18 @@ test_libs = \
        $(SYSPROF_LIBS) \
        $(top_builddir)/lib/libsysprof- API_VERSION@.la
 
+TESTS += test-capture
+test_capture_SOURCES = test-capture.c
+test_capture_CFLAGS = $(test_cflags)
+test_capture_LDADD = $(test_libs)
+
+
+if ENABLE_GTK
+
 test_ui_cflags = \
        $(SYSPROF_UI_CFLAGS) \
        -I$(top_srcdir)/lib \
        -I$(top_builddir)/lib
-
 test_ui_libs = \
        $(SYSPROF_UI_LIBS) \
        $(top_builddir)/lib/libsysprof- API_VERSION@.la \
@@ -21,14 +29,12 @@ test_ui_libs = \
 
 
 TESTS += test-model-filter
+TEST_PROGS += test-model-filter
 test_model_filter_SOURCES = test-model-filter.c
 test_model_filter_CFLAGS = $(test_ui_cflags)
 test_model_filter_LDADD = $(test_ui_libs)
 
-TESTS += test-capture
-test_capture_SOURCES = test-capture.c
-test_capture_CFLAGS = $(test_cflags)
-test_capture_LDADD = $(test_libs)
+endif
 
 TEST_ENVIRONMENT = \
        G_TEST_SRCDIR="$(abs_srcdir)" \
@@ -38,7 +44,6 @@ TEST_ENVIRONMENT = \
        MALLOC_CHECK_=2 \
        MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))
 
-TEST_PROGS = test-model-filter
 LOG_COMPILER = $(top_srcdir)/tap-test
 
 noinst_PROGRAMS = $(TESTS)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]