[folks] Bug 626578 — Use vala's vala.m4 to check for telepathy-glib(.vapi)



commit cd2400c5ed45df81a4024e41c4020b61a6051b37
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu Aug 19 14:59:38 2010 +0100

    Bug 626578 â?? Use vala's vala.m4 to check for telepathy-glib(.vapi)

 configure.ac         |   10 +++----
 m4/vala.m4           |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++
 telepathy-check.vala |    6 ----
 3 files changed, 74 insertions(+), 12 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3cafba7..cf664e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,12 +110,10 @@ PKG_CHECK_MODULES(TP_GLIB, telepathy-glib >= $TP_GLIB_REQUIRED)
 AC_SUBST(TP_GLIB_CFLAGS)
 AC_SUBST(TP_GLIB_LIBS)
 
-# check for tp-glib vala bindings by compiling a trivial program
-AC_MSG_CHECKING([Telepathy Vala bindings])
-AS_IF(! [$VALAC $VALACFLAGS $VALAFLAGS --vapidir=$VAPIDIR --pkg telepathy-glib \
-	 -o /dev/null "${srcdir}/telepathy-check.vala"],
-	[AC_MSG_ERROR([Missing telepathy-glib Vala bindings])])
-AC_MSG_RESULT([yes])
+VALA_CHECK_PACKAGES([telepathy-glib
+                    dbus-glib-1
+                    gio-2.0
+                    gee-1.0])
 
 # -----------------------------------------------------------
 # Backends
diff --git a/m4/vala.m4 b/m4/vala.m4
new file mode 100644
index 0000000..3735948
--- /dev/null
+++ b/m4/vala.m4
@@ -0,0 +1,70 @@
+dnl vala.m4
+dnl
+dnl Copyright 2010 Marc-Andre Lureau
+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
+
+# _VALA_CHECK_COMPILE_WITH_ARGS(ARGS, [ACTION-IF-TRUE],
+#   [ACTION-IF-FALSE])
+# --------------------------------------
+# Check that Vala compile with ARGS.
+#
+AC_DEFUN([_VALA_CHECK_COMPILE_WITH_ARGS],
+[AC_REQUIRE([AM_PROG_VALAC])[]dnl
+
+  cat <<_ACEOF >conftest.vala
+void main(){}
+_ACEOF
+
+  AS_IF([vala_error=`$VALAC $1 -q -o conftest$ac_exeext conftest.vala 2>&1`],
+        [$2], [$3])
+])
+
+])# _VALA_CHECK_COMPILE_WITH_ARGS
+
+# VALA_CHECK_PACKAGES(PKGS, [ACTION-IF-FOUND],
+#   [ACTION-IF-NOT-FOUND])
+# --------------------------------------
+# Check that PKGS Vala bindings are installed and usable.
+#
+AC_DEFUN([VALA_CHECK_PACKAGES],
+[
+  ac_save_ifs="$IFS"; unset IFS
+  for vala_pkg in $(echo "$1"); do
+      vala_pkgs="$vala_pkgs --pkg $vala_pkg"
+      vala_bindings="$vala_bindings $vala_pkg"
+  done
+  IFS="$ac_save_ifs"
+  AC_MSG_CHECKING([for $vala_bindings vala bindings])
+  _VALA_CHECK_COMPILE_WITH_ARGS([$vala_pkgs],
+    [vala_pkg_exists=yes],
+    [vala_pkg_exists=no])
+
+AS_IF([test x${vala_pkg_exists} = xno],[
+  ifelse([$3], , [AC_MSG_ERROR([]dnl
+[Package requirements were not met: $1
+
+$vala_error
+
+Consider adjusting the XDG_DATA_DIRS environment variable if you
+installed bindings in a non-standard prefix.
+])],
+  [AC_MSG_RESULT([no])
+$3])],[
+  AC_MSG_RESULT([yes])
+  ifelse([$2], , :, [$2])[]dnl
+])
+
+])# VALA_CHECK_PACKAGES



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]