diff options
Diffstat (limited to 'm4/mysql.m4')
-rw-r--r-- | m4/mysql.m4 | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/m4/mysql.m4 b/m4/mysql.m4 new file mode 100644 index 0000000..c4c4a3b --- /dev/null +++ b/m4/mysql.m4 | |||
@@ -0,0 +1,64 @@ | |||
1 | dnl CHECK_PATH_MYSQL([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUNT]]) | ||
2 | dnl Check for MySQL Libs | ||
3 | dnl | ||
4 | AC_DEFUN(CHECK_PATH_MYSQL, | ||
5 | [dnl | ||
6 | AC_ARG_WITH( | ||
7 | mysql, | ||
8 | [AC_HELP_STRING([--with-mysql],[Path to MySQL client library])], | ||
9 | mysql_prefix="$withval", | ||
10 | |||
11 | ) | ||
12 | AC_ARG_ENABLE( | ||
13 | mysqltest, | ||
14 | [AC_HELP_STRING([--disble-mysqltest],[Do not try to compile and run mysql test program])], | ||
15 | , | ||
16 | enable_apachetest=yes) | ||
17 | |||
18 | AC_REQUIRE([AC_CANONICAL_TARGET]) | ||
19 | ac_save_CFLAGS=$CFLAGS | ||
20 | ac_save_LDFLAGS=$LDFLAGS | ||
21 | if test "x$mysql_prefix" != "x" && test "x$mysql_prefix" != "xyes"; then | ||
22 | MYSQL_LDFLAGS="-L${mysql_prefix}/lib -L${mysql_prefix}/lib/mysql -L${mysql_prefix}/mysql/lib" | ||
23 | MYSQL_CFLAGS="-I${mysql_prefix}/include -I${mysql_prefix}/include/mysql -I${mysql_prefix}/mysql/include" | ||
24 | else | ||
25 | MYSQL_LDFLAGS="-L/usr/local/mysql/lib -L/usr/lib/mysql -L/usr/mysql/lib -L/usr/local/lib/mysql -L/usr/local/mysql/lib/mysql -L/usr/mysql/lib/mysql" | ||
26 | MYSQL_CFLAGS="-I/usr/local/mysql/include -I/usr/include/mysql -I/usr/mysql/include -I/usr/local/include/mysql -I/usr/local/mysql/include/mysql -I/usr/mysql/include/mysql" | ||
27 | fi | ||
28 | CFLAGS="$CFLAGS $MYSQL_CFLAGS" | ||
29 | LDFLAGS="$LDFLAGS $MYSQL_LDFLAGS" | ||
30 | AC_CHECK_LIB(m, floor) | ||
31 | AC_CHECK_LIB(z, gzclose) | ||
32 | with_mysql="yes" | ||
33 | AC_DEFINE(WITH_MYSQL,,[with mysql]) | ||
34 | AC_CHECK_LIB(mysqlclient, mysql_init, , | ||
35 | [AC_MSG_ERROR(libmysqlclient is needed for MySQL support)]) | ||
36 | MYSQL_LIBS=$LIBS | ||
37 | AC_CHECK_FUNCS(mysql_real_escape_string) | ||
38 | AC_MSG_CHECKING(whether mysql clients can run) | ||
39 | AC_TRY_RUN([ | ||
40 | #include <stdio.h> | ||
41 | #include <mysql.h> | ||
42 | int main(void) | ||
43 | { | ||
44 | MYSQL *a = mysql_init(NULL); | ||
45 | return 0; | ||
46 | } | ||
47 | ], , no_mysql=yes,[echo $ac_n "cross compiling; assumed OK.... $ac_c"]) | ||
48 | CFLAGS=$ac_save_CFLAGS | ||
49 | LDFLAGS=$ac_save_LDFLAGS | ||
50 | if test "x$no_mysql" = x; then | ||
51 | AC_MSG_RESULT(yes) | ||
52 | ifelse([$1], , :, [$1]) | ||
53 | else | ||
54 | AC_MSG_RESULT(no) | ||
55 | echo "*** MySQL could not be found ***" | ||
56 | MYSQL_CFLAGS="" | ||
57 | MYSQL_LDFLAGS="" | ||
58 | MYSQL_LIBS="" | ||
59 | ifelse([$2], , :, [$2]) | ||
60 | fi | ||
61 | AC_SUBST(MYSQL_LDFLAGS) | ||
62 | AC_SUBST(MYSQL_CFLAGS) | ||
63 | AC_SUBST(MYSQL_LIBS) | ||
64 | ]) | ||