VAPIGEN_CHECK
PKG_CHECK_MODULES(VALA, [libvala-0.32],[have_libvala=yes],[have_libvala=no])
VALA_VERSION=0.32
AS_IF([test x$have_libvala = xno],[
	PKG_CHECK_MODULES(VALA, [libvala-0.30 >= 0.29.3],[have_libvala=yes],[have_libvala=no])
	VALA_VERSION=0.30
])
AC_SUBST(VALA_VERSION)

# --enable-vala-pack-plugin=auto/yes/no
AC_ARG_ENABLE([vala-pack-plugin],
              [AS_HELP_STRING([--enable-vala-pack-plugin=@<:@auto/yes/no@:>@],
                              [Build with support for vala enhancements such as auto completion.])],
              [enable_vala_pack_plugin=$enableval],
              [enable_vala_pack_plugin=auto])

AS_IF([test x$enable_vala_pack_plugin = xauto],[
	AS_IF([test x$have_libvala = xyes && test x$enable_vala = xyes],
	      [enable_vala_pack_plugin=yes],
	      [enable_vala_pack_plugin=no])
])

AS_IF([test x$enable_vala_pack_plugin = xyes],[
	AS_IF([test x$enable_vala != xyes || test x$have_libvala != xyes],[
		AC_MSG_ERROR([Please install both the vala compiler and vapigen. vapigen may be part of your systems vala-tools package.])
	])

	AS_IF([test x$have_libvala = xyes],[
		cflags_save="${CFLAGS}"
		libs_save="${LIBS}"
		CFLAGS="${CFLAGS} ${VALA_CFLAGS}"
		LIBS="${LIBS} ${VALA_LIBS}"
		AC_MSG_CHECKING([if vala uses old-style symbol deprecations])
		AC_TRY_LINK([#include <vala.h>],[
			vala_symbol_get_deprecated (NULL);
		],
		[have_vala_symbol_get_deprecated=yes],
		[have_vala_symbol_get_deprecated=no])
		CFLAGS="${cflags_save}"
		LIBS="${libs_save}"
	])
	AC_MSG_RESULT([$have_vala_symbol_get_deprecated])
])

# for if ENABLE_VALA_SYMBOL_GET_DEPRECATED in .vala files
AM_CONDITIONAL(ENABLE_VALA_SYMBOL_GET_DEPRECATED, test x$have_vala_symbol_get_deprecated = xyes)

# for if ENABLE_VALA_PACK_PLUGIN in Makefile.am
AM_CONDITIONAL(ENABLE_VALA_PACK_PLUGIN, test x$enable_vala_pack_plugin = xyes)

# Ensure our makefile is generated by autoconf
AC_CONFIG_FILES([plugins/vala-pack/Makefile])
