spec: remove pkg_initdb in post script
[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_CHECK_PACKAGES(LIST-OF-PACKAGES,
30 #   ACTION-IF-FOUND)
31 # ---------------------------------------
32 # Version of VALA_CHECK_PACKAGES that will only run if vala support is
33 # enabled. Otherwise ACTION-IF-FOUND will be run.
34 AC_DEFUN([RYGEL_CHECK_PACKAGES],
35 [
36     AS_IF([test "x$enable_vala" = "xyes"],
37           [
38                 VALA_CHECK_PACKAGES([$1],[$2])
39           ],
40           [
41                 $2
42           ])
43 ])
44
45 # _RYGEL_ADD_PLUGIN_INTERNAL(NAME-OF-PLUGIN,
46 #   NAME-OF-PLUGIN-WITH-UNDERSCORES,
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_INTERNAL],
53 [
54     AC_ARG_ENABLE([$1-plugin],
55         AS_HELP_STRING([--enable-$1-plugin],[enable $3 plugin]),,
56         enable_$2_plugin=$4)
57     AC_CONFIG_FILES([src/plugins/$1/Makefile])
58     AM_CONDITIONAL(m4_toupper(build_$2_plugin), test "x$[]enable_$2_plugin" = "xyes")
59     RYGEL_ADD_STAMP([src/plugins/$1/librygel_$2_la_vala.stamp])
60     AC_CONFIG_FILES([src/plugins/$1/$1.plugin])
61 ])
62
63 # _RYGEL_ADD_PLUGIN_INTERNAL(NAME-OF-PLUGIN,
64 #   NAME-OF-PLUGIN-FOR-HELP,
65 #   DEFAULT-FOR-ENABLE)
66 # --------------------------------------
67 # Add an --enable-plugin option, add its Makefile to AC_OUTPUT and set the
68 # conditional
69 AC_DEFUN([RYGEL_ADD_PLUGIN],
70 [
71     _RYGEL_ADD_PLUGIN_INTERNAL([$1],
72         m4_translit([$1],[-],[_]),
73         [$2],
74         [$3])
75 ])
76
77 AC_DEFUN([_RYGEL_DISABLE_PLUGIN_INTERNAL],
78 [
79     AM_CONDITIONAL(m4_toupper(build_$1_plugin), false)
80     enable_$1_plugin="n/a"
81 ])
82
83 AC_DEFUN([RYGEL_DISABLE_PLUGIN],
84 [
85     _RYGEL_DISABLE_PLUGIN_INTERNAL(m4_translit([$1],[-],[_]))
86 ])
87
88 AC_DEFUN([RYGEL_CHECK_VALA],
89 [
90     AC_ARG_ENABLE([vala],
91         [AS_HELP_STRING([--enable-vala],[enable checks for vala])],,
92             [enable_vala=no])
93     AC_ARG_ENABLE([strict-valac],
94         [AS_HELP_STRING([--enable-strict-valac],[enable strict Vala compiler])],,
95               [enable_strict_valac=no])
96     AS_IF([test "x$enable_strict_valac" = "xyes"],
97           [RYGEL_ADD_VALAFLAGS([--fatal-warnings])])
98     AC_SUBST([VALAFLAGS])
99
100     dnl Enable check for Vala even if not asked to do so if stamp files are absent.
101     for stamp in $rygel_stamp_files
102     do
103         AS_IF([test ! -e "$stamp"],
104               [AC_MSG_WARN([Missing stamp file $[]stamp. Forcing vala mode])
105                enable_vala=yes
106               ])
107     done
108
109     dnl Vala
110     AS_IF([test x$enable_vala = xyes],
111           [dnl check for vala
112            AM_PROG_VALAC([$1])
113
114             AS_IF([test x$VALAC = "x"],
115                 [AC_MSG_ERROR([Cannot find the "valac" compiler in your PATH])],
116                 [
117                     VALA_CHECK_PACKAGES([$2])
118                 ])
119            ],
120            []
121     )
122
123     VAPIDIR="${datadir}/vala/vapi"
124     AC_SUBST(VAPIDIR)
125 ])