root / firmware / fx2 / config / pkg.m4 @ 70eae1d2
History | View | Annotate | Download (6.4 kB)
| 1 |
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- |
|---|---|
| 2 |
# |
| 3 |
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. |
| 4 |
# Copyright © 2008 Free Software Foundation, Inc. |
| 5 |
# |
| 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. |
| 10 |
# |
| 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. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License |
| 17 |
# along with this program; if not, write to the Free Software |
| 18 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 |
# |
| 20 |
# As a special exception to the GNU General Public License, if you |
| 21 |
# distribute this file as part of a program that contains a |
| 22 |
# configuration script generated by Autoconf, you may include it under |
| 23 |
# the same distribution terms that you use for the rest of that program. |
| 24 |
|
| 25 |
# PKG_PROG_PKG_CONFIG([MIN-VERSION]) |
| 26 |
# ---------------------------------- |
| 27 |
AC_DEFUN([PKG_PROG_PKG_CONFIG], |
| 28 |
[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) |
| 29 |
m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) |
| 30 |
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl |
| 31 |
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then |
| 32 |
AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) |
| 33 |
fi |
| 34 |
if test -n "$PKG_CONFIG"; then |
| 35 |
_pkg_min_version=m4_default([$1], [0.18]) |
| 36 |
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) |
| 37 |
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then |
| 38 |
AC_MSG_RESULT([yes]) |
| 39 |
else |
| 40 |
AC_MSG_RESULT([no]) |
| 41 |
PKG_CONFIG="" |
| 42 |
fi |
| 43 |
|
| 44 |
fi[]dnl |
| 45 |
])# PKG_PROG_PKG_CONFIG |
| 46 |
|
| 47 |
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
| 48 |
# |
| 49 |
# Check to see whether a particular set of modules exists. Similar |
| 50 |
# to PKG_CHECK_MODULES(), but does not set variables or print errors. |
| 51 |
# |
| 52 |
# |
| 53 |
# Similar to PKG_CHECK_MODULES, make sure that the first instance of |
| 54 |
# this or PKG_CHECK_MODULES is called, or make sure to call |
| 55 |
# PKG_CHECK_EXISTS manually |
| 56 |
# -------------------------------------------------------------- |
| 57 |
AC_DEFUN([PKG_CHECK_EXISTS], |
| 58 |
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl |
| 59 |
if test -n "$PKG_CONFIG" && \ |
| 60 |
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then |
| 61 |
m4_ifval([$2], [$2], [:]) |
| 62 |
m4_ifvaln([$3], [else |
| 63 |
$3])dnl |
| 64 |
fi]) |
| 65 |
|
| 66 |
|
| 67 |
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) |
| 68 |
# --------------------------------------------- |
| 69 |
m4_define([_PKG_CONFIG], |
| 70 |
[if test -n "$PKG_CONFIG"; then |
| 71 |
if test -n "$$1"; then |
| 72 |
pkg_cv_[]$1="$$1" |
| 73 |
else |
| 74 |
PKG_CHECK_EXISTS([$3], |
| 75 |
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], |
| 76 |
[pkg_failed=yes]) |
| 77 |
fi |
| 78 |
else |
| 79 |
pkg_failed=untried |
| 80 |
fi[]dnl |
| 81 |
])# _PKG_CONFIG |
| 82 |
|
| 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 |
| 93 |
|
| 94 |
|
| 95 |
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], |
| 96 |
# [ACTION-IF-NOT-FOUND]) |
| 97 |
# |
| 98 |
# E.g., |
| 99 |
# PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not) |
| 100 |
# defines: |
| 101 |
# |
| 102 |
# GSTUFF_LIBS |
| 103 |
# GSTUFF_CFLAGS |
| 104 |
# GSTUFF_INCLUDEDIR |
| 105 |
# GSTUFF_CPPFLAGS # the -I, -D and -U's out of CFLAGS |
| 106 |
# |
| 107 |
# see pkg-config man page also defines GSTUFF_PKG_ERRORS on error |
| 108 |
# |
| 109 |
# Note that if there is a possibility the first call to |
| 110 |
# PKG_CHECK_MODULES might not happen, you should be sure to include an |
| 111 |
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac |
| 112 |
# |
| 113 |
# -------------------------------------------------------------- |
| 114 |
AC_DEFUN([PKG_CHECK_MODULES],[ |
| 115 |
AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl |
| 116 |
AC_REQUIRE([AC_CANONICAL_HOST])dnl |
| 117 |
AC_REQUIRE([AC_CANONICAL_BUILD])dnl |
| 118 |
|
| 119 |
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl |
| 120 |
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl |
| 121 |
AC_ARG_VAR([$1][_INCLUDEDIR], [includedir for $1, overriding pkg-config])dnl |
| 122 |
|
| 123 |
pkg_failed=no |
| 124 |
AC_MSG_CHECKING([for $1]) |
| 125 |
|
| 126 |
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) |
| 127 |
|
| 128 |
if test x$cross_compiling = xyes |
| 129 |
then |
| 130 |
dnl _PKG_CONFIG([$1][_LIBS], [libs-only-l --static], [$2]) |
| 131 |
_PKG_CONFIG([$1][_LIBS], [libs --static], [$2]) |
| 132 |
dnl prune out any -L/lib or -L/usr/lib since they're pointing to the wrong filesystem root |
| 133 |
_pkg_tmp= |
| 134 |
for flag in [$]pkg_cv_[$1][_LIBS]; do |
| 135 |
case $flag in |
| 136 |
(-L/lib* | -L/usr/lib* ) ;; # ignore |
| 137 |
(*) _pkg_tmp="$_pkg_tmp $flag" ;; |
| 138 |
esac |
| 139 |
done |
| 140 |
pkg_cv_[$1][_LIBS]="$_pkg_tmp" |
| 141 |
else |
| 142 |
_PKG_CONFIG([$1][_LIBS], [libs --static], [$2]) |
| 143 |
fi |
| 144 |
|
| 145 |
_PKG_CONFIG([$1][_INCLUDEDIR], [variable=includedir], [$2]) |
| 146 |
|
| 147 |
|
| 148 |
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS |
| 149 |
and $1[]_LIBS to avoid the need to call pkg-config. |
| 150 |
See the pkg-config man page for more details.]) |
| 151 |
|
| 152 |
if test $pkg_failed = yes; then |
| 153 |
_PKG_SHORT_ERRORS_SUPPORTED |
| 154 |
if test $_pkg_short_errors_supported = yes; then |
| 155 |
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` |
| 156 |
else |
| 157 |
$1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` |
| 158 |
fi |
| 159 |
# Put the nasty error message in config.log where it belongs |
| 160 |
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD |
| 161 |
|
| 162 |
ifelse([$4], , [AC_MSG_ERROR(dnl |
| 163 |
[Package requirements ($2) were not met: |
| 164 |
|
| 165 |
$$1_PKG_ERRORS |
| 166 |
|
| 167 |
Consider adjusting the PKG_CONFIG_PATH environment variable if you |
| 168 |
installed software in a non-standard prefix. |
| 169 |
|
| 170 |
_PKG_TEXT |
| 171 |
])], |
| 172 |
[AC_MSG_RESULT([no]) |
| 173 |
$4]) |
| 174 |
elif test $pkg_failed = untried; then |
| 175 |
ifelse([$4], , [AC_MSG_FAILURE(dnl |
| 176 |
[The pkg-config script could not be found or is too old. Make sure it |
| 177 |
is in your PATH or set the PKG_CONFIG environment variable to the full |
| 178 |
path to pkg-config. |
| 179 |
|
| 180 |
_PKG_TEXT |
| 181 |
|
| 182 |
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])], |
| 183 |
[$4]) |
| 184 |
else |
| 185 |
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS |
| 186 |
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS |
| 187 |
$1[]_INCLUDEDIR=$pkg_cv_[]$1[]_INCLUDEDIR |
| 188 |
|
| 189 |
$1[]_CPPFLAGS="" |
| 190 |
for flag in $$1[]_CFLAGS; do |
| 191 |
case $flag in |
| 192 |
-I* | -D* | -U*) $1[]_CPPFLAGS="$$1[]_CPPFLAGS $flag" ;; |
| 193 |
esac |
| 194 |
done |
| 195 |
pkg_cv_[]$1[]_CPPFLAGS=$$1[]_CPPFLAGS |
| 196 |
AC_SUBST($1[]_CPPFLAGS) |
| 197 |
|
| 198 |
AC_MSG_RESULT([yes]) |
| 199 |
ifelse([$3], , :, [$3]) |
| 200 |
fi[]dnl |
| 201 |
])# PKG_CHECK_MODULES |