Code

fix libwrap and libdbi detection logic
[rrdtool-all.git] / contrib / php4 / config.m4
1 dnl $Id$
2 dnl config.m4 for extension rrdtool
4 dnl Comments in this file start with the string 'dnl'.
5 dnl Remove where necessary. This file will not work
6 dnl without editing.
8 dnl
9 dnl Checks for the configure options
10 dnl
12 PHP_ARG_WITH(rrdtool, for rrdtool support,
13 [  --with-rrdtool[=DIR]       Include rrdtool support (requires rrdtool >= 1.0.49).])
15 if test "$PHP_RRDTOOL" != "no"; then
17   if test "$PHP_RRDTOOL" != "yes"; then
18   AC_MSG_CHECKING(if rrdtool specified path is valid)
19     if test -r $PHP_RRDTOOL/include/rrd.h && test -f $PHP_RRDTOOL/lib/librrd.$SHLIB_SUFFIX_NAME -o -f $PHP_RRDTOOL/lib/librrd.a; then # path given as parameter
20       RRDTOOL_DIR=$PHP_RRDTOOL
21       RRDTOOL_INCDIR=$PHP_RRDTOOL/include
22       RRDTOOL_LIBDIR=$PHP_RRDTOOL/lib
23     AC_MSG_RESULT([yes])
24     else
25     AC_MSG_RESULT([no])
26       AC_MSG_ERROR([The specified RRDTool path is Invalid or the installation is incomplete
27       Please specify another path or reinstall the rrdtool distribution])
28     fi
29   else
30     dnl Header path
31     AC_MSG_CHECKING([for rrdtool header files in default path])
32     for i in /usr/local/rrdtool /usr/local /usr /opt ""; do
33      test -r $i/include/rrd.h && RRDTOOL_DIR=$i && RRDTOOL_INCDIR=$i/include
34     done
35     if test -z "$RRDTOOL_INCDIR"; then
36       AC_MSG_RESULT([not found])
37       AC_MSG_ERROR([Please reinstall the rrdtool distribution])
38     else
39      AC_MSG_RESULT(found in $RRDTOOL_INCDIR)
40     fi
41     dnl Library path
42     AC_MSG_CHECKING([for rrdtool library files in default path])
43     for i in librrd.$SHLIB_SUFFIX_NAME librrd.a; do
44       test -f $RRDTOOL_DIR/lib/$i && RRDTOOL_LIBDIR=$RRDTOOL_DIR/lib
45     done
46     if test -z "$RRDTOOL_LIBDIR"; then
47       AC_MSG_RESULT([not found])
48       AC_MSG_ERROR([Please reinstall the rrdtool distribution])
49     else
50      AC_MSG_RESULT(found in $RRDTOOL_LIBDIR)
51     fi
52   fi
54 dnl Finish the setup
56   RRD_H_PATH="$RRDTOOL_INCDIR/rrd.h"
57   PHP_RRDTOOL_DIR=$RRDTOOL_DIR
58   PHP_ADD_INCLUDE($RRDTOOL_INCDIR)
60   PHP_CHECK_LIBRARY(rrd, rrd_create,
61   [],[
62     PHP_CHECK_LIBRARY(rrd, rrd_create,
63     [],[
64       AC_MSG_ERROR([wrong rrd lib version or lib not found])
65     ],[
66       -L$RRDTOOL_LIBDIR -ldl
67     ])
68   ],[
69     -L$RRDTOOL_LIBDIR -ldl
70   ])
72  AC_MSG_CHECKING([rrdtool version])
73   AC_TRY_COMPILE([
74 #include <$RRD_H_PATH>
75   ], [int main() {
76     double some_variable;
77     some_variable = rrd_version();
78     }
79   ], [
80     AC_MSG_RESULT([1.2.x])
81     ac_cv_rrdversion=yes
82     ], [
83     AC_MSG_RESULT([1.0.x])
84     ac_cv_rrdversion=no
85     ])
87   if test "$ac_cv_rrdversion" = yes; then
88     AC_DEFINE(HAVE_RRD_12X, 1, [Whether you have rrd_verion])
89   fi 
91   PHP_ADD_LIBRARY_WITH_PATH(rrd, $RRDTOOL_LIBDIR, RRDTOOL_SHARED_LIBADD)
93   PHP_NEW_EXTENSION(rrdtool, rrdtool.c, $ext_shared)
94   PHP_SUBST(RRDTOOL_SHARED_LIBADD)
95   AC_DEFINE(HAVE_RRDTOOL, 1, [ ])
96 fi