source: npl/mailserver/dspam/dspam-3.10.2/m4/mysql_drv.m4 @ c5c522c

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 6.9 KB
Line 
1# $Id: mysql_drv.m4,v 1.7 2011/07/16 15:17:46 sbajic Exp $
2# Autoconf macros for checking for MySQL
3#
4#   Public available macro:
5#       DS_MYSQL([mysql_cppflags_out],
6#                [mysql_libs_out],
7#                [mysql_ldflags_out]
8#                [additional-action-if-found],
9#                [additional-action-if-not-found]
10#                )
11#
12#   Another macros are considered as private for implementation and
13#   sould not be used in the configure.ac.  At this time these are:
14#       DS_MYSQL_HEADERS()
15#       DS_MYSQL_LIBS()
16#
17
18#   DS_MYSQL_HEADERS([mysql_cppflags_out],
19#                  [additional-action-if-found],
20#                  [additional-action-if-not-found]
21#                 )
22AC_DEFUN([DS_MYSQL_HEADERS],
23[
24mysql_headers_save_CPPFLAGS="$CPPFLAGS"
25mysql_headers_CPPFLAGS=''
26mysql_headers_success=yes
27
28#
29#   virtual users
30#
31AC_ARG_ENABLE(virtual-users,
32    [AS_HELP_STRING([--enable-virtual-users],
33                    [Cause mysql_drv to generate virtual uids for each user])])
34AC_MSG_CHECKING([whether to enable virtual users])
35case x"$enable_virtual_users" in
36    xyes)   # enabled explicity
37            ;;
38    xno)    # disabled explicity
39            ;;
40    x)      # disabled by default
41            enable_virtual_users=no
42            ;;
43    *)      AC_MSG_ERROR([unexpected value $enable_virtual_users for --{enable,disable}-virtual-users configure option])
44            ;;
45esac
46if test x"$enable_virtual_users" != xyes
47then
48    enable_virtual_users=no
49else
50    enable_virtual_users=yes    # overkill, but convenient
51    AC_DEFINE(VIRTUAL_USERS, 1, [Defined if homedir dotfiles is enabled])
52fi
53AC_MSG_RESULT([$enable_virtual_users])
54
55
56AC_ARG_WITH(mysql-includes,
57    [AS_HELP_STRING([--with-mysql-includes=DIR],
58                    [Where to find Mysql headers])])
59AC_MSG_CHECKING([where to find MySQL headers])
60if test x"$with_mysql_includes" = x
61then
62    AC_MSG_RESULT([compiler default paths])
63else
64    AC_MSG_RESULT([$with_mysql_includes])
65    if test -d "$with_mysql_includes"
66    then
67        :
68    else
69        AC_MSG_ERROR([required include path for mysql headers $with_mysql_includes is not a directory])
70    fi
71    mysql_headers_CPPFLAGS="-I$with_mysql_includes"
72    CPPFLAGS="$mysql_headers_CPPFLAGS $CPPFLAGS"
73fi
74AC_CHECK_HEADERS([mysql.h mysqld_error.h errmsg.h],
75                [],
76                [ mysql_headers_success=no ])
77if test x"$mysql_headers_success" = xyes
78then
79    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
80    #include <mysql.h>
81    #include <mysqld_error.h>
82    #include <errmsg.h>
83    #if defined(PROTOCOL_VERSION) && defined(ER_LOCK_DEADLOCK) && defined(ER_LOCK_WAIT_TIMEOUT) && defined(ER_LOCK_OR_ACTIVE_TRANSACTION) && defined(CR_ERROR_FIRST)
84    /* Success */
85    #else
86    #error Unsupported version of MySQL
87    #endif
88            ]])],
89            [],
90            [
91                AC_MSG_FAILURE([Unsupported version of MySQL (no PROTOCOL_VERSION or ER_LOCK_DEADLOCK or ER_LOCK_WAIT_TIMEOUT or ER_LOCK_OR_ACTIVE_TRANSACTION or CR_ERROR_FIRST defined)])
92                mysql_headers_success=no
93            ])
94fi
95
96CPPFLAGS="$mysql_headers_save_CPPFLAGS"
97if test x"$mysql_headers_success" = xyes
98then
99    ifelse([$1], [], [:], [$1="$mysql_headers_CPPFLAGS"])
100    ifelse([$2], [], [:], [$2])
101else
102    ifelse([$3], [], [:], [$3])
103fi
104])
105
106#
107#   DS_MYSQL_LIBS([mysql_ldflags_out], [mysql_libs_out],
108#                  [additional-action-if-found],
109#                  [additional-action-if-not-found]
110#                 )
111AC_DEFUN([DS_MYSQL_LIBS],
112[
113mysql_libs_save_LDFLAGS="$LDFLAGS"
114mysql_libs_save_LIBS="$LIBS"
115mysql_libs_LDFLAGS=''
116mysql_libs_LIBS=''
117mysql_libs_success=no
118mysql_libs_netlibs=''
119
120success=yes
121                                                                               
122AC_SEARCH_LIBS([gzopen], [z], [success=yes], [success=no])
123if test x"$success" = xno
124then
125  AC_MSG_ERROR([zlib required for mysql_drv])
126fi
127
128AC_ARG_WITH(mysql-libraries,
129    [AS_HELP_STRING([--with-mysql-libraries=DIR],
130                    [Where to find MySQL])])
131AC_MSG_CHECKING([where to find MySQL libraries])
132if test x"$with_mysql_libraries" = x
133then
134    AC_MSG_RESULT([compiler default paths])
135else
136    AC_MSG_RESULT([$with_mysql_libraries])
137    if test -d "$with_mysql_libraries"
138    then
139        :
140    else
141        AC_MSG_ERROR([required path for mysql libraries ($with_mysql_libraries) is not a directory])
142    fi
143    mysql_libs_LDFLAGS="-L$with_mysql_libraries"
144fi
145
146DS_NETLIBS([mysql_libs_netlibs],
147           [mysql_libs_success=yes],
148           [mysql_libs_success=no])
149if test x"$mysql_libs_success" = xyes
150then
151    AC_MSG_CHECKING([for mysql_init in -lmysqlclient])
152    mysql_libs_LIBS="-lmysqlclient $mysql_libs_netlibs"
153    LIBS="$mysql_libs_LIBS $mysql_libs_save_LIBS"
154    LDFLAGS="$mysql_libs_LDFLAGS $mysql_libs_save_LDFLAGS"
155
156    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
157            #include <stdlib.h>
158            #include <mysql.h>
159        ]],
160        [[
161            MYSQL *mysql = mysql_init(NULL);
162            mysql_close(mysql);
163        ]])],
164        [ mysql_libs_success=yes ],
165        [ mysql_libs_success=no ]
166        )
167    AC_MSG_RESULT([$mysql_libs_success])
168
169    if test x"$mysql_libs_success" = xyes
170    then
171        AC_MSG_CHECKING([for MySQL client version >= 5.0.0])
172        AC_RUN_IFELSE([
173          AC_LANG_PROGRAM([[
174            #include <stdlib.h>
175            #include <string.h>
176            #include <mysql.h>
177          ]],[[
178            int is_ok = 0;
179            const char *info = mysql_get_client_info();
180            char *i = strdup(info);
181            char *m = strtok(i, ".");
182            if (m)
183              if (atoi(m) >= 5)
184                is_ok = 1;
185            free (i);
186            return is_ok ? 0 : 1;
187          ]])
188        ],[
189          AC_MSG_RESULT([yes])
190        ],[
191          AC_MSG_RESULT([no])
192          mysql_libs_success=no
193        ])
194    fi
195fi
196LIBS="$mysql_libs_save_LIBS"
197LDFLAGS="$mysql_libs_save_LDFLAGS"
198if test x"$mysql_libs_success" = xyes
199then
200    ifelse([$1], [], [:], [$1="$mysql_libs_LDFLAGS"])
201    ifelse([$2], [], [:], [$2="$mysql_libs_LIBS"])
202    ifelse([$3], [], [:], [$3])
203else
204    ifelse([$4], [], [:], [$4])
205fi
206])
207
208#
209#   DS_MYSQL([db_cppflags_out], [db_ldflags_out], [db_libs_out],
210#                  [additional-action-if-found],
211#                  [additional-action-if-not-found]
212#                 )
213AC_DEFUN([DS_MYSQL],
214[
215mysql_save_CPPFLAGS="$CPPFLAGS"
216mysql_save_LDFLAGS="$LDFLAGS"
217mysql_save_LIBS="$LIBS"
218
219mysql_CPPFLAGS=''
220mysql_LIBS=''
221
222mysql_success=yes
223
224DS_MYSQL_HEADERS([mysql_CPPFLAGS], [], [mysql_success=no])
225
226if test x"$mysql_success" = xyes
227then
228    CPPFLAGS="$mysql_CPPFLAGS $CPPFLAGS"
229    DS_MYSQL_LIBS([mysql_LDFLAGS], [mysql_LIBS], [], [mysql_success=no])
230fi
231
232CPPFLAGS="$mysql_save_CPPFLAGS"
233LDFLAGS="$mysql_save_LDFLAGS"
234LIBS="$mysql_save_LIBS"
235
236if test x"$mysql_success" = xyes
237then
238    ifelse([$1], [], [:], [$1="$mysql_CPPFLAGS"])
239    ifelse([$2], [], [:], [$2="$mysql_LDFLAGS"])
240    ifelse([$3], [], [:], [$3="$mysql_LIBS"])
241    ifelse([$4], [], [:], [$4])
242else
243    ifelse([$5], [], [:], [$5])
244fi
245])
Note: See TracBrowser for help on using the repository browser.