Update Polish translation
[dasher.git] / m4 / pkg.m4
blob89100b1c729be2b33e768e73e7ec948eda5492fd
1 # pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
2 # serial 1 (pkg-config-0.24)
3
4 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, see <http://www.gnu.org/licenses/>.
19 # As a special exception to the GNU General Public License, if you
20 # distribute this file as part of a program that contains a
21 # configuration script generated by Autoconf, you may include it under
22 # the same distribution terms that you use for the rest of that program.
24 # PKG_PROG_PKG_CONFIG([MIN-VERSION])
25 # ----------------------------------
26 AC_DEFUN([PKG_PROG_PKG_CONFIG],
27 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
28 m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
29 m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
30 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
31 AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
32 AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
34 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
35         AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
37 if test -n "$PKG_CONFIG"; then
38         _pkg_min_version=m4_default([$1], [0.9.0])
39         AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
40         if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
41                 AC_MSG_RESULT([yes])
42         else
43                 AC_MSG_RESULT([no])
44                 PKG_CONFIG=""
45         fi
46 fi[]dnl
47 ])# PKG_PROG_PKG_CONFIG
49 # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
51 # Check to see whether a particular set of modules exists.  Similar
52 # to PKG_CHECK_MODULES(), but does not set variables or print errors.
54 # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
55 # only at the first occurence in configure.ac, so if the first place
56 # it's called might be skipped (such as if it is within an "if", you
57 # have to call PKG_CHECK_EXISTS manually
58 # --------------------------------------------------------------
59 AC_DEFUN([PKG_CHECK_EXISTS],
60 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
61 if test -n "$PKG_CONFIG" && \
62     AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
63   m4_default([$2], [:])
64 m4_ifvaln([$3], [else
65   $3])dnl
66 fi])
68 # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
69 # ---------------------------------------------
70 m4_define([_PKG_CONFIG],
71 [if test -n "$$1"; then
72     pkg_cv_[]$1="$$1"
73  elif test -n "$PKG_CONFIG"; then
74     PKG_CHECK_EXISTS([$3],
75                      [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
76                       test "x$?" != "x0" && pkg_failed=yes ],
77                      [pkg_failed=yes])
78  else
79     pkg_failed=untried
80 fi[]dnl
81 ])# _PKG_CONFIG
83 # _PKG_SHORT_ERRORS_SUPPORTED
84 # -----------------------------
85 AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
86 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])
87 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
88         _pkg_short_errors_supported=yes
89 else
90         _pkg_short_errors_supported=no
91 fi[]dnl
92 ])# _PKG_SHORT_ERRORS_SUPPORTED
95 # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
96 # [ACTION-IF-NOT-FOUND])
99 # Note that if there is a possibility the first call to
100 # PKG_CHECK_MODULES might not happen, you should be sure to include an
101 # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
104 # --------------------------------------------------------------
105 AC_DEFUN([PKG_CHECK_MODULES],
106 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
107 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
108 AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
110 pkg_failed=no
111 AC_MSG_CHECKING([for $1])
113 _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
114 _PKG_CONFIG([$1][_LIBS], [libs], [$2])
116 m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
117 and $1[]_LIBS to avoid the need to call pkg-config.
118 See the pkg-config man page for more details.])
120 if test $pkg_failed = yes; then
121         AC_MSG_RESULT([no])
122         _PKG_SHORT_ERRORS_SUPPORTED
123         if test $_pkg_short_errors_supported = yes; then
124                 $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
125         else 
126                 $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
127         fi
128         # Put the nasty error message in config.log where it belongs
129         echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
131         m4_default([$4], [AC_MSG_ERROR(
132 [Package requirements ($2) were not met:
134 $$1_PKG_ERRORS
136 Consider adjusting the PKG_CONFIG_PATH environment variable if you
137 installed software in a non-standard prefix.
139 _PKG_TEXT])[]dnl
140         ])
141 elif test $pkg_failed = untried; then
142         AC_MSG_RESULT([no])
143         m4_default([$4], [AC_MSG_FAILURE(
144 [The pkg-config script could not be found or is too old.  Make sure it
145 is in your PATH or set the PKG_CONFIG environment variable to the full
146 path to pkg-config.
148 _PKG_TEXT
150 To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
151         ])
152 else
153         $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
154         $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
155         AC_MSG_RESULT([yes])
156         $3
157 fi[]dnl
158 ])# PKG_CHECK_MODULES
161 # PKG_INSTALLDIR(DIRECTORY)
162 # -------------------------
163 # Substitutes the variable pkgconfigdir as the location where a module
164 # should install pkg-config .pc files. By default the directory is
165 # $libdir/pkgconfig, but the default can be changed by passing
166 # DIRECTORY. The user can override through the --with-pkgconfigdir
167 # parameter.
168 AC_DEFUN([PKG_INSTALLDIR],
169 [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
170 m4_pushdef([pkg_description],
171     [pkg-config installation directory @<:@]pkg_default[@:>@])
172 AC_ARG_WITH([pkgconfigdir],
173     [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
174     [with_pkgconfigdir=]pkg_default)
175 AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
176 m4_popdef([pkg_default])
177 m4_popdef([pkg_description])
178 ]) dnl PKG_INSTALLDIR
181 # PKG_NOARCH_INSTALLDIR(DIRECTORY)
182 # -------------------------
183 # Substitutes the variable noarch_pkgconfigdir as the location where a
184 # module should install arch-independent pkg-config .pc files. By
185 # default the directory is $datadir/pkgconfig, but the default can be
186 # changed by passing DIRECTORY. The user can override through the
187 # --with-noarch-pkgconfigdir parameter.
188 AC_DEFUN([PKG_NOARCH_INSTALLDIR],
189 [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
190 m4_pushdef([pkg_description],
191     [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
192 AC_ARG_WITH([noarch-pkgconfigdir],
193     [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
194     [with_noarch_pkgconfigdir=]pkg_default)
195 AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
196 m4_popdef([pkg_default])
197 m4_popdef([pkg_description])
198 ]) dnl PKG_NOARCH_INSTALLDIR