[couchdb-glib: 2/6] Add introspection support



commit e20de5b9559b7a2951300e1b9304569a2fce89b0
Author: Johan Dahlin <johan gnome org>
Date:   Tue Dec 8 22:08:38 2009 -0200

    Add introspection support

 Makefile.am              |    2 +
 configure.ac             |    7 +++
 couchdb-glib/Makefile.am |   83 ++++++++++++++++++++++++++++++++---------
 m4/introspection.m4      |   92 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 166 insertions(+), 18 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index c466442..8d8748c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,5 @@
+ACLOCAL_AMFLAGS = -I m4
+
 SUBDIRS = couchdb-glib tests doc
 
 DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
diff --git a/configure.ac b/configure.ac
index dbc3d24..f7de7bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,6 +4,8 @@ AC_PREREQ([2.59])
 
 AC_CONFIG_SRCDIR([Makefile.am])
 
+AC_CONFIG_MACRO_DIR([m4])
+
 AM_CONFIG_HEADER([config.h])
 
 AM_INIT_AUTOMAKE([1.6.3 foreign])
@@ -50,6 +52,11 @@ GTK_DOC_CHECK(1.0)
 DISTCHECK_CONFIGURE_FLAGS="--enable-gtk-doc"
 AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
 
+##################################################
+# Check for introspection
+##################################################
+GOBJECT_INTROSPECTION_CHECK([0.6.4])
+
 AC_OUTPUT([
 Makefile
 couchdb-glib.pc
diff --git a/couchdb-glib/Makefile.am b/couchdb-glib/Makefile.am
index 6a60488..526029c 100644
--- a/couchdb-glib/Makefile.am
+++ b/couchdb-glib/Makefile.am
@@ -1,10 +1,12 @@
-OAUTH_FILES = oauth.c oauth.h xmalloc.c xmalloc.h
+
+oauth_headers = oauth.h xmalloc.h
+oauth_sources = oauth.c xmalloc.c
 
 if HAVE_OAUTH
-OAUTH_SOURCES = $(OAUTH_FILES)
+OAUTH_FILES = $(oauth_headers) $(oauth_sources)
 OAUTH_LIBS = 
 else
-OAUTH_SOURCES = 
+OAUTH_FILES = 
 OAUTH_LIBS =
 endif
 
@@ -14,7 +16,9 @@ INCLUDES =		\
 lib_LTLIBRARIES = libcouchdb-glib-1.0.la
 
 # Marshallers
-MARSHAL_GENERATED = couchdb-marshal.c couchdb-marshal.h
+marshal_headers = couchdb-marshal.h
+marshal_sources = couchdb-marshal.c
+MARSHAL_FILES = $(marshal_headers) $(marshal_sources)
 
 couchdb-marshal.h: couchdb-marshal.list $(GLIB_GENMARSHAL)
 	$(GLIB_GENMARSHAL) $< --header --prefix=_couchdb_marshal > $@
@@ -22,28 +26,36 @@ couchdb-marshal.h: couchdb-marshal.list $(GLIB_GENMARSHAL)
 couchdb-marshal.c: couchdb-marshal.list $(GLIB_GENMARSHAL)
 	$(GLIB_GENMARSHAL) $< --body --prefix=_couchdb_marshal > $@
 
-libcouchdb_glib_1_0_la_SOURCES =	\	
-	couchdb.c			\
+libcouchdb_glib_1_0_la_headers =	\
 	couchdb.h			\
-	couchdb-database-info.c		\
 	couchdb-database-info.h		\
-	couchdb-document.c		\
 	couchdb-document.h		\
-	couchdb-document-contact.c	\
 	couchdb-document-contact.h	\
-	couchdb-document-info.c		\
 	couchdb-document-info.h		\
 	couchdb-glib.h			\
-	couchdb-struct-field.c		\
 	couchdb-struct-field.h		\
 	couchdb-types.h			\
-	dbwatch.c			\
 	dbwatch.h			\
+	utils.h
+
+libcouchdb_glib_1_0_la_sources =	\
+	couchdb.c			\
+	couchdb-database-info.c		\
+	couchdb-document.c		\
+	couchdb-document-contact.c	\
+	couchdb-document-info.c		\
+	couchdb-struct-field.c		\
+	dbwatch.c			\
 	utils.c				\
-	utils.h				\
-	$(MARSHAL_GENERATED)		\
-	$(OAUTH_SOURCES)			
-	
+	$(marshal_sources)		\
+	$(oauth_sources)
+
+libcouchdb_glib_1_0_la_SOURCES =	\
+    $(libcouchdb_glib_1_0_la_headers) \
+    $(libcouchdb_glib_1_0_la_sources) \
+	$(marshal_headers)		\
+	$(oauth_headers)
+
 libcouchdb_glib_1_0_la_LIBADD =		\
 	$(COUCHDB_GLIB_LIBS)		\
 	$(OAUTH_LIBS)			\
@@ -58,6 +70,41 @@ h_DATA = 				\
 	couchdb-document-contact.h	\
 	couchdb-types.h
 
-EXTRA_DIST = $(h_DATA) couchdb-marshal.list $(MARSHAL_GENERATED) $(OAUTH_FILES)
-BUILT_SOURCES = $(MARSHAL_GENERATED)
+EXTRA_DIST = $(h_DATA) couchdb-marshal.list $(MARSHAL_FILES) $(OAUTH_FILES)
+BUILT_SOURCES = $(MARSHAL_FILES)
 CLEANFILES = $(BUILT_SOURCES)
+
+if HAVE_INTROSPECTION
+
+BUILT_SOURCES += Couchdb-1.0.gir Couchdb-1.0.typelib
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = Couchdb-1.0.gir
+
+typelibsdir = $(libdir)/girepository-1.0/
+typelibs_DATA = Couchdb-1.0.typelib
+
+Couchdb-1.0.gir: libcouchdb-glib-1.0.la
+	$(INTROSPECTION_SCANNER) -v \
+        --namespace Couchdb --nsversion=1.0 \
+        --add-include-path=$(srcdir) \
+        --add-include-path=. \
+        --include=GObject-2.0 \
+        --include=Json-1.0 \
+        --library=couchdb-glib-1.0 \
+        --pkg gobject-2.0 \
+        --pkg json-glib-1.0 \
+        --output $@ \
+        -I$(top_srcdir) \
+        $(h_DATA) \
+        $(libcouchdb_glib_1_0_la_headers) \
+        $(libcouchdb_glib_1_0_la_sources)
+
+Couchdb-1.0.typelib: Couchdb-1.0.gir
+	LD_LIBRARY_PATH=.libs$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH} \
+	$(INTROSPECTION_COMPILER) \
+        --includedir=$(srcdir) \
+	--includedir=. \
+	$(INTROSPECTION_COMPILER_OPTS) $< -o $(@F)
+
+endif
diff --git a/m4/introspection.m4 b/m4/introspection.m4
new file mode 100644
index 0000000..6e2c565
--- /dev/null
+++ b/m4/introspection.m4
@@ -0,0 +1,92 @@
+dnl -*- mode: autoconf -*-
+dnl Copyright 2009 Johan Dahlin
+dnl
+dnl This file is free software; the author(s) gives unlimited
+dnl permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+
+# serial 1
+
+m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
+[
+    AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
+
+    dnl enable/disable introspection
+    m4_if([$2], [require],
+    [dnl
+        enable_introspection=yes
+    ],[dnl
+        AC_ARG_ENABLE(introspection,
+                  AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
+                                 [Enable introspection for this build]),, 
+                                 [enable_introspection=auto])
+    ])dnl
+
+    AC_MSG_CHECKING([for gobject-introspection])
+
+    dnl presence/version checking
+    AS_CASE([$enable_introspection],
+    [no], [dnl
+        found_introspection="no (disabled, use --enable-introspection to enable)"
+    ],dnl
+    [yes],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0],,
+                         AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
+                         found_introspection=yes,
+                         AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME]))
+    ],dnl
+    [auto],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
+    ],dnl
+    [dnl	
+        AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
+    ])dnl
+
+    AC_MSG_RESULT([$found_introspection])
+
+    INTROSPECTION_SCANNER=
+    INTROSPECTION_COMPILER=
+    INTROSPECTION_GENERATE=
+    INTROSPECTION_GIRDIR=
+    INTROSPECTION_TYPELIBDIR=
+    if test "x$found_introspection" = "xyes"; then
+       INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+       INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+       INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+       INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+       INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+    fi
+    AC_SUBST(INTROSPECTION_SCANNER)
+    AC_SUBST(INTROSPECTION_COMPILER)
+    AC_SUBST(INTROSPECTION_GENERATE)
+    AC_SUBST(INTROSPECTION_GIRDIR)
+    AC_SUBST(INTROSPECTION_TYPELIBDIR)
+    AC_SUBST(INTROSPECTION_CFLAGS)
+    AC_SUBST(INTROSPECTION_LIBS)
+
+    AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
+])
+
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
+
+AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
+])
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
+
+
+AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
+])



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