Add . and whitespace
[vlc.git] / m4 / with_pkg.m4
blob39439b792ff8924620edf7722f380c68014dada9
1 dnl with_pkg.m4 - Macros to ease the usage of pkg-config.    -*- Autoconf -*-
2 dnl
3 dnl Copyright © 2008 Luca Barbato <lu_zero@gentoo.org>,
4 dnl                  Diego Pettenò <flameeyes@gentoo.org>
5 dnl                  Jean-Baptiste Kempf
6 dnl
7 dnl This program is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 2 of the License, or
10 dnl (at your option) any later version.
11 dnl
12 dnl This program is distributed in the hope that it will be useful, but
13 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 dnl General Public License for more details.
16 dnl
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program; if not, write to the Free Software
19 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 dnl
21 dnl As a special exception to the GNU General Public License, if you
22 dnl distribute this file as part of a program that contains a
23 dnl configuration script generated by Autoconf, you may include it under
24 dnl the same distribution terms that you use for the rest of that program.
26 dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
27 dnl                  [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
28 dnl                  [DESCRIPTION], [DEFAULT])
29 dnl
30 dnl Prepare a --with-variable-prefix triggered check for module,
31 dnl disable by default.
32 dnl
34 AC_DEFUN([PKG_WITH_MODULES],
36 AC_REQUIRE([PKG_PROG_PKG_CONFIG])
37 m4_pushdef([with_arg], m4_tolower([$1]))
39 m4_pushdef([description],
40            [m4_default([$5], [build with ]with_arg[ support enabled])])
42 m4_pushdef([def_arg], [m4_default([$6], [auto])])
43 m4_pushdef([def_action_if_found], [AS_TR_SH([enable_]with_arg)=yes])
44 m4_pushdef([def_action_if_not_found], [AS_TR_SH([enable_]with_arg)=no])
46 m4_case(def_arg,
47             [yes],[m4_pushdef([with_without], [--disable-]with_arg)],
48             [m4_pushdef([with_without],[--enable-]with_arg)])
50 AC_ARG_ENABLE(with_arg,
51      AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
52     [AS_TR_SH([enable_]with_arg)=def_arg])
54 AS_CASE([$AS_TR_SH([enable_]with_arg)],
55             [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
56             [auto],[PKG_CHECK_MODULES([$1],[$2],
57                                         [m4_n([def_action_if_found]) $3],
58                                         [m4_n([def_action_if_not_found]) $4])])
60 m4_popdef([with_arg])
61 m4_popdef([description])
62 m4_popdef([def_arg])
64 ]) dnl PKG_WITH_MODULES
66 dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
67 dnl                       [DESCRIPTION], [DEFAULT])
68 dnl
70 AC_DEFUN([PKG_HAVE_WITH_MODULES],
72 PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
74 AM_CONDITIONAL([HAVE_][$1],
75                [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
78 dnl PKG_ENABLE_MODULES_VLC(VARIABLE-PREFIX,
79 dnl                         VLC_MODULE_NAME  dnl (if empty, same as VARIABLE-PREFIX)
80 dnl                         PKG MODULES,
81 dnl                         [DESCRIPTION], [DEFAULT],
82 dnl                         [EXTRA_CFLAGS], [EXTRA_LIBS], [EXTRA_CPPFLAGS]
83 AC_DEFUN([PKG_ENABLE_MODULES_VLC],
85 m4_pushdef([module_names], m4_default(m4_tolower([$2]),m4_tolower([$1])))
86 m4_pushdef([enable_arg], m4_tolower([$1]))
88 PKG_WITH_MODULES([$1],[$3],
89     VLC_ADD_PLUGIN(module_names)
90     m4_ifval( m4_normalize([$8]), VLC_ADD_CPPFLAGS(module_names, [$8]))
91     VLC_ADD_CFLAGS(module_names,[$$1_CFLAGS] [$6])
92     VLC_ADD_LIBS(module_names,[$$1_LIBS] [$7]),
93     AS_IF([test x"$AS_TR_SH([enable_]enable_arg)" = "xyes"],
94         [AC_MSG_ERROR(Library [$3] needed for [m4_tolower([$1])] was not found)],
95         [AC_MSG_WARN(Library [$3] needed for [m4_tolower([$1])] was not found)]
96          ),
97     [$4],[$5])
99 m4_popdef([module_names])
100 m4_popdef([enable_arg])