packaging: depend on the same release
[platform/upstream/vala.git] / vala.m4
1 dnl vala.m4
2 dnl
3 dnl Copyright 2010 Marc-Andre Lureau
4 dnl Copyright 2011 Rodney Dawes <dobey.pwns@gmail.com>
5 dnl
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.
10 dnl
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.
15 dnl
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
19
20 # _VALA_CHECK_COMPILE_WITH_ARGS(ARGS, [ACTION-IF-TRUE],
21 #   [ACTION-IF-FALSE])
22 # --------------------------------------
23 # Check that Vala compile with ARGS.
24 #
25 AC_DEFUN([_VALA_CHECK_COMPILE_WITH_ARGS],
26 [AC_REQUIRE([AM_PROG_VALAC])[]dnl
27
28   cat <<_ACEOF >conftest.vala
29 void main(){}
30 _ACEOF
31
32   AS_IF([vala_error=`$VALAC $1 -q --cc="${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}" -o conftest$ac_exeext conftest.vala 2>&1`],
33         [$2], [$3])
34 ])
35
36 ])# _VALA_CHECK_COMPILE_WITH_ARGS
37
38 # VALA_CHECK_PACKAGES(PKGS, [ACTION-IF-FOUND],
39 #   [ACTION-IF-NOT-FOUND])
40 # --------------------------------------
41 # Check that PKGS Vala bindings are installed and usable.
42 #
43 AC_DEFUN([VALA_CHECK_PACKAGES],
44 [
45   unset vala_pkgs
46   unset vala_bindings
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"
51   done
52   IFS="$ac_save_ifs"
53   AC_MSG_CHECKING([for $vala_bindings vala bindings])
54   _VALA_CHECK_COMPILE_WITH_ARGS([$vala_pkgs],
55     [vala_pkg_exists=yes],
56     [vala_pkg_exists=no])
57
58 AS_IF([test x${vala_pkg_exists} = xno],[
59   ifelse([$3], , [AC_MSG_ERROR([]dnl
60 [Package requirements were not met: $1
61
62 $vala_error
63
64 Consider adjusting the XDG_DATA_DIRS environment variable if you
65 installed bindings in a non-standard prefix.
66 ])],
67   [AC_MSG_RESULT([no])
68 $3])],[
69   AC_MSG_RESULT([yes])
70   ifelse([$2], , :, [$2])[]dnl
71 ])
72
73 ])# VALA_CHECK_PACKAGES
74
75
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.
81 #
82 # VALA_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
83 # [ACTION-IF-NOT-FOUND])
84 # --------------------------------------------------------------
85 AC_DEFUN([VALA_CHECK_MODULES],
86 [
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
91
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"
95         done
96
97         PKG_CHECK_MODULES([$1], [$2], [$3], [$4])
98
99         pkg_failed=no
100                 AC_MSG_CHECKING([for $1 vala modules])
101
102         _VALA_CHECK_COMPILE_WITH_ARGS([$1][_VALAFLAGS],
103                                       [pkg_failed=yes],
104                                       [pkg_failed=no])
105
106                 if test $pkg_failed = yes; then
107                    AC_MSG_RESULT([no])
108                    m4_default([$4], [AC_MSG_ERROR(
109                                                         [Package requirements ($2) were not met.])dnl
110                    ])
111                 else
112                         AC_MSG_RESULT([yes])
113                         m4_default([$3], [:])
114                 fi[]dnl
115 ])
116
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.
120 #
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])],
133            [AC_MSG_RESULT([no])
134             AC_MSG_ERROR([Vala API Generator $1 not found.])])])])
135 ])