summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Nemerson <evan@coeus-group.com>2013-02-14 02:17:36 -0800
committerSergey V. Udaltsov <svu@gnome.org>2013-02-14 23:30:42 +0000
commit74f47d010b88f1483c911a1edaf0909522f40d0f (patch)
treef85e5371e9bac2df72ba594e5c20ae1ab5f38642
parentf48cdb13142f28f591198e261437ecb1ec7ce36b (diff)
downloadlibxklavier-74f47d010b88f1483c911a1edaf0909522f40d0f.tar.gz
Add Vala bindings
https://bugs.freedesktop.org/show_bug.cgi?id=57629
-rw-r--r--.gitignore6
-rw-r--r--configure.ac3
-rw-r--r--libxklavier/Makefile.am21
-rw-r--r--m4/vapigen.m4101
4 files changed, 130 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index e834743..becba63 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,9 +12,11 @@ config.sub
configure
gtk-doc.make
libtool
+libxklavier.deps
libxklavier.prj
libxklavier.pws
libxklavier.spec
+libxklavier.vapi
ltmain.sh
stamp-h
stamp-h.in
@@ -34,7 +36,9 @@ libxklavier-*.tar.*
.anjuta
.anjuta_sym_db.db
.tm_project2.cache
-m4
+m4/*
+!m4/introspection.m4
+!m4/vapigen.m4
*.bak
*~
ABOUT-NLS
diff --git a/configure.ac b/configure.ac
index 58f2445..cdb9fd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,6 +38,9 @@ AM_GNU_GETTEXT_VERSION([0.17])
# Introspection
GOBJECT_INTROSPECTION_CHECK([1.30.0])
+# Vala
+VAPIGEN_CHECK([0.18.0.110])
+
m4_ifset([GTK_DOC_CHECK], [
GTK_DOC_CHECK(1.0)
], [
diff --git a/libxklavier/Makefile.am b/libxklavier/Makefile.am
index 6e90096..c9c1bbe 100644
--- a/libxklavier/Makefile.am
+++ b/libxklavier/Makefile.am
@@ -103,6 +103,8 @@ Xkl_1_0_gir_INCLUDES = GObject-2.0 xlib-2.0
Xkl_1_0_gir_CFLAGS = -I$(top_srcdir) -I$(top_builddir) $(INCLUDES) $(X_CFLAGS) $(XML_CFLAGS) $(GLIB_CFLAGS) $(XINPUT_CFLAGS)
Xkl_1_0_gir_LIBS = libxklavier.la
Xkl_1_0_gir_FILES = $(xklavier_headers) $(introspection_sources)
+Xkl_1_0_gir_EXPORT_PACKAGES = libxklavier
+Xkl_1_0_gir_SCANNERFLAGS = --c-include="libxklavier/xklavier.h"
INTROSPECTION_GIRS += Xkl-1.0.gir
girdir = $(datadir)/gir-1.0
@@ -112,4 +114,23 @@ typelibdir = $(libdir)/girepository-1.0
typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
CLEANFILES += $(gir_DATA) $(typelib_DATA)
+
+if ENABLE_VAPIGEN
+-include $(VAPIGEN_MAKEFILE)
+
+libxklavier.vapi: Xkl-1.0.gir libxklavier.deps
+
+VAPIGEN_VAPIS = libxklavier.vapi
+
+libxklavier_vapi_DEPS = x11
+libxklavier_vapi_FILES = Xkl-1.0.gir
+
+libxklavier.deps:
+ $(AM_V_GEN) for pkg in $(libxklavier_vapi_DEPS); do \
+ echo $$pkg >> $@; \
+ done
+
+vapidir = $(datadir)/vala/vapi
+vapi_DATA = $(VAPIGEN_VAPIS) $(VAPIGEN_VAPIS:.vapi=.deps)
+endif
endif
diff --git a/m4/vapigen.m4 b/m4/vapigen.m4
new file mode 100644
index 0000000..2c435e7
--- /dev/null
+++ b/m4/vapigen.m4
@@ -0,0 +1,101 @@
+dnl vapigen.m4
+dnl
+dnl Copyright 2012 Evan Nemerson
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND_INTROSPECTION], [DEFAULT])
+# --------------------------------------
+# Check vapigen existence and version
+#
+# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation
+AC_DEFUN([VAPIGEN_CHECK],
+[
+ AS_IF([test "x$3" != "xyes"], [
+ m4_provide_if([GOBJECT_INTROSPECTION_CHECK], [], [
+ m4_provide_if([GOBJECT_INTROSPECTION_REQUIRE], [], [
+ AC_MSG_ERROR([[You must call GOBJECT_INTROSPECTION_CHECK or GOBJECT_INTROSPECTION_REQUIRE before using VAPIGEN_CHECK unless using the FOUND_INTROSPECTION argument is "yes"]])
+ ])
+ ])
+ ])
+
+ AC_ARG_ENABLE([vala],
+ [AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]],[build Vala bindings @<:@default=]ifelse($4,,auto,$4)[@:>@])],,[
+ AS_IF([test "x$4" = "x"], [
+ enable_vala=auto
+ ], [
+ enable_vala=$4
+ ])
+ ])
+
+ AS_CASE([$enable_vala], [no], [enable_vala=no],
+ [yes], [
+ AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
+ AC_MSG_ERROR([Vala bindings require GObject Introspection])
+ ])
+ ], [auto], [
+ AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
+ enable_vala=no
+ ])
+ ], [
+ AC_MSG_ERROR([Invalid argument passed to --enable-vala, should be one of @<:@no/auto/yes@:>@])
+ ])
+
+ AS_IF([test "x$2" = "x"], [
+ vapigen_pkg_name=vapigen
+ ], [
+ vapigen_pkg_name=vapigen-$2
+ ])
+ AS_IF([test "x$1" = "x"], [
+ vapigen_pkg="$vapigen_pkg_name"
+ ], [
+ vapigen_pkg="$vapigen_pkg_name >= $1"
+ ])
+
+ PKG_PROG_PKG_CONFIG
+
+ PKG_CHECK_EXISTS([$vapigen_pkg], [
+ AS_IF([test "$enable_vala" = "auto"], [
+ enable_vala=yes
+ ])
+ ], [
+ AS_CASE([$enable_vala], [yes], [
+ AC_MSG_ERROR([$vapigen_pkg not found])
+ ], [auto], [
+ enable_vala=no
+ ])
+ ])
+
+ AC_MSG_CHECKING([for vapigen])
+
+ AS_CASE([$enable_vala],
+ [yes], [
+ VAPIGEN=`$PKG_CONFIG --variable=vapigen $vapigen_pkg_name`
+ VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir $vapigen_pkg_name`/vala/Makefile.vapigen
+ AS_IF([test "x$2" = "x"], [
+ VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir $vapigen_pkg_name`
+ ], [
+ VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned $vapigen_pkg_name`
+ ])
+ ])
+
+ AC_MSG_RESULT([$enable_vala])
+
+ AC_SUBST([VAPIGEN])
+ AC_SUBST([VAPIGEN_VAPIDIR])
+ AC_SUBST([VAPIGEN_MAKEFILE])
+
+ AM_CONDITIONAL(ENABLE_VAPIGEN, test "x$enable_vala" = "xyes")
+])