xref: /minix3/crypto/external/bsd/heimdal/dist/cf/pkg.m4 (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
2*ebfedea0SLionel Sambuc#
3*ebfedea0SLionel Sambuc# Copyright � 2004 Scott James Remnant <scott@netsplit.com>.
4*ebfedea0SLionel Sambuc#
5*ebfedea0SLionel Sambuc# This program is free software; you can redistribute it and/or modify
6*ebfedea0SLionel Sambuc# it under the terms of the GNU General Public License as published by
7*ebfedea0SLionel Sambuc# the Free Software Foundation; either version 2 of the License, or
8*ebfedea0SLionel Sambuc# (at your option) any later version.
9*ebfedea0SLionel Sambuc#
10*ebfedea0SLionel Sambuc# This program is distributed in the hope that it will be useful, but
11*ebfedea0SLionel Sambuc# WITHOUT ANY WARRANTY; without even the implied warranty of
12*ebfedea0SLionel Sambuc# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13*ebfedea0SLionel Sambuc# General Public License for more details.
14*ebfedea0SLionel Sambuc#
15*ebfedea0SLionel Sambuc# You should have received a copy of the GNU General Public License
16*ebfedea0SLionel Sambuc# along with this program; if not, write to the Free Software
17*ebfedea0SLionel Sambuc# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*ebfedea0SLionel Sambuc#
19*ebfedea0SLionel Sambuc# As a special exception to the GNU General Public License, if you
20*ebfedea0SLionel Sambuc# distribute this file as part of a program that contains a
21*ebfedea0SLionel Sambuc# configuration script generated by Autoconf, you may include it under
22*ebfedea0SLionel Sambuc# the same distribution terms that you use for the rest of that program.
23*ebfedea0SLionel Sambuc
24*ebfedea0SLionel Sambuc# PKG_PROG_PKG_CONFIG([MIN-VERSION])
25*ebfedea0SLionel Sambuc# ----------------------------------
26*ebfedea0SLionel SambucAC_DEFUN([PKG_PROG_PKG_CONFIG],
27*ebfedea0SLionel Sambuc[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
28*ebfedea0SLionel Sambucm4_pattern_allow([^PKG_CONFIG(_PATH)?$])
29*ebfedea0SLionel SambucAC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
30*ebfedea0SLionel Sambucif test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
31*ebfedea0SLionel Sambuc	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
32*ebfedea0SLionel Sambucfi
33*ebfedea0SLionel Sambucif test -n "$PKG_CONFIG"; then
34*ebfedea0SLionel Sambuc	_pkg_min_version=m4_default([$1], [0.9.0])
35*ebfedea0SLionel Sambuc	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
36*ebfedea0SLionel Sambuc	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
37*ebfedea0SLionel Sambuc		AC_MSG_RESULT([yes])
38*ebfedea0SLionel Sambuc	else
39*ebfedea0SLionel Sambuc		AC_MSG_RESULT([no])
40*ebfedea0SLionel Sambuc		PKG_CONFIG=""
41*ebfedea0SLionel Sambuc	fi
42*ebfedea0SLionel Sambuc
43*ebfedea0SLionel Sambucfi[]dnl
44*ebfedea0SLionel Sambuc])# PKG_PROG_PKG_CONFIG
45*ebfedea0SLionel Sambuc
46*ebfedea0SLionel Sambuc# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
47*ebfedea0SLionel Sambuc#
48*ebfedea0SLionel Sambuc# Check to see whether a particular set of modules exists.  Similar
49*ebfedea0SLionel Sambuc# to PKG_CHECK_MODULES(), but does not set variables or print errors.
50*ebfedea0SLionel Sambuc#
51*ebfedea0SLionel Sambuc#
52*ebfedea0SLionel Sambuc# Similar to PKG_CHECK_MODULES, make sure that the first instance of
53*ebfedea0SLionel Sambuc# this or PKG_CHECK_MODULES is called, or make sure to call
54*ebfedea0SLionel Sambuc# PKG_CHECK_EXISTS manually
55*ebfedea0SLionel Sambuc# --------------------------------------------------------------
56*ebfedea0SLionel SambucAC_DEFUN([PKG_CHECK_EXISTS],
57*ebfedea0SLionel Sambuc[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
58*ebfedea0SLionel Sambucif test -n "$PKG_CONFIG" && \
59*ebfedea0SLionel Sambuc    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
60*ebfedea0SLionel Sambuc  m4_ifval([$2], [$2], [:])
61*ebfedea0SLionel Sambucm4_ifvaln([$3], [else
62*ebfedea0SLionel Sambuc  $3])dnl
63*ebfedea0SLionel Sambucfi])
64*ebfedea0SLionel Sambuc
65*ebfedea0SLionel Sambuc
66*ebfedea0SLionel Sambuc# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
67*ebfedea0SLionel Sambuc# ---------------------------------------------
68*ebfedea0SLionel Sambucm4_define([_PKG_CONFIG],
69*ebfedea0SLionel Sambuc[if test -n "$PKG_CONFIG"; then
70*ebfedea0SLionel Sambuc    if test -n "$$1"; then
71*ebfedea0SLionel Sambuc        pkg_cv_[]$1="$$1"
72*ebfedea0SLionel Sambuc    else
73*ebfedea0SLionel Sambuc        PKG_CHECK_EXISTS([$3],
74*ebfedea0SLionel Sambuc                         [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
75*ebfedea0SLionel Sambuc			 [pkg_failed=yes])
76*ebfedea0SLionel Sambuc    fi
77*ebfedea0SLionel Sambucelse
78*ebfedea0SLionel Sambuc	pkg_failed=untried
79*ebfedea0SLionel Sambucfi[]dnl
80*ebfedea0SLionel Sambuc])# _PKG_CONFIG
81*ebfedea0SLionel Sambuc
82*ebfedea0SLionel Sambuc# _PKG_SHORT_ERRORS_SUPPORTED
83*ebfedea0SLionel Sambuc# -----------------------------
84*ebfedea0SLionel SambucAC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
85*ebfedea0SLionel Sambuc[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
86*ebfedea0SLionel Sambucif $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
87*ebfedea0SLionel Sambuc        _pkg_short_errors_supported=yes
88*ebfedea0SLionel Sambucelse
89*ebfedea0SLionel Sambuc        _pkg_short_errors_supported=no
90*ebfedea0SLionel Sambucfi[]dnl
91*ebfedea0SLionel Sambuc])# _PKG_SHORT_ERRORS_SUPPORTED
92*ebfedea0SLionel Sambuc
93*ebfedea0SLionel Sambuc
94*ebfedea0SLionel Sambuc# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
95*ebfedea0SLionel Sambuc# [ACTION-IF-NOT-FOUND])
96*ebfedea0SLionel Sambuc#
97*ebfedea0SLionel Sambuc#
98*ebfedea0SLionel Sambuc# Note that if there is a possibility the first call to
99*ebfedea0SLionel Sambuc# PKG_CHECK_MODULES might not happen, you should be sure to include an
100*ebfedea0SLionel Sambuc# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
101*ebfedea0SLionel Sambuc#
102*ebfedea0SLionel Sambuc#
103*ebfedea0SLionel Sambuc# --------------------------------------------------------------
104*ebfedea0SLionel SambucAC_DEFUN([PKG_CHECK_MODULES],
105*ebfedea0SLionel Sambuc[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
106*ebfedea0SLionel SambucAC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
107*ebfedea0SLionel SambucAC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
108*ebfedea0SLionel Sambuc
109*ebfedea0SLionel Sambucpkg_failed=no
110*ebfedea0SLionel SambucAC_MSG_CHECKING([for $1])
111*ebfedea0SLionel Sambuc
112*ebfedea0SLionel Sambuc_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
113*ebfedea0SLionel Sambuc_PKG_CONFIG([$1][_LIBS], [libs], [$2])
114*ebfedea0SLionel Sambuc
115*ebfedea0SLionel Sambucm4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
116*ebfedea0SLionel Sambucand $1[]_LIBS to avoid the need to call pkg-config.
117*ebfedea0SLionel SambucSee the pkg-config man page for more details.])
118*ebfedea0SLionel Sambuc
119*ebfedea0SLionel Sambucif test $pkg_failed = yes; then
120*ebfedea0SLionel Sambuc        _PKG_SHORT_ERRORS_SUPPORTED
121*ebfedea0SLionel Sambuc        if test $_pkg_short_errors_supported = yes; then
122*ebfedea0SLionel Sambuc	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
123*ebfedea0SLionel Sambuc        else
124*ebfedea0SLionel Sambuc	        $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
125*ebfedea0SLionel Sambuc        fi
126*ebfedea0SLionel Sambuc	# Put the nasty error message in config.log where it belongs
127*ebfedea0SLionel Sambuc	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
128*ebfedea0SLionel Sambuc
129*ebfedea0SLionel Sambuc	ifelse([$4], , [AC_MSG_ERROR(dnl
130*ebfedea0SLionel Sambuc[Package requirements ($2) were not met:
131*ebfedea0SLionel Sambuc
132*ebfedea0SLionel Sambuc$$1_PKG_ERRORS
133*ebfedea0SLionel Sambuc
134*ebfedea0SLionel SambucConsider adjusting the PKG_CONFIG_PATH environment variable if you
135*ebfedea0SLionel Sambucinstalled software in a non-standard prefix.
136*ebfedea0SLionel Sambuc
137*ebfedea0SLionel Sambuc_PKG_TEXT
138*ebfedea0SLionel Sambuc])],
139*ebfedea0SLionel Sambuc		[AC_MSG_RESULT([no])
140*ebfedea0SLionel Sambuc                $4])
141*ebfedea0SLionel Sambucelif test $pkg_failed = untried; then
142*ebfedea0SLionel Sambuc	ifelse([$4], , [AC_MSG_FAILURE(dnl
143*ebfedea0SLionel Sambuc[The pkg-config script could not be found or is too old.  Make sure it
144*ebfedea0SLionel Sambucis in your PATH or set the PKG_CONFIG environment variable to the full
145*ebfedea0SLionel Sambucpath to pkg-config.
146*ebfedea0SLionel Sambuc
147*ebfedea0SLionel Sambuc_PKG_TEXT
148*ebfedea0SLionel Sambuc
149*ebfedea0SLionel SambucTo get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
150*ebfedea0SLionel Sambuc		[$4])
151*ebfedea0SLionel Sambucelse
152*ebfedea0SLionel Sambuc	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
153*ebfedea0SLionel Sambuc	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
154*ebfedea0SLionel Sambuc        AC_MSG_RESULT([yes])
155*ebfedea0SLionel Sambuc	ifelse([$3], , :, [$3])
156*ebfedea0SLionel Sambucfi[]dnl
157*ebfedea0SLionel Sambuc])# PKG_CHECK_MODULES
158