346ff12dd2772e626969388badde7bfd75b4d560
[profile/ivi/rygel.git] / m4 / rygel.m4
1 dnl rygel.m4
2 dnl
3 dnl Copyright 2011 Jens Georg
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 AC_DEFUN([RYGEL_ADD_STAMP],
20 [
21     rygel_stamp_files="$rygel_stamp_files $srcdir/$1"
22 ])
23
24 AC_DEFUN([RYGEL_ADD_VALAFLAGS],
25 [
26     VALAFLAGS="${VALAFLAGS:+$VALAFLAGS }$1"
27 ])
28
29 # _RYGEL_ADD_PLUGIN_INTERNAL(NAME-OF-PLUGIN,
30 #   NAME-OF-PLUGIN-WITH-UNDERSCORES,
31 #   NAME-OF-PLUGIN-FOR-HELP,
32 #   DEFAULT-FOR-ENABLE)
33 # --------------------------------------
34 # Add an --enable-plugin option, add its Makefile to AC_OUTPUT and set the
35 # conditional
36 AC_DEFUN([_RYGEL_ADD_PLUGIN_INTERNAL],
37 [
38     AC_ARG_ENABLE([$1-plugin],
39         AS_HELP_STRING([--enable-$1-plugin],[enable $3 plugin]),,
40         enable_$2_plugin=$4)
41     AC_CONFIG_FILES([src/plugins/$1/Makefile])
42     AM_CONDITIONAL(m4_toupper(build_$2_plugin), test "x$[]enable_$2_plugin" = "xyes")
43     RYGEL_ADD_STAMP([src/plugins/$1/librygel_$2_la_vala.stamp])
44 ])
45
46 # _RYGEL_ADD_PLUGIN_INTERNAL(NAME-OF-PLUGIN,
47 #   NAME-OF-PLUGIN-FOR-HELP,
48 #   DEFAULT-FOR-ENABLE)
49 # --------------------------------------
50 # Add an --enable-plugin option, add its Makefile to AC_OUTPUT and set the
51 # conditional
52 AC_DEFUN([RYGEL_ADD_PLUGIN],
53 [
54     _RYGEL_ADD_PLUGIN_INTERNAL([$1],
55         m4_translit([$1],[-],[_]),
56         [$2],
57         [$3])
58 ])
59
60 AC_DEFUN([RYGEL_CHECK_VALA],
61 [AC_REQUIRE([AM_PROG_VALAC])[]dnl
62     AC_ARG_ENABLE([vala],
63         [AS_HELP_STRING([--enable-vala],[enable checks for vala])],,
64             [enable_vala=no])
65     AC_ARG_ENABLE([strict-valac],
66         [AS_HELP_STRING([--enable-strict-valac],[enable strict Vala compiler])],,
67               [enable_strict_valac=no])
68     AS_IF([test "x$enable_strict_valac" = "xyes"],
69           [RYGEL_ADD_VALAFLAGS([--fatal-warnings])])
70     AC_SUBST([VALAFLAGS])
71
72     dnl Enable check for Vala even if not asked to do so if stamp files are absent.
73     for stamp in $rygel_stamp_files
74     do
75         AS_IF([test ! -e "$stamp"],
76               [AC_MSG_WARN([Missing stamp file $[]stamp. Forcing vala mode])
77                enable_vala=yes
78               ])
79     done
80
81     dnl Vala
82     AS_IF([test x$enable_vala = xyes],
83           [dnl check for vala
84            AM_PROG_VALAC([$1])
85
86             AS_IF([test x$VALAC = "x"],
87                 [AC_MSG_ERROR([Cannot find the "valac" compiler in your PATH])],
88                 [
89                     PKG_CHECK_MODULES(GUPNP_VALA, gupnp-vala-1.0 >= $GUPNP_VALA_REQUIRED)
90
91                     VALA_CHECK_PACKAGES([$2])
92                 ])
93            ],
94            []
95     )
96
97     VAPIDIR="${datadir}/vala/vapi"
98     AC_SUBST(VAPIDIR)
99 ])