config.m4 - utilize pkg-config

see https://github.com/oetiker/rrdtool-1.x/issues/714


git-svn-id: http://svn.php.net/repository/pecl/rrd/trunk@339158 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Miroslav Kubelik
2016-05-09 17:49:41 +00:00
parent 6eb1874bb1
commit 0826a33f80

View File

@@ -2,7 +2,7 @@ dnl config.m4 for extension php_rrd
dnl Comments in this file start with the string 'dnl'.
PHP_ARG_WITH(rrd, for rrdtool support,
[ --with-rrd[=DIR] Include rrdtool support (requires rrdtool >= 1.3.x)])
[ --with-rrd Include rrdtool support (requires rrdtool >= 1.3.0)], yes)
AC_ARG_WITH(rrd-binary,
[AC_HELP_STRING([--with-rrd-binary][=PATH], [rrd binary dir path, mostly for testing (default=$PATH)])],
@@ -16,61 +16,32 @@ if test -f $srcdir/tests/rrdtool-bin.inc.in; then
fi
if test "$PHP_RRD" != "no"; then
if test "$PHP_RRD" != "yes"; then
AC_MSG_CHECKING(if rrdtool specified path is valid)
if test -r "$PHP_RRD/include/rrd.h"; then
RRDTOOL_INCDIR=$PHP_RRD/include
RRDTOOL_LIBDIR=$PHP_RRD/$PHP_LIBDIR
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([The specified RRDTool path is invalid or the installation is incomplete
Please specify another path or reinstall the rrdtool distribution])
fi
else
AC_MSG_CHECKING([for rrdtool header files in default paths])
for i in /usr /usr/local /usr/local/rrdtool /opt; do
test -r $i/include/rrd.h && RRDTOOL_LIBDIR=$i/$PHP_LIBDIR && RRDTOOL_INCDIR=$i/include
done
if test -z "$RRDTOOL_INCDIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please reinstall the rrdtool distribution])
else
AC_MSG_RESULT(found in $RRDTOOL_INCDIR)
fi
fi
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
AC_MSG_CHECKING(for librdd)
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists librrd && $PKG_CONFIG librrd --atleast-version 1.3.0; then
AC_MSG_RESULT(found)
LIBRRD_CFLAGS=`$PKG_CONFIG librrd --cflags`
LIBRRD_LDFLAGS=`$PKG_CONFIG librrd --libs`
dnl Finish the setup
PHP_ADD_INCLUDE($RRDTOOL_INCDIR)
PHP_CHECK_LIBRARY(rrd, rrd_create,
[
PHP_ADD_LIBRARY_WITH_PATH(rrd, $RRDTOOL_LIBDIR, RRD_SHARED_LIBADD)
PHP_EVAL_LIBLINE($LIBRRD_LDFLAGS, RRD_SHARED_LIBADD)
PHP_EVAL_INCLINE($LIBRRD_CFLAGS)
AC_DEFINE(HAVE_RRDTOOL, 1, [ ])
], [
AC_MSG_ERROR([wrong rrd lib version or lib not found])
], [
-L$RRDTOOL_LIBDIR
])
dnl save temporary LDFLAGS, necessary for PHP_CHECK_FUNC
old_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -L$RRDTOOL_LIBDIR"
dnl rrd_graph_v is available in 1.3.0+
PHP_CHECK_FUNC(rrd_graph_v, rrd)
if test "$ac_cv_func_rrd_graph_v" != yes; then
AC_MSG_ERROR([rrd lib version seems older than 1.3.0, update to 1.3.0+])
fi
else
AC_MSG_ERROR(pkgconfig and librrd in version >= 1.3.0 must be installed)
fi
dnl rrd_lastupdate_r available in 1.4.0+
PHP_CHECK_FUNC(rrd_lastupdate_r, rrd)
AC_CHECK_LIB([rrd], [rrd_lastupdate_r],
[
AC_DEFINE(HAVE_RRD_LASTUPDATE_R, 1, [ ])
], , [$LIBRRD_LDFLAGS])
dnl rrdc_disconnect available in 1.4.0+
PHP_CHECK_FUNC(rrdc_disconnect, rrd)
LDFLAGS=$old_LDFLAGS
AC_CHECK_LIB([rrd], [rrdc_disconnect],
[
AC_DEFINE(HAVE_RRDC_DISCONNECT, 1, [ ])
], , [$LIBRRD_LDFLAGS])
PHP_NEW_EXTENSION(rrd, rrd.c rrd_graph.c rrd_create.c rrd_update.c rrd_info.c, $ext_shared)
PHP_SUBST(RRD_SHARED_LIBADD)