Add introspection to build process
authorP. F. Chimento <philip.chimento@gmail.com>
Mon, 13 Jun 2011 12:17:28 +0000 (14:17 +0200)
committerP. F. Chimento <philip.chimento@gmail.com>
Mon, 13 Jun 2011 12:17:28 +0000 (14:17 +0200)
So that the build generates a GObject Introspection Repository from
which we can automatically generate bindings for other programming
languages!

Makefile.am
configure.ac
libchimara/Makefile.am
m4/introspection.m4 [new file with mode: 0644]

index a163df8615b21d7b7febdb4276ca437707fa7070..352b3d352b03ad7d247d845bb0fa70de2952656a 100644 (file)
@@ -18,18 +18,29 @@ dist_chimaradoc_DATA = \
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = chimara.pc chimara-plugin.pc
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = chimara.pc chimara-plugin.pc
 
-EXTRA_DIST = chimara.pc.in chimara-plugin.pc.in chimara.spec.in
+EXTRA_DIST = \
+       chimara.pc.in
+       chimara-plugin.pc.in
+       chimara.spec.in
+       m4/introspection.m4
 
 DISTCLEANFILES = chimara.pc chimara-plugin.pc chimara.spec
 
 
 DISTCLEANFILES = chimara.pc chimara-plugin.pc chimara.spec
 
+macros_ignore = codeset gettext glibc2 glibc21 gtk-doc iconv intdiv0 intl \
+       intldir intlmacosx intltool intmax inttypes_h inttypes-pri lcmessage \
+       lib-ld lib-link lib-prefix libtool lock longlong lt~obsolete ltoptions \
+       ltsugar ltversion nls po printf-posix progtest size_max stdint_h uintmax_t \
+       visibility wchar_t wint_t xsize
+
 MAINTAINERCLEANFILES = ABOUT-NLS INSTALL aclocal.m4 compile config.guess \
        config.h.in config.rpath config.sub depcomp gtk-doc.make install-sh \
 MAINTAINERCLEANFILES = ABOUT-NLS INSTALL aclocal.m4 compile config.guess \
        config.h.in config.rpath config.sub depcomp gtk-doc.make install-sh \
-       intltool-extract.in     intltool-merge.in intltool-update.in ltmain.sh missing \
-       ylwrap m4 autom4te.cache
+       intltool-extract.in intltool-merge.in intltool-update.in ltmain.sh missing \
+       ylwrap autom4te.cache \
+       $(addprefix 'm4/',$(addsuffix '.m4', $(macros_ignore)))
 
 ACLOCAL_AMFLAGS = -I m4
 
 
 ACLOCAL_AMFLAGS = -I m4
 
-DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
+DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-introspection
 
 if BUILDING_RPM
 EXTRA_DIST += chimara.spec
 
 if BUILDING_RPM
 EXTRA_DIST += chimara.spec
index 6a47b5464634f80ca261e21f1cf92ac71ba40893..9e73d1155372d449d84c34b3d40875d7dabe61cc 100644 (file)
@@ -2,16 +2,17 @@
 
 ### INITIALIZATION ############################################################
 
 
 ### INITIALIZATION ############################################################
 
-# Initialize Autoconf 
+AC_PREREQ([2.62]) # Oldest version of Autoconf that works with introspection
+# Initialize Autoconf
 # Args: (human-readable package name, package version, bug report address, 
 # tarballname)
 AC_INIT([chimara], [0.9])
 # Sanity check to make sure we are running Autoconf from the right directory
 AC_CONFIG_SRCDIR(libchimara/chimara-glk.c)
 # Put m4 macros in their own directory
 # Args: (human-readable package name, package version, bug report address, 
 # tarballname)
 AC_INIT([chimara], [0.9])
 # Sanity check to make sure we are running Autoconf from the right directory
 AC_CONFIG_SRCDIR(libchimara/chimara-glk.c)
 # Put m4 macros in their own directory
-AC_CONFIG_MACRO_DIR(m4)
+AC_CONFIG_MACRO_DIR([m4])
 # Initialize Automake
 # Initialize Automake
-AM_INIT_AUTOMAKE([-Wall])
+AM_INIT_AUTOMAKE([-Wall -Wno-portability])
 # Configure with --enable-silent-rules to cut down on clutter
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 # Configure with --enable-silent-rules to cut down on clutter
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
@@ -45,7 +46,7 @@ AC_PROG_YACC                 # Building nitfol requires yacc
 ### DECLARE PROGRAMS ##########################################################
 
 AC_PROG_INSTALL              # Install
 ### DECLARE PROGRAMS ##########################################################
 
 AC_PROG_INSTALL              # Install
-LT_INIT([dlopen])                      # Libtool 2.2.6 and up
+LT_INIT([dlopen])            # Libtool 2.2.6 and up
 LT_PREREQ([2.2.6])
 AM_GNU_GETTEXT([external])   # Gettext, link to system libintl
 IT_PROG_INTLTOOL([0.40.0])   # Intltool
 LT_PREREQ([2.2.6])
 AM_GNU_GETTEXT([external])   # Gettext, link to system libintl
 IT_PROG_INTLTOOL([0.40.0])   # Intltool
@@ -72,6 +73,10 @@ GETTEXT_PACKAGE=chimara
 AC_SUBST(GETTEXT_PACKAGE)
 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name])
 
 AC_SUBST(GETTEXT_PACKAGE)
 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name])
 
+### INTROSPECTION ##############################################################
+
+GOBJECT_INTROSPECTION_CHECK([0.6.7])
+
 ### ILIAD #####################################################################
 AC_ARG_ENABLE([iliad],
        [AS_HELP_STRING([--enable-iliad=@<:@yes/no@:>@],
 ### ILIAD #####################################################################
 AC_ARG_ENABLE([iliad],
        [AS_HELP_STRING([--enable-iliad=@<:@yes/no@:>@],
index 3f98d0898082f8a1b2ae40bc2ffbd763e221f27c..7724b74cf0361e11497e8c6d7386026a547518e1 100644 (file)
@@ -71,5 +71,33 @@ chimara-marshallers.h: chimara-marshallers.txt
        $(AM_V_GEN)glib-genmarshal --header --prefix=_chimara_marshal $< > $@
 
 EXTRA_DIST = doc.c glkstart.c chimara-marshallers.txt
        $(AM_V_GEN)glib-genmarshal --header --prefix=_chimara_marshal $< > $@
 
 EXTRA_DIST = doc.c glkstart.c chimara-marshallers.txt
+CLEANFILES =
+
+-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir)
+INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
+
+if HAVE_INTROSPECTION
+introspection_sources = \
+       chimara-glk.c chimara-glk.h \
+       chimara-if.c chimara-if.h
+
+Chimara-1.0.gir: libchimara.la
+Chimara_1_0_gir_INCLUDES = GObject-2.0 GLib-2.0 Gtk-2.0
+Chimara_1_0_gir_CFLAGS = @CHIMARA_CFLAGS@ -I$(top_srcdir)
+Chimara_1_0_gir_LIBS = libchimara.la
+Chimara_1_0_gir_FILES = $(introspection_sources)
+Chimara_1_0_gir_SCANNERFLAGS = --warn-all
+INTROSPECTION_GIRS += Chimara-1.0.gir
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+CLEANFILES += $(gir_DATA) $(typelib_DATA)
+endif
 
 -include $(top_srcdir)/git.mk
 
 -include $(top_srcdir)/git.mk
diff --git a/m4/introspection.m4 b/m4/introspection.m4
new file mode 100644 (file)
index 0000000..589721c
--- /dev/null
@@ -0,0 +1,94 @@
+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`
+       INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
+    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)
+    AC_SUBST(INTROSPECTION_MAKEFILE)
+
+    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])
+])