aboutsummaryrefslogtreecommitdiff
path: root/m4/libmysqlclient.m4
blob: 84b447190700080e089d548ae97b45122d48d51c (plain)
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
98
99
100
101
102
103
104
105
106
107
dnl file      : m4/libmysqlclient.m4
dnl copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC
dnl license   : GNU GPL v2; see accompanying LICENSE file
dnl
dnl LIBMYSQLCLIENT(MULTI-THREADED=none|<other>,
dnl                [ACTION-IF-FOUND[,
dnl                ACTION-IF-NOT-FOUND]])
dnl
dnl
AC_DEFUN([LIBMYSQLCLIENT], [
libmysqlclient_found=no

if test x"$1" != xnone; then
  libmysqlclient_name=mysqlclient_r
else
  libmysqlclient_name=mysqlclient
fi

AC_MSG_CHECKING([for lib$libmysqlclient_name])

save_LIBS="$LIBS"
LIBS="-l$libmysqlclient_name $LIBS"

CXX_LIBTOOL_LINK_IFELSE(
AC_LANG_SOURCE([[
#ifdef _WIN32
#  include <winsock2.h>
#endif
#include <mysql/mysql.h>

int
main ()
{
  MYSQL handle;
  mysql_init (&handle);
  mysql_real_connect (&handle, 0, 0, 0, 0, 0, 0, 0);
  MYSQL_STMT* stmt = mysql_stmt_init (&handle);
  mysql_stmt_close (stmt);
  mysql_close (&handle);
}
]]),
[
libmysqlclient_found=yes
libmysqlclient_include=long
])

if test x"$libmysqlclient_found" = xno; then

CXX_LIBTOOL_LINK_IFELSE(
AC_LANG_SOURCE([[
#ifdef _WIN32
#  include <winsock2.h>
#endif
#include <mysql.h>

int
main ()
{
  MYSQL handle;
  mysql_init (&handle);
  mysql_real_connect (&handle, 0, 0, 0, 0, 0, 0, 0);
  MYSQL_STMT* stmt = mysql_stmt_init (&handle);
  mysql_stmt_close (stmt);
  mysql_close (&handle);
}
]]),
[
libmysqlclient_found=yes
libmysqlclient_include=short
])

fi

if test x"$libmysqlclient_found" = xno; then
  LIBS="$save_LIBS"
fi

if test x"$libmysqlclient_found" = xyes; then
  AC_MSG_RESULT([yes])
  $2
else
  AC_MSG_RESULT([no])
  $3
fi

# Check if the THR_KEY_mysys pthread key symbol is visible.
#
libmysqlclient_thr_key_visible=no

if test x"$libmysqlclient_found" = xyes -a x"$1" = xposix; then

CXX_LIBTOOL_LINK_IFELSE(
AC_LANG_SOURCE([[
#include <pthread.h>
extern pthread_key_t THR_KEY_mysys;
int
main ()
{
  return pthread_getspecific (THR_KEY_mysys) != 0;
}
]]),
[
libmysqlclient_thr_key_visible=yes
])
fi

])dnl