]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - m4/vapigen.m4
Load all users only when really needed
[sojka/lightdm.git] / m4 / vapigen.m4
1 dnl vapigen.m4
2 dnl
3 dnl Copyright 2012 Evan Nemerson
4 dnl
5 dnl This library is free software; you can redistribute it and/or
6 dnl modify it under the terms of the GNU Lesser General Public
7 dnl License as published by the Free Software Foundation; either
8 dnl version 2.1 of the License, or (at your option) any later version.
9 dnl
10 dnl This library is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 dnl Lesser General Public License for more details.
14 dnl
15 dnl You should have received a copy of the GNU Lesser General Public
16 dnl License along with this library; if not, write to the Free Software
17 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
18
19 # VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND_INTROSPECTION], [DEFAULT])
20 # --------------------------------------
21 # Check vapigen existence and version
22 #
23 # See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation
24 AC_DEFUN([VAPIGEN_CHECK],
25 [
26   AS_IF([test "x$3" != "xyes"], [
27       m4_provide_if([GOBJECT_INTROSPECTION_CHECK], [], [
28           m4_provide_if([GOBJECT_INTROSPECTION_REQUIRE], [], [
29               AC_MSG_ERROR([[You must call GOBJECT_INTROSPECTION_CHECK or GOBJECT_INTROSPECTION_REQUIRE before using VAPIGEN_CHECK unless using the FOUND_INTROSPECTION argument is "yes"]])
30             ])
31         ])
32     ])
33
34   AC_ARG_ENABLE([vala],
35     [AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]],[build Vala bindings @<:@default=]ifelse($4,,auto,$4)[@:>@])],,[
36       AS_IF([test "x$4" = "x"], [
37           enable_vala=auto
38         ], [
39           enable_vala=$4
40         ])
41     ])
42
43   AS_CASE([$enable_vala], [no], [enable_vala=no],
44       [yes], [
45         AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
46             AC_MSG_ERROR([Vala bindings require GObject Introspection])
47           ])
48       ], [auto], [
49         AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
50             enable_vala=no
51           ])
52       ], [
53         AC_MSG_ERROR([Invalid argument passed to --enable-vala, should be one of @<:@no/auto/yes@:>@])
54       ])
55
56   AS_IF([test "x$2" = "x"], [
57       vapigen_pkg_name=vapigen
58     ], [
59       vapigen_pkg_name=vapigen-$2
60     ])
61   AS_IF([test "x$1" = "x"], [
62       vapigen_pkg="$vapigen_pkg_name"
63     ], [
64       vapigen_pkg="$vapigen_pkg_name >= $1"
65     ])
66
67   PKG_PROG_PKG_CONFIG
68
69   PKG_CHECK_EXISTS([$vapigen_pkg], [
70       AS_IF([test "$enable_vala" = "auto"], [
71           enable_vala=yes
72         ])
73     ], [
74       AS_CASE([$enable_vala], [yes], [
75           AC_MSG_ERROR([$vapigen_pkg not found])
76         ], [auto], [
77           enable_vala=no
78         ])
79     ])
80
81   AC_MSG_CHECKING([for vapigen])
82
83   AS_CASE([$enable_vala],
84     [yes], [
85       VAPIGEN=`$PKG_CONFIG --variable=vapigen $vapigen_pkg_name`
86       VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir $vapigen_pkg_name`/vala/Makefile.vapigen
87       AS_IF([test "x$2" = "x"], [
88           VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir $vapigen_pkg_name`
89         ], [
90           VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned $vapigen_pkg_name`
91         ])
92     ])
93
94   AC_MSG_RESULT([$enable_vala])
95
96   AC_SUBST([VAPIGEN])
97   AC_SUBST([VAPIGEN_VAPIDIR])
98   AC_SUBST([VAPIGEN_MAKEFILE])
99
100   AM_CONDITIONAL(ENABLE_VAPIGEN, test "x$enable_vala" = "xyes")
101 ])