summaryrefslogtreecommitdiff
path: root/vapigen
diff options
context:
space:
mode:
authorEvan Nemerson <evan@coeus-group.com>2012-01-20 21:09:47 -0800
committerEvan Nemerson <evan@coeus-group.com>2012-01-20 21:09:47 -0800
commit32faf1522c8ebc09f2ec9388fbe96c20c232af70 (patch)
treed3d1c497e58724b0b1a1671dd09dca4f0806dcfc /vapigen
parent3406eff147ec805a6ec881074436dc4a86a0ee41 (diff)
downloadvala-32faf1522c8ebc09f2ec9388fbe96c20c232af70.tar.gz
Add autotools vapigen integration for upstream bindings
Fixes bug 649526.
Diffstat (limited to 'vapigen')
-rw-r--r--vapigen/Makefile.am19
-rw-r--r--vapigen/Makefile.vapigen60
-rw-r--r--vapigen/vapigen.m488
-rw-r--r--vapigen/vapigen.pc.in15
4 files changed, 182 insertions, 0 deletions
diff --git a/vapigen/Makefile.am b/vapigen/Makefile.am
index 2f08351fa..dd2a49fff 100644
--- a/vapigen/Makefile.am
+++ b/vapigen/Makefile.am
@@ -60,12 +60,31 @@ vapicheck_LDADD = \
../gobject-introspection/libgidl.la \
$(NULL)
+if ENABLE_UNVERSIONED
+makedir = $(datadir)/vala
+make_DATA = Makefile.vapigen
+
+aclocaldir = $(datadir)/aclocal
+aclocal_DATA = vapigen.m4
+endif
+
+pkgconfigdir = $(datadir)/pkgconfig
+pkgconfig_DATA = vapigen@PACKAGE_SUFFIX@.pc
+
+vapigen@PACKAGE_SUFFIX@.pc: vapigen.pc
+ cp $< $@
+
EXTRA_DIST = $(vapigen_VALASOURCES) $(vapicheck_VALASOURCES) vapigen.vala.stamp vapicheck.vala.stamp
+CLEANFILES = \
+ vapigen@PACKAGE_SUFFIX@.pc
+ $(NULL)
+
if ENABLE_UNVERSIONED
install-exec-hook:
cd $(DESTDIR)$(bindir) && $(LN_S) -f vapigen@PACKAGE_SUFFIX@$(EXEEXT) vapigen$(EXEEXT)
cd $(DESTDIR)$(bindir) && $(LN_S) -f vapicheck@PACKAGE_SUFFIX@$(EXEEXT) vapicheck$(EXEEXT)
+ cd $(DESTDIR)$(pkgconfigdir) && $(LN_S) -f vapigen@PACKAGE_SUFFIX@.pc vapigen.pc
endif
MAINTAINERCLEANFILES = \
diff --git a/vapigen/Makefile.vapigen b/vapigen/Makefile.vapigen
new file mode 100644
index 000000000..f3cf30d3c
--- /dev/null
+++ b/vapigen/Makefile.vapigen
@@ -0,0 +1,60 @@
+# Makefile for Vala API Generator (vapigen)
+# Written by Evan Nemerson
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation
+#
+# Variables:
+#
+# VAPIGEN_FILES
+#
+# VAPIs to create
+#
+# *_DEPS / VAPIGEN_DEPS
+#
+# The dependencies. Generally the pkg-config names.
+#
+# *_METADATADIRS / VAPIGEN_METADATADIRS
+#
+# Directory containing the metadata.
+#
+# *_VAPIDIRS / VAPIGEN_VAPIDIRS
+#
+# Additional location(s) to search for VAPI dependencies.
+#
+# *_GIRDIRS / VAPIGEN_GIRDIRS
+#
+# Additional location(s) to search for GIR dependencies.
+#
+# *_GIR
+#
+# The GIR which should be used to generate the VAPI.
+
+_vapigen_silent_prefix = $(_vapigen_silent_prefix_$(V))
+_vapigen_silent_prefix_ = $(_vapigen_silent_prefix_$(AM_DEFAULT_VERBOSITY))
+_vapigen_silent_prefix_0 = @echo " VAPIGEN $(1)";
+_vapigen_silent_opts = $(_vapigen_silent_opts_$(V))
+_vapigen_silent_opts_ = $(_vapigen_silent_opts_$(AM_DEFAULT_VERBOSITY))
+_vapigen_silent_opts_0 = --quiet
+
+$(if $(VAPIGEN),,$(error You must define VAPIGEN))
+
+_vapi_name = $(subst /,_,$(subst -,_,$(subst .,_,$(1))))
+
+define vapigen
+$(1): $$($(_vapi_name)_GIR)
+ $(_vapigen_silent_prefix) $(VAPIGEN) $(_vapigen_silent_opts) \
+ --library $(1:.vapi=) \
+ $(foreach _vapi_metadatadir_name,$(if $($(_vapi_name)_METADATADIRS),$($(_vapi_name)_METADATADIRS),$(VAPIGEN_METADATADIRS)),--metadatadir $(_vapi_metadatadir_name)) \
+ $(foreach _vapi_dir_name,$(if $($(_vapi_name)_VAPIDIRS),$($(_vapi_name)_DIRS),$(VAPIGEN_VAPIDIRS)),--vapidir $(_vapi_dir_name)) \
+ $(foreach _vapi_dep_name,$(if $($(_vapi_name)_DEPS),$($(_vapi_name)_DEPS),$(VAPIGEN_DEPS)),--pkg $(_vapi_dep_name)) \
+ $$($(_vapi_name)_GIR)
+endef
+
+$(foreach vapi,$(VAPIGEN_VAPIS),$(eval $(call vapigen,$(vapi))))
diff --git a/vapigen/vapigen.m4 b/vapigen/vapigen.m4
new file mode 100644
index 000000000..48051078d
--- /dev/null
+++ b/vapigen/vapigen.m4
@@ -0,0 +1,88 @@
+dnl vala.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])
+# --------------------------------------
+# Check that vapigen existence and version
+#
+# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation
+AC_DEFUN([VAPIGEN_CHECK],
+[
+ AC_BEFORE([GOBJECT_INTROSPECTION_CHECK],[$0])
+ AC_BEFORE([GOBJECT_INTROSPECTION_REQUIRE],[$0])
+
+ AC_ARG_ENABLE([vala],
+ AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]],
+ [build Vala bindings [[default=auto]]]),,
+ [enable_vala=auto])
+
+ AS_CASE([$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
+ ])
+ ])
+
+ AS_CASE([$enable_vala],
+ [yes], [
+ VAPIGEN=`$PKG_CONFIG --variable=vapigen vapigen`
+ VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir vapigen`/vala/Makefile.vapigen
+ AS_IF([test "x$2" = "x"], [
+ VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir vapigen`
+ ], [
+ VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned vapigen`
+ ])
+ ])
+
+ AC_SUBST([VAPIGEN])
+ AC_SUBST([VAPIGEN_VAPIDIR])
+ AC_SUBST([VAPIGEN_MAKEFILE])
+
+ AM_CONDITIONAL(ENABLE_VAPIGEN, test "x$enable_vala" = "xyes")
+])
diff --git a/vapigen/vapigen.pc.in b/vapigen/vapigen.pc.in
new file mode 100644
index 000000000..ecd54cef7
--- /dev/null
+++ b/vapigen/vapigen.pc.in
@@ -0,0 +1,15 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+bindir=@bindir@
+datarootdir=@datarootdir@
+datadir=@datadir@
+includedir=@includedir@
+
+vapigen=${bindir}/vapigen@PACKAGE_SUFFIX@
+vapidir=${datadir}/vala/vapi
+vapidir_versioned=${datadir}/vala@PACKAGE_SUFFIX@/vapi
+
+Name: vapigen
+Description: Vala API Generator
+Version: @VERSION@