Code

mysql detection cleanup: fixes runtime linking, autodetection of main
authorTon Voon <tonvoon@users.sourceforge.net>
Fri, 17 Mar 2006 14:07:34 +0000 (14:07 +0000)
committerTon Voon <tonvoon@users.sourceforge.net>
Fri, 17 Mar 2006 14:07:34 +0000 (14:07 +0000)
locations, detection of lib64 and different layouts

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1327 f882894a-f735-0410-b71e-b25c423dba1c

REQUIREMENTS
configure.in
plugins/Makefile.am
plugins/check_mysql.c
plugins/check_mysql_query.c
plugins/t/check_mysql.t

index 12552df4ac15add8b220701300ccae3f25fa7957..f16de93682e9c1f03beacaad00f527f219d09d90 100644 (file)
@@ -40,11 +40,6 @@ check_mysql, check_mysql_query:
                Redhat Powertools Source: mysql-3.20.32a-3.i386.rpm, mysql-devel-3.20.32a-3.i386.rpm (these seem to be broken, however)
                RPMS from www.mysql.org work better
 
-         If you use the Mac OS X package from mysql.org, you need to add two soft links for ./configure
-         to find the mysql libraries correctly:
-               cd /usr/local/mysql/lib && ln -s . mysql
-               cd /usr/local/mysql/include && ln -s . mysql
-
 check_pqsql:
        - Requires the PostgreSQL libraries available from
          http://www.postgresql.org
index d1ef95439945b4b2c06a1077bff630ba335f8092..e02dc8955ed2c26908fecdb2b9f0085f8e6fcc1d 100644 (file)
@@ -253,49 +253,72 @@ else
 fi
 LIBS="$_SAVEDLIBS"
 
-
 dnl Check for mysql libraries
 _SAVEDLIBS="$LIBS"
 _SAVEDCPPFLAGS="$CPPFLAGS"
+FOUNDMYSQL="no"
 AC_ARG_WITH(mysql,
        ACX_HELP_STRING([--with-mysql=DIR],
-               [sets path to mysql installation (assumes lib/mysql and include subdirs]),
+               [sets path to mysql installation (assumes lib/lib64 and include subdirs)]),
        MYSQL=$withval,)
+# Find the mysql client libs
 if test -n "$MYSQL"; then
+  MYSQLLIBDIR=$MYSQL/lib
+  MYSQLLIB64DIR=$MYSQL/lib64
+elif test -f /usr/lib/libmysqlclient.so -o -f /usr/lib/libmysqlclient.a ; then
+  MYSQL="/usr"
+  MYSQLLIBDIR=$MYSQL/lib
+  MYSQLLIB64DIR=$MYSQL/lib64
+elif test -f /usr/lib/mysql/libmysqlclient.so -o -f /usr/lib/mysql/libmysqlclient.a ; then
+  MYSQL="/usr"
   MYSQLLIBDIR=$MYSQL/lib/mysql
-  CPPFLAGS="-I$MYSQL/include"
-  AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR " check_mysql_query_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz)
-  AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
-elif test -f /usr/lib/libmysqlclient.so; then
-  AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
-  AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
-elif test -f /usr/lib/libmysqlclient.a; then
+  MYSQLLIB64DIR=$MYSQL/lib64/mysql
+elif test -f /usr/local/lib/libmysqlclient.so -o -f /usr/local/lib/libmysqlclient.a ; then
+  MYSQL="/usr/local"
+  MYSQLLIBDIR=$MYSQL/lib
+  MYSQLLIB64DIR=$MYSQL/lib64
+elif test -f /usr/local/lib/mysql/libmysqlclient.so -o -f /usr/local/lib/mysql/libmysqlclient.a ; then
+  MYSQL="/usr/local"
+  MYSQLLIBDIR=$MYSQL/lib/mysql
+  MYSQLLIB64DIR=$MYSQL/lib64/mysql
+elif test -f /usr/local/mysql/lib/libmysqlclient.so -o -f /usr/local/mysql/lib/libmysqlclient.a ; then
+  MYSQL="/usr/local/mysql"
+  MYSQLLIBDIR=$MYSQL/lib
+  MYSQLLIB64DIR=$MYSQL/lib64
+fi
+
+# Check libs okay
+if test -n "$MYSQL" ; then
+  CPPFLAGS="-L$MYSQLLIBDIR -L$MYSQLLIB64DIR"
   AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz)
   AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient")
-elif test -f /usr/lib/mysql/libmysqlclient.so; then
-  AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
-  AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
-elif test -f /usr/lib/mysql/libmysqlclient.a; then
-  AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz)
-  AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql)
 fi
+
+# Check headers okay
 if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then
-  AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, MYSQLINCLUDE="-I$MYSQL/include" )
-  if test "$ac_cv_header_mysql_mysql_h" = "yes" -a "$ac_cv_header_mysql_errmsg_h" = "yes"; then
-    EXTRAS="$EXTRAS check_mysql check_mysql_query"
-    AC_SUBST(MYSQLINCLUDE)
-    AC_SUBST(MYSQLLIBS)
-    AC_SUBST(check_mysql_LDFLAGS)
-    AC_SUBST(check_mysql_query_LDFLAGS)
-  else
-    AC_MSG_WARN([Skipping mysql plugin])
-    AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).])
+  CPPFLAGS="-I$MYSQL/include"
+  AC_CHECK_HEADERS(mysql.h errmsg.h, FOUNDMYSQL="yes" MYSQLINCLUDE="-I$MYSQL/include")
+  if test x"$FOUNDMYSQL" != x"yes" ; then
+         AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, FOUNDMYSQL="yes" MYSQLINCLUDE="-I$MYSQL/include/mysql")
+  fi
+fi
+
+# Setup mysql plugins
+if test $FOUNDMYSQL = "yes" ; then
+  EXTRAS="$EXTRAS check_mysql check_mysql_query"
+  if test -d $MYSQLLIB64DIR ; then
+    MYSQLLIBS="-L$MYSQLLIB64DIR -rpath $MYSQLLIB64DIR $MYSQLLIBS"
+  fi
+  if test -d $MYSQLLIBDIR ; then
+    MYSQLLIBS="-L$MYSQLLIBDIR -rpath $MYSQLLIBDIR $MYSQLLIBS"
   fi
+  AC_SUBST(MYSQLINCLUDE)
+  AC_SUBST(MYSQLLIBS)
 else
   AC_MSG_WARN([Skipping mysql plugin])
   AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).])
 fi
-CPPFLAGS="$_SAVEDCPPFLAGS $MYSQLINCLUDE"
+CPPFLAGS="$_SAVEDCPPFLAGS"
 LIBS="$_SAVEDLIBS"
 
 AC_CHECK_HEADERS(unistd.h)
@@ -442,7 +465,7 @@ fi
 
 
 dnl openssl detection/configuration
-if ! test "$with_openssl" = "no"; then
+if ! test x"$with_openssl" = x"no"; then
        dnl Check for OpenSSL location if it wasn't already specified
        if ! test -d "$with_openssl"; then
                for d in $OPENSSL_DIRS; do
@@ -456,18 +479,20 @@ if ! test "$with_openssl" = "no"; then
        _SAVEDLDFLAGS="$LDFLAGS"
        dnl Check for OpenSSL header files
        unset FOUNDINCLUDE
-       CPPFLAGS="$CPPFLAGS -I$OPENSSL/include"
-       LDFLAGS="$LDFLAGS -R$OPENSSL/lib"
+       if test x"$with_openssl" != x"/usr" ; then
+               CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
+               LDFLAGS="$LDFLAGS -R$with_openssl/lib"
+       fi
 
        dnl check for openssl in $dir/include/openssl
        AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h,
-                        SSLINCLUDE="-I$OPENSSL/include"
+                        SSLINCLUDE="-I$with_openssl/include"
                         FOUNDINCLUDE=yes,
                         FOUNDINCLUDE=no)
        dnl else check to see if $dir/include has it
        if test "$FOUNDINCLUDE" = "no"; then
                AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h,
-                                SSLINCLUDE="-I$OPENSSL/include"
+                                SSLINCLUDE="-I$with_openssl/include"
                                 FOUNDINCLUDE=yes,
                                 FOUNDINCLUDE=no)
        fi
index 7f9d7456c47de4b27d15a6faf6ee6f486222eb17..9a1f6d09fbb7dd4b6b9d1e2ce90bfed762660697 100644 (file)
@@ -63,7 +63,9 @@ check_ldap_LDADD = $(NETLIBS) $(LDAPLIBS)
 check_load_LDADD = $(BASEOBJS) popen.o
 check_mrtg_LDADD = $(BASEOBJS)
 check_mrtgtraf_LDADD = $(BASEOBJS)
+check_mysql_CPPFLAGS = $(MYSQLINCLUDE)
 check_mysql_LDADD = $(NETLIBS) $(MYSQLLIBS)
+check_mysql_query_CPPFLAGS = $(MYSQLINCLUDE)
 check_mysql_query_LDADD = $(NETLIBS) $(MYSQLLIBS)
 check_nagios_LDADD = $(BASEOBJS) runcmd.o
 check_nt_LDADD = $(NETLIBS) 
index 92ac7ff00f3b8b3002ef9f5f5a94d5c96b2506a1..9d547ddd0fb7ee8ae30fa90d2184bb9ab0a6b51e 100644 (file)
@@ -25,8 +25,8 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
 #include "utils.h"
 #include "netutils.h"
 
-#include <mysql/mysql.h>
-#include <mysql/errmsg.h>
+#include <mysql.h>
+#include <errmsg.h>
 
 char *db_user = NULL;
 char *db_host = NULL;
index 321af7aaa3d3a4949eca5a3c1a0b515e6e0600de..b542fb4461995388913dfd5048ae69523ad7729e 100644 (file)
@@ -22,8 +22,8 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
 #include "utils.h"
 #include "netutils.h"
 
-#include <mysql/mysql.h>
-#include <mysql/errmsg.h>
+#include <mysql.h>
+#include <errmsg.h>
 
 char *db_user = NULL;
 char *db_host = NULL;
index 78413c6e88d63938b91ea87269df7898a352b2e1..852926a72f8b723ecf968ad388331d410771084d 100644 (file)
@@ -48,7 +48,7 @@ SKIP: {
        $result = NPTest->testCmd("./check_mysql -H $mysqlserver $mysql_login_details");
        cmp_ok( $result->return_code, '==', 0, "Login okay");
 
-       $result = NPTest->testCmd("./check_mysql -H $mysqlserver -u dummy");
+       $result = NPTest->testCmd("./check_mysql -H $mysqlserver -u dummy -pdummy");
        cmp_ok( $result->return_code, '==', 2, "Login failure");
        like( $result->output, $bad_login_output, "Expected login failure message");