diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2007-03-30 14:08:27 (GMT) |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2007-03-30 14:08:27 (GMT) |
commit | a6b538664e7ab3d3ee5f26e3c48d444df91daa35 (patch) | |
tree | 10d5ef6f1ff037bfb7249cffea5204d2d7c90007 /m4/np_mysqlclient.m4 | |
parent | 950f99c62a942f665bde95b9d606279ffa7804d7 (diff) | |
download | monitoring-plugins-a6b538664e7ab3d3ee5f26e3c48d444df91daa35.tar.gz |
Fix AC_CHECK_LIB for mysql_init - add dependent libraries. mysql detection
separated into external m4 file
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1661 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'm4/np_mysqlclient.m4')
-rw-r--r-- | m4/np_mysqlclient.m4 | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/m4/np_mysqlclient.m4 b/m4/np_mysqlclient.m4 new file mode 100644 index 0000000..6bd51b8 --- /dev/null +++ b/m4/np_mysqlclient.m4 | |||
@@ -0,0 +1,71 @@ | |||
1 | # np_mysqlclient.m4 | ||
2 | dnl Copyright (C) 2007 Nagios Plugins Team | ||
3 | dnl This file is free software; the Nagios Plugin Team | ||
4 | dnl gives unlimited permission to copy and/or distribute it, | ||
5 | dnl with or without modifications, as long as this notice is preserved. | ||
6 | |||
7 | dnl Test for mysql availability using mysql_config | ||
8 | dnl Uses --with-mysql= yes(autodetection - default) | no | path | ||
9 | dnl Sets 4 variables: | ||
10 | dnl with_mysql = path/to/mysql_config (if found and can compile mysqlclient) or "no" | ||
11 | dnl np_mysql_include = flags for include, from mysql_config --include (will be guessed as $with_mysql/include if --include not found) | ||
12 | dnl np_mysql_libs = flags for libs, from mysql_config --libs | ||
13 | dnl np_mysql_cflags = flags for cflags, from mysql_config --cflags | ||
14 | dnl Also sets in config.h: | ||
15 | dnl HAVE_MYSQLCLIENT | ||
16 | dnl Copile your code with: | ||
17 | dnl $(CC) $(np_mysql_include) code.c $(np_mysql_libs) | ||
18 | |||
19 | AC_DEFUN([np_mysqlclient], | ||
20 | [ | ||
21 | AC_ARG_WITH(mysql, | ||
22 | ACX_HELP_STRING([--with-mysql=DIR], | ||
23 | [Locates mysql libraries. Expects DIR/bin/mysql_config. Default to search for mysql_config in PATH]), | ||
24 | with_mysql=$withval, | ||
25 | with_mysql=yes) | ||
26 | |||
27 | if test "x$with_mysql" != "xno" ; then | ||
28 | if test "x$with_mysql" = "xyes" ; then | ||
29 | AC_PATH_PROG(np_mysql_config, mysql_config) | ||
30 | else | ||
31 | if test -x $with_mysql/bin/mysql_config ; then | ||
32 | np_mysql_config="$with_mysql/bin/mysql_config" | ||
33 | fi | ||
34 | fi | ||
35 | if test -z "$np_mysql_config"; then | ||
36 | with_mysql="no" | ||
37 | else | ||
38 | np_mysql_include="`$np_mysql_config --include`" | ||
39 | # Mysql 3 does not support --include. --cflags should be sufficient | ||
40 | if test $? -ne 0; then | ||
41 | np_mysql_include="-I$with_mysql/include" # Guessed location | ||
42 | fi | ||
43 | np_mysql_libs="`$np_mysql_config --libs`" | ||
44 | np_mysql_cflags="`$np_mysql_config --cflags`" | ||
45 | |||
46 | dnl Test a mysql_init. Some systems have mysql_config, but no headers | ||
47 | _savedcppflags="$CPPFLAGS" | ||
48 | CPPFLAGS="$CPPFLAGS $np_mysql_include" | ||
49 | |||
50 | dnl Putting $np_mysql_libs as other libraries ensures that all mysql dependencies are linked in | ||
51 | dnl Although -lmysqlclient is duplicated, it is not a problem | ||
52 | AC_CHECK_LIB([mysqlclient], [mysql_init], [ | ||
53 | with_mysql=$np_mysql_config | ||
54 | AC_DEFINE(HAVE_MYSQLCLIENT, 1, [Defined if mysqlclient is found and can compile]) | ||
55 | ], [with_mysql=no], [$np_mysql_libs]) | ||
56 | CPPFLAGS=$_savedcppflags | ||
57 | |||
58 | fi | ||
59 | fi | ||
60 | ]) | ||
61 | |||
62 | dnl Will take $1, find last occurrance of -LDIR and add DIR to LD_RUN_PATH | ||
63 | AC_DEFUN([np_add_to_runpath], | ||
64 | [ | ||
65 | dnl Need [[ ]] so autoconf gives us just one set | ||
66 | np_libdir=`echo "$1" | sed -e 's/.*-L\([[^ ]]*\) .*/\1/'` | ||
67 | if test "x$np_libdir" != x ; then | ||
68 | LD_RUN_PATH="${np_libdir}${LD_RUN_PATH:+:}${LD_RUN_PATH}" | ||
69 | fi | ||
70 | ]) | ||
71 | |||