[json-glib] [build] Add introspection generation
- From: Emmanuele Bassi <ebassi src gnome org>
- To: svn-commits-list gnome org
- Subject: [json-glib] [build] Add introspection generation
- Date: Tue, 9 Jun 2009 06:52:27 -0400 (EDT)
commit bddc717b8b6f2f1501c30f78159c20394665d335
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Tue Jun 9 11:48:02 2009 +0100
[build] Add introspection generation
Build the Introspection data when compiling JSON-GLib; this way, the
API should be available to other languages automatically.
---
.gitignore | 3 +
build/autotools/Makefile.am | 7 +++-
build/autotools/introspection.m4 | 88 ++++++++++++++++++++++++++++++++++++++
configure.ac | 13 +++--
json-glib/Makefile.am | 30 +++++++++++++
5 files changed, 135 insertions(+), 6 deletions(-)
diff --git a/.gitignore b/.gitignore
index 048ec7b..53747f3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ autom4te.cache
/build/autotools/*.m4
!/build/autotools/shave.m4
!/build/autotools/as-compiler-flag.m4
+!/build/autotools/introspection.m4
configure
config.guess
config.h
@@ -27,6 +28,8 @@ json-glib.pc
json-enum-types.[ch]
json-marshal.[ch]
json-version.h
+Json-1.0.gir
+Json-1.0.typelib
*.la
stamp-json-enum-types.h
stamp-json-marshal.h
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 ef2d166..157d975 100644
--- a/configure.ac
+++ b/configure.ac
@@ -117,6 +117,8 @@ AS_IF([test "x$enable_maintainer_flags" = "xyes" && test "x$GCC" = "xyes"],
GTK_DOC_CHECK([1.11])
+GOBJECT_INTROSPECTION_CHECK([0.6.3])
+
SHAVE_INIT([build/autotools], [enable])
AC_CONFIG_FILES([
@@ -140,9 +142,10 @@ AC_OUTPUT
echo ""
echo " Json-GLib $VERSION"
echo ""
-echo " Prefix: ${prefix}"
-echo " Debug level: ${enable_debug}"
-echo " Compiler flags: ${MAINTAINER_CFLAGS}"
-echo " API reference: ${enable_gtk_doc}"
-echo " Enable test suite: ${enable_glibtest}"
+echo " Prefix: ${prefix}"
+echo " Debug level: ${enable_debug}"
+echo " Compiler flags: ${MAINTAINER_CFLAGS}"
+echo " API reference: ${enable_gtk_doc}"
+echo " Enable test suite: ${enable_glibtest}"
+echo " Build introspection data: ${enable_introspection}"
echo ""
diff --git a/json-glib/Makefile.am b/json-glib/Makefile.am
index 9a5328b..7726f3a 100644
--- a/json-glib/Makefile.am
+++ b/json-glib/Makefile.am
@@ -123,3 +123,33 @@ EXTRA_DIST += \
$(NULL)
TESTS_ENVIRONMENT = srcdir="$(srcdir)" json_all_c_sources="$(source_c)"
+
+if HAVE_INTROSPECTION
+BUILT_GIRSOURCES =
+
+Json-1.0.gir: $(INTROSPECTION_SCANNER) libjson-glib-1.0.la
+ $(INTROSPECTION_SCANNER) -v --namespace Json --nsversion=1.0 \
+ $(INCLUDES) \
+ --c-include='json-glib/json-glib.h' \
+ --include=GObject-2.0 \
+ --library=json-glib-1.0 \
+ --pkg gobject-2.0 \
+ --output $@ \
+ $(source_h) \
+ $(source_c)
+
+BUILT_GIRSOURCES += Json-1.0.gir
+
+# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to
+# install anything - we need to install inside our prefix.
+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]