1dnl GP_CHECK_VALAC([version], [action-if-found], [action-if-not-found])
2dnl Checks for the Vala compiler.  Similar to AM_PROG_VALAC but supports
3dnl 2nd and 3rd arguments with Automake < 1.12.5
4AC_DEFUN([GP_CHECK_VALAC],
5[
6    gp_have_valac=yes
7    AM_PROG_VALAC([$1],,[gp_have_valac=no])
8    dnl Automake < 1.12.5 does not support 3rd arg but leaves $VALAC
9    dnl empty if not found, so emulate it
10    AS_IF([test "x$VALAC" = x], [gp_have_valac=no])
11    AS_IF([test "$gp_have_valac" = yes],
12          [m4_default([$2], [:])],
13          [m4_default([$3], [:])])
14])
15
16dnl GP_CHECK_PLUGIN_VALA(plugin, [valac-version])
17dnl Checks for the Vala compiler and takes the appropriate action on
18dnl $plugin depending on its presence.
19dnl FIXME: take into account that the compiler is optional if we have
20dnl        the generated C sources
21AC_DEFUN([GP_CHECK_PLUGIN_VALA],
22[
23    AS_IF([test "$m4_tolower(AS_TR_SH(enable_$1))" = no],[],
24          [GP_CHECK_VALAC([$2],
25                          [dnl we fake the checking messages here because
26                           dnl GP_CHECK_VALAC outputs messages itself
27                           AC_MSG_CHECKING([whether the vala compiler is compatible with $1])
28                           AC_MSG_RESULT([yes])],
29                          [AC_MSG_CHECKING([whether the vala compiler is compatible with $1])
30                           AC_MSG_RESULT([no])
31                           AS_IF([test "$m4_tolower(AS_TR_SH(enable_$1))" = yes],
32                                 [AC_MSG_ERROR([$1 requires the Vala compiler])],
33                                 [test "$m4_tolower(AS_TR_SH(enable_$1))" = auto],
34                                 [m4_tolower(AS_TR_SH(enable_$1))=no])])])
35])
36