From: Tim Horton Date: Mon, 29 Jun 2009 01:19:19 +0000 (-0400) Subject: Add GObject introspection X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=376f4aa1863305de6242a12b3af65b40f3651677;p=libchamplain Add GObject introspection --- diff --git a/.gitignore b/.gitignore index 6ffb611..a887db0 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ champlain-gtk-uninstalled.pc *.lo *.la *.stamp +*.gir +*.typelib champlain-gtk/champlain-gtk-marshal.c champlain-gtk/champlain-gtk-marshal.h champlain/champlain-marshal.c diff --git a/AUTHORS b/AUTHORS index 261f51e..3abe6cf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -19,3 +19,4 @@ Victor Godoy Poluceno Javier Jardón Patryk Zawadski Sebastian Reichel +Tim Horton diff --git a/champlain-gtk/Makefile.am b/champlain-gtk/Makefile.am index 8a4801c..343c5f1 100644 --- a/champlain-gtk/Makefile.am +++ b/champlain-gtk/Makefile.am @@ -35,3 +35,37 @@ AM_CPPFLAGS = $(GTK_DEPS_CFLAGS) -I$(top_srcdir) -DCHAMPLAIN_GTK_COMPILATION AM_LDFLAGS = $(GTK_DEPS_LIBS) -export-symbols-regex ^gtk_champlain_.* EXTRA_DIST = $(CHAMPLAIN_GTK_MARSHAL_LIST) + +if HAVE_INTROSPECTION +BUILT_GIRSOURCES = + +GtkChamplain-0.3.gir: $(INTROSPECTION_SCANNER) libchamplain-gtk-0.3.la + $(QUIET_GEN)$(INTROSPECTION_SCANNER) -v \ + --namespace GtkChamplain --nsversion=0.3 \ + --strip-prefix=GtkChamplain \ + $(INCLUDES) \ + --add-include-path=$(srcdir) --add-include=path=. \ + --c-include="$(libchamplain_include_HEADERS)" \ + --include=Clutter-0.8 \ + --include=Gtk-2.0 \ + --library=champlain-gtk-0.3 \ + --output $@ \ + --pkg gobject-2.0 \ + --pkg gtk+-2.0 \ + $(libchamplain_gtk_0_3_la_SOURCES) $(libchamplain_include_HEADERS) + +BUILT_GIRSOURCES += GtkChamplain-0.3.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 $(builddir)/$(@F) + +CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA) +endif diff --git a/champlain/Makefile.am b/champlain/Makefile.am index ebf7726..e81a29e 100644 --- a/champlain/Makefile.am +++ b/champlain/Makefile.am @@ -153,3 +153,38 @@ champlain-enum-types.c: $(libchamplain_headers) Makefile $(libchamplain_headers) ) > xgen-gtc \ && cp xgen-gtc $(@F) \ && rm -f xgen-gtc + +if HAVE_INTROSPECTION +BUILT_GIRSOURCES = + +Champlain-0.3.gir: $(INTROSPECTION_SCANNER) libchamplain-0.3.la + $(QUIET_GEN)$(INTROSPECTION_SCANNER) -v \ + --namespace Champlain --nsversion=0.3 \ + --strip-prefix=Champlain \ + $(INCLUDES) \ + --add-include-path=$(srcdir) --add-include=path=. \ + --c-include="$(libchamplain_include_HEADERS)" \ + --include=Clutter-0.8 \ + --include=Gtk-2.0 \ + --library=champlain-0.3 \ + --output $@ \ + --pkg gobject-2.0 \ + --pkg gtk+-2.0 \ + $(libchamplain_0_3_la_SOURCES) $(libchamplain_include_HEADERS) + +BUILT_GIRSOURCES += Champlain-0.3.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 $(builddir)/$(@F) + +CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA) +endif + diff --git a/configure.ac b/configure.ac index b72df99..a62e9aa 100644 --- a/configure.ac +++ b/configure.ac @@ -193,6 +193,7 @@ if test "x$enable_python" = "xyes" -a "x$have_python" != "xyes"; then fi AM_CONDITIONAL(ENABLE_PYTHON, test "x$enable_python" = "xyes") +GOBJECT_INTROSPECTION_CHECK([0.6.3]) # ----------------------------------------------------------- AC_CONFIG_FILES([Makefile @@ -232,6 +233,8 @@ echo " libsoup-gnome: ${have_soup_gnome}" echo " Gtk+ View: ${enable_gtk}" echo "" echo "Bindings:" -echo " champlain-sharp: ${enable_managed}" -echo " Python bindings: ${enable_python}" +echo " champlain-sharp: ${enable_managed}" +echo " Python bindings: ${enable_python}" +echo " gobject-introspection: ${enable_introspection}" +echo "" diff --git a/m4/introspection.m4 b/m4/introspection.m4 new file mode 100644 index 0000000..bb3a0da --- /dev/null +++ b/m4/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]) +])