fix and use the mmap-anon.m4 macro for our purpose (untested)
[nobug.git] / m4 / with_pkg.m4
blob9931ec4501243ede3d3a6e54179cba8d632b8278
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
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.
10 dnl
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.
15 dnl
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.
19 dnl
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])
28 dnl
29 dnl Prepare a --with-variable-prefix triggered check for module,
30 dnl disable by default.
31 dnl
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])
44 m4_case(def_arg,
45             [yes],[m4_pushdef([with_without], [--without-]with_arg)],
46             [m4_pushdef([with_without],[--with-]with_arg)])
48 AC_ARG_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])])
58 m4_popdef([with_arg])
59 m4_popdef([description])
60 m4_popdef([def_arg])
62 ]) dnl PKG_WITH_MODULES
64 dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
65 dnl                       [DESCRIPTION], [DEFAULT])
66 dnl
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])
78 dnl
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])])