3 dnl Copyright 2010 Marc-Andre Lureau
4 dnl Copyright 2011 Rodney Dawes <dobey.pwns@gmail.com>
6 dnl This library is free software; you can redistribute it and/or
7 dnl modify it under the terms of the GNU Lesser General Public
8 dnl License as published by the Free Software Foundation; either
9 dnl version 2.1 of the License, or (at your option) any later version.
11 dnl This library is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 dnl Lesser General Public License for more details.
16 dnl You should have received a copy of the GNU Lesser General Public
17 dnl License along with this library; if not, write to the Free Software
18 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 # _VALA_CHECK_COMPILE_WITH_ARGS(ARGS, [ACTION-IF-TRUE],
22 # --------------------------------------
23 # Check that Vala compile with ARGS.
25 AC_DEFUN([_VALA_CHECK_COMPILE_WITH_ARGS],
26 [AC_REQUIRE([AM_PROG_VALAC])[]dnl
28 cat <<_ACEOF >conftest.vala
32 AS_IF([vala_error=`$VALAC $1 -q --cc="${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}" -o conftest$ac_exeext conftest.vala 2>&1`],
36 ])# _VALA_CHECK_COMPILE_WITH_ARGS
38 # VALA_CHECK_PACKAGES(PKGS, [ACTION-IF-FOUND],
39 # [ACTION-IF-NOT-FOUND])
40 # --------------------------------------
41 # Check that PKGS Vala bindings are installed and usable.
43 AC_DEFUN([VALA_CHECK_PACKAGES],
47 ac_save_ifs="$IFS"; unset IFS
48 for vala_pkg in $(echo "$1"); do
49 vala_pkgs="${vala_pkgs:+$vala_pkgs }--pkg $vala_pkg"
50 vala_bindings="${vala_bindings:+$vala_bindings }$vala_pkg"
53 AC_MSG_CHECKING([for $vala_bindings vala bindings])
54 _VALA_CHECK_COMPILE_WITH_ARGS([$vala_pkgs],
55 [vala_pkg_exists=yes],
58 AS_IF([test x${vala_pkg_exists} = xno],[
59 ifelse([$3], , [AC_MSG_ERROR([]dnl
60 [Package requirements were not met: $1
64 Consider adjusting the XDG_DATA_DIRS environment variable if you
65 installed bindings in a non-standard prefix.
70 ifelse([$2], , :, [$2])[]dnl
73 ])# VALA_CHECK_PACKAGES
76 # Check for Vala bindings for a package, as well as the pkg-config
77 # CFLAGS and LIBS for the package. The arguments here work the
78 # same as those for PKG_CHECK_MODULES, which is called internally.
79 # As a result, the _CFLAGS, _LIBS, and _VALAFLAGS variables will
80 # all be declared, rather than only _VALAFLAGS.
82 # VALA_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
83 # [ACTION-IF-NOT-FOUND])
84 # --------------------------------------------------------------
85 AC_DEFUN([VALA_CHECK_MODULES],
87 AC_REQUIRE([AM_PROG_VALAC])dnl
88 AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
89 AC_REQUIRE([_VALA_CHECK_COMPILE_WITH_ARGS])dnl
90 AC_ARG_VAR([$1][_VALAFLAGS], [Vala compiler flags for $1])dnl
92 VALA_MODULES="`echo $2 | sed -e 's/ [[=<>]]\+ [[0-9.]]\+//g'`"
93 for MODULE in $VALA_MODULES; do
94 $1[]_VALAFLAGS="$[]$1[]_VALAFLAGS --pkg $MODULE"
97 PKG_CHECK_MODULES([$1], [$2], [$3], [$4])
100 AC_MSG_CHECKING([for $1 vala modules])
102 _VALA_CHECK_COMPILE_WITH_ARGS([$1][_VALAFLAGS],
106 if test $pkg_failed = yes; then
108 m4_default([$4], [AC_MSG_ERROR(
109 [Package requirements ($2) were not met.])dnl
113 m4_default([$3], [:])
117 # Check whether the Vala API Generator exists in `PATH'. If it is found,
118 # the variable VAPIGEN is set. Optionally a minimum release number of the
119 # generator can be requested.
121 # VALA_PROG_VAPIGEN([MINIMUM-VERSION])
122 # ------------------------------------
123 AC_DEFUN([VALA_PROG_VAPIGEN],
124 [AC_PATH_PROG([VAPIGEN], [vapigen], [])
125 AS_IF([test -z "$VAPIGEN"],
126 [AC_MSG_WARN([No Vala API Generator found. You will not be able to generate .vapi files.])],
127 [AS_IF([test -n "$1"],
128 [AC_MSG_CHECKING([$VAPIGEN is at least version $1])
129 am__vapigen_version=`$VAPIGEN --version | sed 's/Vala API Generator *//'`
130 AS_VERSION_COMPARE([$1], ["$am__vapigen_version"],
131 [AC_MSG_RESULT([yes])],
132 [AC_MSG_RESULT([yes])],
134 AC_MSG_ERROR([Vala API Generator $1 not found.])])])])