[collectd] [PATCH] configure, mysql plugin: Check for mysql.h as well.

Sebastian Harl sh at tokkee.org
Sat Nov 1 11:38:30 CET 2008


Up to now, only mysql/mysql.h has been checked for. However, mysql_config
--cflags usually adds the complete path to mysql.h to the include flags. In
most setups, mysql/mysql.h can be found in the search path as well (usually
the header is available in something like /usr/include/mysql/mysql.h) so this
issue has not been found so far. However, if that's not the case, the build
will fail.

Thanks to Dusty Doris <collectd at dusty.name> for reporting this.
---

This patch can also be found in the branch sh/collectd-4.4 in my
repository at git://git.tokkee.org/collectd.git.

---
 configure.in |   18 +++++++++++++++---
 src/mysql.c  |    4 +++-
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/configure.in b/configure.in
index bc4d321..6fd080a 100644
--- a/configure.in
+++ b/configure.in
@@ -1338,12 +1338,24 @@ then
 
 	if test $mysql_config_status -ne 0
 	then
-		with_libmysql="no"
+		with_libmysql="no ($with_mysql_config failed)"
 	else
 		SAVE_CPPFLAGS="$CPPFLAGS"
 		CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
 
-		AC_CHECK_HEADERS(mysql/mysql.h, [], [with_libmysql="no (mysql/mysql.h not found)"], [])
+		have_mysql_h="no"
+		have_mysql_mysql_h="no"
+		AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
+
+		if test "x$have_mysql_h" = "xno"
+		then
+			AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
+		fi
+
+		if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
+		then
+			with_libmysql="no (mysql.h not found)"
+		fi
 
 		CPPFLAGS="$SAVE_CPPFLAGS"
 	fi
@@ -1355,7 +1367,7 @@ then
 
 	if test $mysql_config_status -ne 0
 	then
-		with_libmysql="no"
+		with_libmysql="no ($with_mysql_config failed)"
 	else
 		AC_CHECK_LIB(mysqlclient, mysql_init,
 		 [with_libmysql="yes"],
diff --git a/src/mysql.c b/src/mysql.c
index aa585d6..30557f6 100644
--- a/src/mysql.c
+++ b/src/mysql.c
@@ -24,7 +24,9 @@
 #include "plugin.h"
 #include "configfile.h"
 
-#ifdef HAVE_MYSQL_MYSQL_H
+#ifdef HAVE_MYSQL_H
+#include <mysql.h>
+#elif defined(HAVE_MYSQL_MYSQL_H)
 #include <mysql/mysql.h>
 #endif
 
-- 
1.6.0.3.523.g304d0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20081101/572760eb/attachment.pgp 


More information about the collectd mailing list