1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
From f850bea77c036e59a220a976ce3564fb2dd08a1e Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 15 Jan 2020 10:17:42 +0100
Subject: [PATCH] use pkg-config and allow build when cpp-driver use
CASS_INSTALL_HEADER_IN_SUBDIR
---
ext/config.m4 | 60 ++++++++++++++++++++++++++++++++++-----------------
1 file changed, 40 insertions(+), 20 deletions(-)
diff --git a/ext/config.m4 b/ext/config.m4
index d479d904..3c9abdc5 100644
--- a/ext/config.m4
+++ b/ext/config.m4
@@ -267,31 +267,51 @@ if test "$PHP_CASSANDRA" != "no"; then
PHP_ADD_LIBRARY(uv,, CASSANDRA_SHARED_LIBADD)
PHP_ADD_LIBRARY(m,, CASSANDRA_SHARED_LIBADD)
- if test "$PHP_CASSANDRA" != "yes"; then
- if test -f $PHP_CASSANDRA/include/cassandra.h; then
- CPP_DRIVER_DIR=$PHP_CASSANDRA
+ AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+
+ AC_MSG_CHECKING([for supported DataStax C/C++ driver version])
+ if test "$PHP_CASSANDRA" = "yes" -a -x $PKG_CONFIG; then
+ CPP_DRIVER_VERSION=`$PKG_CONFIG cassandra --modversion`
+ if $PKG_CONFIG cassandra --atleast-version 2.7.0; then
+ CPP_DRIVER_INCDIR=`$PKG_CONFIG cassandra --variable=includedir`
+ CPP_DRIVER_LIBDIR=`$PKG_CONFIG cassandra --variable=libdir`
+ AC_MSG_RESULT([supported ($CPP_DRIVER_VERSION from pkg-config)])
+ else
+ AC_MSG_ERROR([not supported. Driver version 2.7.0+ required (found $CPP_DRIVER_VERSION)])
fi
+
else
- for i in /usr/local /usr; do
- if test -f $i/include/cassandra.h; then
- CPP_DRIVER_DIR=$i
+ if test "$PHP_CASSANDRA" != "yes"; then
+ if test -f $PHP_CASSANDRA/include/cassandra.h; then
+ CPP_DRIVER_INCDIR=$PHP_CASSANDRA/include
+ CPP_DRIVER_LIBDIR=$PHP_CASSANDRA/$PHP_LIBDIR
fi
- done
- fi
+ if test -f $PHP_CASSANDRA/include/cassandra/cassandra.h; then
+ CPP_DRIVER_INCDIR=$PHP_CASSANDRA/include/cassandra
+ CPP_DRIVER_LIBDIR=$PHP_CASSANDRA/$PHP_LIBDIR
+ fi
+ else
+ for i in /usr/local /usr; do
+ if test -f $i/include/cassandra.h; then
+ CPP_DRIVER_INCDIR=$i/include
+ CPP_DRIVER_LIBDIR=$i/$PHP_LIBDIR
+ fi
+ done
+ fi
- AC_MSG_CHECKING([for supported DataStax C/C++ driver version])
- PHP_CASSANDRA_FOUND_CASSANDRA_VERSION=`$AWK '/CASS_VERSION_MAJOR/ {printf $3"."} /CASS_VERSION_MINOR/ {printf $3"."} /CASS_VERSION_PATCH/ {printf $3}' $CPP_DRIVER_DIR/include/cassandra.h`
- PHP_CASSANDRA_FOUND_CASSANDRA_VERSION_NUMBER=`echo "${PHP_CASSANDRA_FOUND_CASSANDRA_VERSION}" | $AWK 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 100 + [$]2) * 100 + [$]3;}'`
- if test "$PHP_CASSANDRA_FOUND_CASSANDRA_VERSION_NUMBER" -lt "20700"; then
- AC_MSG_ERROR([not supported. Driver version 2.7.0+ required (found $PHP_CASSANDRA_FOUND_CASSANDRA_VERSION)])
- else
- AC_MSG_RESULT([supported ($PHP_CASSANDRA_FOUND_CASSANDRA_VERSION)])
+ PHP_CASSANDRA_FOUND_CASSANDRA_VERSION=`$AWK '/CASS_VERSION_MAJOR/ {printf $3"."} /CASS_VERSION_MINOR/ {printf $3"."} /CASS_VERSION_PATCH/ {printf $3}' $CPP_DRIVER_INCDIR/cassandra.h`
+ PHP_CASSANDRA_FOUND_CASSANDRA_VERSION_NUMBER=`echo "${PHP_CASSANDRA_FOUND_CASSANDRA_VERSION}" | $AWK 'BEGIN { FS = "."; } { printf "%d", ([$]1 * 100 + [$]2) * 100 + [$]3;}'`
+ if test "$PHP_CASSANDRA_FOUND_CASSANDRA_VERSION_NUMBER" -lt "20700"; then
+ AC_MSG_ERROR([not supported. Driver version 2.7.0+ required (found $PHP_CASSANDRA_FOUND_CASSANDRA_VERSION)])
+ else
+ AC_MSG_RESULT([supported ($PHP_CASSANDRA_FOUND_CASSANDRA_VERSION)])
+ fi
fi
- if test -z "$CPP_DRIVER_DIR"; then
+ if test -z "$CPP_DRIVER_LIBDIR"; then
ac_extra=
else
- ac_extra=-L$CPP_DRIVER_DIR/$PHP_LIBDIR
+ ac_extra=-L$CPP_DRIVER_LIBDIR/$PHP_LIBDIR
fi
PHP_CHECK_LIBRARY(cassandra, cass_cluster_new,
@@ -306,9 +326,9 @@ if test "$PHP_CASSANDRA" != "no"; then
]
)
- if test -n "$CPP_DRIVER_DIR"; then
- PHP_ADD_LIBPATH($CPP_DRIVER_DIR/$PHP_LIBDIR, CASSANDRA_SHARED_LIBADD)
- PHP_ADD_INCLUDE($CPP_DRIVER_DIR/include)
+ if test -n "$CPP_DRIVER_INCDIR"; then
+ PHP_ADD_LIBPATH($CPP_DRIVER_LIBDIR, CASSANDRA_SHARED_LIBADD)
+ PHP_ADD_INCLUDE($CPP_DRIVER_INCDIR)
fi
PHP_ADD_LIBRARY(cassandra,, CASSANDRA_SHARED_LIBADD)
|