[libgdata] build: Add --enable-gtk option to conditionalise GTK+ examples



commit 40e3eefae8e2d03d549d0f26862d0e2e0883d6c9
Author: Philip Withnall <withnall endlessm com>
Date:   Wed Feb 14 16:15:15 2018 +0000

    build: Add --enable-gtk option to conditionalise GTK+ examples
    
    Only build the GTK+ examples if enabled explicitly with --enable-gtk, or
    if --enable-gtk is not specified and GTK+ is available.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=787210

 Makefile.am  |    3 ++-
 configure.ac |   12 ++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 8b17f05..144e54e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -650,10 +650,11 @@ if ENABLE_GOA
 noinst_PROGRAMS += demos/docs-list/docs-list
 endif
 
-if HAVE_GTK
+if ENABLE_GTK
 noinst_PROGRAMS +=                     \
        demos/scrapbook/scrapbook
 endif
+AM_DISTCHECK_CONFIGURE_FLAGS += --enable-gtk
 
 demos_docs_list_docs_list_SOURCES = \
        demos/docs-list/docs-list.c \
diff --git a/configure.ac b/configure.ac
index 9d56e54..ae8d437 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,8 +114,16 @@ GDK_PIXBUF_CFLAGS="$GDK_PIXBUF_CFLAGS -DGDK_VERSION_MIN_REQUIRED=$GDK_PIXBUF_MIN
 AC_SUBST(GDK_PIXBUF_CFLAGS)
 AC_SUBST(GDK_PIXBUF_LIBS)
 
-PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK_REQS], [have_gtk=yes], [have_gtk=no])
-AM_CONDITIONAL([HAVE_GTK], [test "x$have_gtk" = "xyes"])
+AC_MSG_CHECKING([whether to build examples which use GTK+])
+AC_ARG_ENABLE([gtk], [AS_HELP_STRING([--enable-gtk], [Whether to enable examples which use GTK+ (default: if 
available)])],, [enable_gtk=maybe])
+AC_MSG_RESULT([$enable_gtk])
+AS_IF([test "$enable_gtk" != "no"],[
+       PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK_REQS], [have_gtk=yes], [have_gtk=no])
+])
+AS_IF([test "$enable_gtk" = "yes" && test "$have_gtk" != "yes"],[
+       AC_MSG_ERROR([GTK+ support requested but gtk+-3.0 could not be found])
+])
+AM_CONDITIONAL([ENABLE_GTK], [test "$have_gtk" = "yes" && test "$enable_gtk" != "no"])
 
 # GNOME support, which pulls in gcr-base-3 to provide non-pageable memory
 AC_MSG_CHECKING(whether to build with GNOME support)


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