1dnl vala.m4
2dnl
3dnl Copyright 2010 Marc-Andre Lureau
4dnl
5dnl This library is free software; you can redistribute it and/or
6dnl modify it under the terms of the GNU Lesser General Public
7dnl License as published by the Free Software Foundation; either
8dnl version 2.1 of the License, or (at your option) any later version.
9dnl
10dnl This library is distributed in the hope that it will be useful,
11dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13dnl Lesser General Public License for more details.
14dnl
15dnl You should have received a copy of the GNU Lesser General Public
16dnl License along with this library; if not, write to the Free Software
17dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
18
19# _VALA_CHECK_COMPILE_WITH_ARGS(ARGS, [ACTION-IF-TRUE],
20#   [ACTION-IF-FALSE])
21# --------------------------------------
22# Check that Vala compile with ARGS.
23#
24AC_DEFUN([_VALA_CHECK_COMPILE_WITH_ARGS],
25[AC_REQUIRE([AM_PROG_VALAC])[]dnl
26
27  cat <<_ACEOF >conftest.vala
28void main(){}
29_ACEOF
30
31  AS_IF([vala_error=`$VALAC $1 -q -o conftest$ac_exeext conftest.vala 2>&1`],
32        [$2], [$3])
33])
34
35])# _VALA_CHECK_COMPILE_WITH_ARGS
36
37# VALA_CHECK_PACKAGES(PKGS, [ACTION-IF-FOUND],
38#   [ACTION-IF-NOT-FOUND])
39# --------------------------------------
40# Check that PKGS Vala bindings are installed and usable.
41#
42AC_DEFUN([VALA_CHECK_PACKAGES],
43[
44  ac_save_ifs="$IFS"; unset IFS
45  for vala_pkg in $(echo "$1"); do
46      vala_pkgs="$vala_pkgs --pkg $vala_pkg"
47      vala_bindings="$vala_bindings $vala_pkg"
48  done
49  IFS="$ac_save_ifs"
50  AC_MSG_CHECKING([for $vala_bindings vala bindings])
51  _VALA_CHECK_COMPILE_WITH_ARGS([$vala_pkgs],
52    [vala_pkg_exists=yes],
53    [vala_pkg_exists=no])
54
55AS_IF([test x${vala_pkg_exists} = xno],[
56  ifelse([$3], , [AC_MSG_ERROR([]dnl
57[Package requirements were not met: $1
58
59$vala_error
60
61Consider adjusting the XDG_DATA_DIRS environment variable if you
62installed bindings in a non-standard prefix.
63])],
64  [AC_MSG_RESULT([no])
65$3])],[
66  AC_MSG_RESULT([yes])
67  ifelse([$2], , :, [$2])[]dnl
68])
69
70])# VALA_CHECK_PACKAGES
71