[gcr/bgo688678] build: Permit building without GTK+



commit fc4e5518fdb95bc2e8966aeb52da6efc1fd43dbc
Author: Mathias Hasselmann <mathias openismus com>
Date:   Thu Dec 6 08:02:29 2012 +0100

    build: Permit building without GTK+
    
     * Adds a --without-gtk switch to the configure script.
     * This is useful for platforms that don't provide GTK+,
       but still want to use gcr, or libraries building upon.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688678

 Makefile.am                      |    1 +
 configure.ac                     |   24 +++++++++++++--
 gcr/Makefile.am                  |   61 ++++++++++++++++++++++++++++++++++----
 gcr/tests/Makefile.am            |   20 ++++++++++--
 gcr/tests/frob-openpgp.c         |    2 +-
 gcr/tests/test-openpgp.c         |    2 +-
 gcr/tests/test-openssh.c         |    2 +-
 gcr/tests/test-secret-exchange.c |    2 +-
 8 files changed, 98 insertions(+), 16 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 67a76e5..075ed88 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,6 +25,7 @@ DISTCHECK_CONFIGURE_FLAGS = \
 	--disable-coverage \
 	--disable-update-mime \
 	--disable-update-icon-cache \
+	--with-gtk \
 	--with-pkcs11-modules=$(abs_srcdir)/$(top_distdir)/_inst/lib/
 
 DISTCLEANFILES = \
diff --git a/configure.ac b/configure.ac
index 8a1c11d..be57d8e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -81,9 +81,26 @@ AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
 
 GTK_DOC_CHECK(1.9)
 
-PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.0)
-AC_SUBST(GTK_CFLAGS)
-AC_SUBST(GTK_LIBS)
+# --------------------------------------------------------------------
+# Optional GTK+ widgets build, avoid building gtk-doc wihtout GTK+
+#
+AC_ARG_WITH(gtk, [
+            AC_HELP_STRING([--without-gtk],
+            [do not build code that uses GTK+]),
+            ], [], [with_gtk=yes])
+AM_CONDITIONAL(WITH_GTK, test "$with_gtk" != "no")
+
+if test "x$with_gtk" != "xno"; then
+	PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.0)
+	AC_SUBST(GTK_CFLAGS)
+	AC_SUBST(GTK_LIBS)
+fi
+
+if test "x$enable_gtk_doc" = "xyes"; then
+  if test "x$with_gtk" = "xno"; then
+    AC_MSG_ERROR([Cannot build documentation if building GTK+ widgets is disabled])
+  fi
+fi
 
 # --------------------------------------------------------------------
 # Checks for functions
@@ -410,6 +427,7 @@ echo
 echo "BUILD"
 echo "  Debug Build:          $debug_status"
 echo "  Strict Compilation:   $strict_status"
+echo "  GTK+ Widgets:         $with_gtk"
 echo "  Introspection:        $found_introspection"
 echo "  Valgrind:             $valgrind_status"
 echo "  Test Coverage:        $enable_coverage"
diff --git a/gcr/Makefile.am b/gcr/Makefile.am
index 4671581..d806337 100644
--- a/gcr/Makefile.am
+++ b/gcr/Makefile.am
@@ -6,12 +6,16 @@ SUBDIRS = . icons tests
 # UI BUILDER
 #
 
+if WITH_GTK
+
 uidir = $(datadir)/gcr- GCR_MAJOR@/ui/
 
 ui_DATA = \
 	gcr-pkcs11-import-dialog.ui \
 	gcr-unlock-options-widget.ui
 
+endif # WITH_GTK
+
 # ------------------------------------------------------------------
 # HEADERS
 
@@ -71,10 +75,16 @@ incdir = $(includedir)/gcr- GCR_MAJOR@/gcr
 
 inc_HEADERS = \
 	$(HEADER_BASE_FILES) \
-	$(HEADER_UI_FILES) \
 	gcr-enum-types-base.h \
 	gcr-enum-types.h
 
+if WITH_GTK
+
+inc_HEADERS += \
+	$(HEADER_UI_FILES)
+
+endif # WITH_GTK
+
 # ------------------------------------------------------------------
 # LIBRARY
 
@@ -89,9 +99,15 @@ INCLUDES = \
 	-DLOCALEDIR=\""$(datadir)/locale"\"
 
 lib_LTLIBRARIES = \
-	libgcr-base- GCR_MAJOR@.la \
+	libgcr-base- GCR_MAJOR@.la
+
+if WITH_GTK
+
+lib_LTLIBRARIES += \
 	libgcr- GCR_MAJOR@.la
 
+endif # WITH_GTK
+
 BUILT_BASE_FILES = \
 	gcr-marshal.c gcr-marshal.h \
 	gcr-enum-types-base.c gcr-enum-types-base.h \
@@ -104,9 +120,15 @@ BUILT_UI_FILES = \
 	gcr-oids.c gcr-oids.h
 
 BUILT_SOURCES = \
-	$(BUILT_BASE_FILES) \
+	$(BUILT_BASE_FILES)
+
+if WITH_GTK
+
+BUILT_SOURCES += \
 	$(BUILT_UI_FILES)
 
+endif # WITH_GTK
+
 libgcr_base_ GCR_MAJOR@_la_SOURCES = \
 	gcr-callback-output-stream.c gcr-callback-output-stream.h \
 	gcr-certificate.c gcr-certificate.h \
@@ -158,6 +180,8 @@ libgcr_base_ GCR_MAJOR@_la_SOURCES = \
 nodist_libgcr_base_ GCR_MAJOR@_la_SOURCES = \
 	$(BUILT_BASE_FILES)
 
+if WITH_GTK
+
 libgcr_ GCR_MAJOR@_la_SOURCES = \
 	gcr-certificate-basics-widget.c gcr-certificate-basics-widget.h \
 	gcr-certificate-details-widget.c gcr-certificate-details-widget.h \
@@ -201,16 +225,22 @@ libgcr_ GCR_MAJOR@_la_SOURCES = \
 nodist_libgcr_ GCR_MAJOR@_la_SOURCES = \
 	$(BUILT_UI_FILES)
 
+endif # WITH_GTK
+
 libgcr_base_ GCR_MAJOR@_la_CFLAGS = \
 	-DGCK_API_SUBJECT_TO_CHANGE \
 	-DP11_KIT_API_SUBJECT_TO_CHANGE \
 	-DGCR_COMPILATION
 
+if WITH_GTK
+
 libgcr_ GCR_MAJOR@_la_CFLAGS = \
 	$(GTK_CFLAGS) \
 	-DUIDIR=\""$(uidir)"\" \
 	$(libgcr_base_ GCR_MAJOR@_la_CFLAGS)
 
+endif # WITH_GTK
+
 libgcr_base_ GCR_MAJOR@_la_LDFLAGS = \
 	-version-info $(GCR_LT_RELEASE) \
 	-no-undefined \
@@ -226,11 +256,15 @@ libgcr_base_ GCR_MAJOR@_la_LIBADD = \
 	$(LIBGCRYPT_LIBS) \
 	$(P11_KIT_LIBS)
 
+if WITH_GTK
+
 libgcr_ GCR_MAJOR@_la_LIBADD = \
 	$(GTK_LIBS) \
 	$(libgcr_base_ GCR_MAJOR@_la_LIBADD) \
 	$(builddir)/libgcr-base-$(GCR_MAJOR).la
 
+endif # WITH_GTK
+
 noinst_LTLIBRARIES = libgcr-testable.la
 libgcr_testable_la_SOURCES =
 libgcr_testable_la_LIBADD = \
@@ -276,13 +310,20 @@ gcr-dbus-generated.c: $(DBUS_XML_DEFINITIONS)
 gcr-dbus-generated.h: gcr-dbus-generated.c
 
 pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = gcr-$(GCR_MAJOR).pc gcr-base-$(GCR_MAJOR).pc
+pkgconfig_DATA = gcr-base-$(GCR_MAJOR).pc
 
-gcr-$(GCR_MAJOR).pc: gcr.pc
-	cp gcr.pc gcr-$(GCR_MAJOR).pc
 gcr-base-$(GCR_MAJOR).pc: gcr-base.pc
 	cp gcr-base.pc gcr-base-$(GCR_MAJOR).pc
 
+if WITH_GTK
+
+pkgconfig_DATA += gcr-$(GCR_MAJOR).pc 
+
+gcr-$(GCR_MAJOR).pc: gcr.pc
+	cp gcr.pc gcr-$(GCR_MAJOR).pc
+
+endif # WITH_GTK
+
 # ----------------------------------------------------------------
 # SYSTEM INTEGRATION
 
@@ -306,6 +347,8 @@ update_mime_database:
 	fi
 endif
 
+if WITH_GTK
+
 desktopdir = $(datadir)/applications
 desktop_in_in_files = gcr-viewer.desktop.in.in gcr-prompter.desktop.in.in
 desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
@@ -317,9 +360,13 @@ service_in_files = \
 servicedir       = $(DBUS_SERVICES_DIR)
 service_DATA     = $(service_in_files:.service.in=.service)
 
+endif # WITH_GTK
+
 # ----------------------------------------------------------------
 # TOOLS
 
+if WITH_GTK
+
 bin_PROGRAMS = gcr-viewer
 
 gcr_viewer_SOURCES = \
@@ -353,6 +400,8 @@ gcr_prompter_LDADD = \
 	$(top_builddir)/gck/libgck- GCK_MAJOR@.la \
 	$(GTK_LIBS)
 
+endif # WITH_GTK
+
 # ------------------------------------------------------------------
 # INTROSPECTION
 
diff --git a/gcr/tests/Makefile.am b/gcr/tests/Makefile.am
index b0215c5..f11e55e 100644
--- a/gcr/tests/Makefile.am
+++ b/gcr/tests/Makefile.am
@@ -8,7 +8,6 @@ INCLUDES = \
 	-DGCK_API_SUBJECT_TO_CHANGE \
 	-DGCR_COMPILATION \
 	$(GLIB_CFLAGS) \
-	$(GTK_CFLAGS) \
 	$(LIBGCRYPT_CFLAGS) \
 	$(P11_KIT_CFLAGS)
 
@@ -16,7 +15,6 @@ LDADD = \
 	$(top_builddir)/gcr/libgcr-testable.la \
 	$(top_builddir)/egg/libegg.la \
 	$(top_builddir)/gck/libgck-testable.la \
-	$(GTK_LIBS) \
 	$(GLIB_LIBS) \
 	$(LIBGCRYPT_LIBS) \
 	$(P11_KIT_LIBS)
@@ -43,6 +41,15 @@ TEST_PROGS = \
 	test-gnupg-process \
 	test-system-prompt
 
+if WITH_GTK
+
+INCLUDES += \
+	$(GTK_CFLAGS)
+LDADD += \
+	$(GTK_LIBS)
+
+endif # WITH_GTK
+
 check_PROGRAMS = $(TEST_PROGS)
 
 test: $(TEST_PROGS)
@@ -61,13 +68,18 @@ EXTRA_DIST = \
 # ------------------------------------------------------------------
 
 noinst_PROGRAMS = \
+	frob-openpgp \
+	frob-parser
+
+if WITH_GTK
+
+noinst_PROGRAMS += \
 	frob-certificate \
 	frob-certificate-request \
 	frob-combo-selector \
 	frob-gnupg-selector \
 	frob-key \
 	frob-tree-selector \
-	frob-openpgp \
 	frob-parser \
 	frob-prompt \
 	frob-request \
@@ -75,6 +87,8 @@ noinst_PROGRAMS = \
 	frob-unlock \
 	frob-unlock-options
 
+endif # WITH_GTK
+
 frob_unlock_SOURCES = \
 	frob-unlock.c \
 	../gcr-viewer-window.c
diff --git a/gcr/tests/frob-openpgp.c b/gcr/tests/frob-openpgp.c
index 9763a62..cd54f72 100644
--- a/gcr/tests/frob-openpgp.c
+++ b/gcr/tests/frob-openpgp.c
@@ -23,7 +23,7 @@
 
 #include "config.h"
 
-#include "gcr/gcr.h"
+#include "gcr/gcr-base.h"
 #include "gcr/gcr-openpgp.h"
 #include "gcr/gcr-record.h"
 
diff --git a/gcr/tests/test-openpgp.c b/gcr/tests/test-openpgp.c
index 0645a08..3880c95 100644
--- a/gcr/tests/test-openpgp.c
+++ b/gcr/tests/test-openpgp.c
@@ -22,7 +22,7 @@
 
 #include "config.h"
 
-#include "gcr/gcr.h"
+#include "gcr/gcr-base.h"
 #include "gcr/gcr-openpgp.h"
 #include "gcr/gcr-record.h"
 
diff --git a/gcr/tests/test-openssh.c b/gcr/tests/test-openssh.c
index 376efe0..6f27713 100644
--- a/gcr/tests/test-openssh.c
+++ b/gcr/tests/test-openssh.c
@@ -22,7 +22,7 @@
 
 #include "config.h"
 
-#include "gcr/gcr.h"
+#include "gcr/gcr-base.h"
 #include "gcr/gcr-openssh.h"
 
 #include "egg/egg-testing.h"
diff --git a/gcr/tests/test-secret-exchange.c b/gcr/tests/test-secret-exchange.c
index ea26d15..5508df9 100644
--- a/gcr/tests/test-secret-exchange.c
+++ b/gcr/tests/test-secret-exchange.c
@@ -22,7 +22,7 @@
 
 #include "config.h"
 
-#include "gcr/gcr.h"
+#include "gcr/gcr-base.h"
 
 #include "egg/egg-testing.h"
 



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