[unique] Add introspection data generation



commit d36e3b3707b1d414e31c45b5d8c0a1d28bc51fbc
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sun Jun 14 20:50:31 2009 +0100

    Add introspection data generation
    
    Set up libunique to generate the GObject Introspection XML and typelib
    from the source files and installed headers.

 .gitignore                       |    3 +
 build/autotools/Makefile.am      |    7 +++-
 build/autotools/introspection.m4 |   88 ++++++++++++++++++++++++++++++++++++++
 configure.ac                     |    8 +++-
 unique/Makefile.am               |   36 +++++++++++++++
 5 files changed, 140 insertions(+), 2 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 40e9c84..2d2cc13 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@ Makefile.in
 aclocal.m4
 !/build/autotools/shave.m4
 !/build/autotools/as-compiler-flag.m4
+!/build/autotools/introspection.m4
 /build/autotools/*.m4
 /build/autotools/shave
 /build/autotools/shave-libtool
@@ -35,6 +36,8 @@ unique.pc
 /unique/dbus/*.o
 /unique/*.lo
 /unique/*.o
+/unique/*.gir
+/unique/*.typelib
 xmldocs.make
 .*.swp
 *~
diff --git a/build/autotools/Makefile.am b/build/autotools/Makefile.am
index 899cbc9..d0035d1 100644
--- a/build/autotools/Makefile.am
+++ b/build/autotools/Makefile.am
@@ -1,3 +1,8 @@
-EXTRA_DIST = shave-libtool.in shave.in shave.m4 as-compiler-flag.m4
+EXTRA_DIST = \
+	shave-libtool.in 	\
+	shave.in 		\
+	shave.m4 		\
+	as-compiler-flag.m4	\
+	introspection.m4
 
 DISTCLEANFILES = shave-libtool shave
diff --git a/build/autotools/introspection.m4 b/build/autotools/introspection.m4
new file mode 100644
index 0000000..f9ce49c
--- /dev/null
+++ b/build/autotools/introspection.m4
@@ -0,0 +1,88 @@
+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)"
+    fi
+    AC_SUBST(INTROSPECTION_SCANNER)
+    AC_SUBST(INTROSPECTION_COMPILER)
+    AC_SUBST(INTROSPECTION_GENERATE)
+    AC_SUBST(INTROSPECTION_GIRDIR)
+    AC_SUBST(INTROSPECTION_TYPELIBDIR)
+
+    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])
+])
diff --git a/configure.ac b/configure.ac
index bdba30c..c6f8078 100644
--- a/configure.ac
+++ b/configure.ac
@@ -216,10 +216,15 @@ AM_GLIB_GNU_GETTEXT
 
 GETTEXT_PACKAGE=unique
 AC_SUBST(GETTEXT_PACKAGE)
-AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"], [Define the gettext package to be used])
+AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],
+                   ["$GETTEXT_PACKAGE"],
+                   [Define the gettext package to be used])
 
 AM_GLIB_DEFINE_LOCALEDIR(UNIQUE_LOCALEDIR)
 
+# introspection
+GOBJECT_INTROSPECTION_CHECK([0.6.3])
+
 # gtk-doc
 GTK_DOC_CHECK([1.11])
 
@@ -253,6 +258,7 @@ Configuration:
             Maintainer flags: $enable_maintainer_flags
                  Debug level: $enable_debug
          Build documentation: $enable_gtk_doc
+    Build introspection data: $enable_introspection
 
 Backends:
           Unix Domain Socket: $have_bacon
diff --git a/unique/Makefile.am b/unique/Makefile.am
index 5998a34..1fdac13 100644
--- a/unique/Makefile.am
+++ b/unique/Makefile.am
@@ -106,3 +106,39 @@ DISTCLEANFILES = \
 	$(NULL)
 
 EXTRA_DIST = uniquemarshal.list uniqueversion.h.in
+
+if HAVE_INTROSPECTION
+BUILT_GIRSOURCES =
+
+Unique-1.0.gir: $(INTROSPECTION_SCANNER) libunique-1.0.la
+	$(INTROSPECTION_SCANNER) -v \
+		--namespace Unique --nsversion=1.0 \
+		$(INCLUDES) \
+		--c-include='unique/unique.h' \
+		--include=GObject-2.0 \
+		--include=Gtk-2.0 \
+		--library=unique-1.0 \
+		--pkg gobject-2.0 \
+		--pkg gtk+-2.0 \
+		--pkg unique-1.0 \
+		--output $@ \
+		$(unique_sources_h) \
+		$(unique_sources_c)
+
+BUILT_GIRSOURCES += Unique-1.0.gir
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(BUILT_GIRSOURCES)
+
+typelibsdir = $(libdir)/girepository-1.0
+typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
+
+%.typelib: %.gir $(INTROSPECTION_COMPILER)
+	$(QUIET_GEN)$(DEBUG) $(INTROSPECTION_COMPILER) \
+		--includedir=$(srcdir) \
+		--includedir=. \
+		$(INTROSPECTION_COMPILER_OPTS) \
+	$< -o $(@F)
+
+CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA)
+endif # HAVE_INTROSPECTION



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