1 dnl with_pkg.m4 - Macros to ease the usage of pkg-config. -*- Autoconf -*-
3 dnl Copyright © 2008 Luca Barbato <lu_zero@gentoo.org>,
4 dnl Diego Pettenò <flameeyes@gentoo.org>
6 dnl This program is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 2 of the License, or
9 dnl (at your option) any later version.
11 dnl This program is distributed in the hope that it will be useful, but
12 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 dnl General Public License for more details.
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with this program; if not, write to the Free Software
18 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 dnl As a special exception to the GNU General Public License, if you
21 dnl distribute this file as part of a program that contains a
22 dnl configuration script generated by Autoconf, you may include it under
23 dnl the same distribution terms that you use for the rest of that program.
25 dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
26 dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
27 dnl [DESCRIPTION], [DEFAULT])
29 dnl Prepare a --with-variable-prefix triggered check for module,
30 dnl disable by default.
33 AC_DEFUN([PKG_WITH_MODULES],
35 m4_pushdef([with_arg], m4_tolower([$1]))
37 m4_pushdef([description],
38 [m4_default([$5], [build with ]with_arg[ support])])
40 m4_pushdef([def_arg], [m4_default([$6], [auto])])
41 m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
42 m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
45 [yes],[m4_pushdef([with_without], [--without-]with_arg)],
46 [m4_pushdef([with_without],[--with-]with_arg)])
49 AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
50 [AS_TR_SH([with_]with_arg)=def_arg])
52 AS_CASE([$AS_TR_SH([with_]with_arg)],
53 [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
54 [auto],[PKG_CHECK_MODULES([$1],[$2],
55 [m4_n([def_action_if_found]) $3],
56 [m4_n([def_action_if_not_found]) $4])])
59 m4_popdef([description])
62 ]) dnl PKG_WITH_MODULES
64 dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
65 dnl [DESCRIPTION], [DEFAULT])
68 AC_DEFUN([PKG_HAVE_WITH_MODULES],
70 PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
72 AM_CONDITIONAL([HAVE_][$1],
73 [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
76 dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
77 dnl [DESCRIPTION], [DEFAULT])
80 AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
82 PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
84 AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
85 [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])