Skip to content

Commit 1bf607a

Browse files
committed
Fix mysql configuration and linking
1 parent c286d30 commit 1bf607a

File tree

3 files changed

+150
-2
lines changed

3 files changed

+150
-2
lines changed

Makefile.am

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ LDFLAGS_ALL = $(DARKSTAR_LDFLAGS)
1414
CXX = g++ -std=gnu++0x
1515

1616
CFLAGS_ALL += $(LUA_CFLAGS)
17-
CFLAGS_ALL +=$(CFLAGS_MYSQL)
17+
CFLAGS_ALL += $(MYSQL_CFLAGS)
1818

1919
LIBS_ALL += $(LUA_LIBS)
20-
LIBS_ALL += $(LIBS_MYSQL) -lmysqlclient
20+
LIBS_ALL += $(MYSQL_LDFLAGS)
2121

2222
## Add Architecture-specific stuff
2323
if DARKSTAR_ARCH_LINUX

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ AC_SUBST(LUA_CFLAGS)
3232
AC_SUBST(LUA_LIBS)
3333

3434
### MySQL check
35+
m4_include([m4/ax_lib_mysql.m4])
3536
AX_LIB_MYSQL()
3637

3738
### Checks for typedefs, structures, and compiler characteristics.

m4/ax_lib_mysql.m4

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# ===========================================================================
2+
# http://www.gnu.org/software/autoconf-archive/ax_lib_mysql.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_LIB_MYSQL([MINIMUM-VERSION])
8+
#
9+
# DESCRIPTION
10+
#
11+
# This macro provides tests of availability of MySQL client library of
12+
# particular version or newer.
13+
#
14+
# AX_LIB_MYSQL macro takes only one argument which is optional. If there
15+
# is no required version passed, then macro does not run version test.
16+
#
17+
# The --with-mysql option takes one of three possible values:
18+
#
19+
# no - do not check for MySQL client library
20+
#
21+
# yes - do check for MySQL library in standard locations (mysql_config
22+
# should be in the PATH)
23+
#
24+
# path - complete path to mysql_config utility, use this option if
25+
# mysql_config can't be found in the PATH
26+
#
27+
# This macro calls:
28+
#
29+
# AC_SUBST(MYSQL_CFLAGS)
30+
# AC_SUBST(MYSQL_LDFLAGS)
31+
# AC_SUBST(MYSQL_VERSION)
32+
#
33+
# And sets:
34+
#
35+
# HAVE_MYSQL
36+
#
37+
# LICENSE
38+
#
39+
# Copyright (c) 2008 Mateusz Loskot <[email protected]>
40+
#
41+
# Copying and distribution of this file, with or without modification, are
42+
# permitted in any medium without royalty provided the copyright notice
43+
# and this notice are preserved. This file is offered as-is, without any
44+
# warranty.
45+
46+
#serial 12
47+
48+
AC_DEFUN([AX_LIB_MYSQL],
49+
[
50+
AC_ARG_WITH([mysql],
51+
AS_HELP_STRING([--with-mysql=@<:@ARG@:>@],
52+
[use MySQL client library @<:@default=yes@:>@, optionally specify path to mysql_config]
53+
),
54+
[
55+
if test "$withval" = "no"; then
56+
want_mysql="no"
57+
elif test "$withval" = "yes"; then
58+
want_mysql="yes"
59+
else
60+
want_mysql="yes"
61+
MYSQL_CONFIG="$withval"
62+
fi
63+
],
64+
[want_mysql="yes"]
65+
)
66+
AC_ARG_VAR([MYSQL_CONFIG], [Full path to mysql_config program])
67+
68+
MYSQL_CFLAGS=""
69+
MYSQL_LDFLAGS=""
70+
MYSQL_VERSION=""
71+
72+
dnl
73+
dnl Check MySQL libraries
74+
dnl
75+
76+
if test "$want_mysql" = "yes"; then
77+
78+
if test -z "$MYSQL_CONFIG" ; then
79+
AC_PATH_PROGS([MYSQL_CONFIG], [mysql_config mysql_config5], [no])
80+
fi
81+
82+
if test "$MYSQL_CONFIG" != "no"; then
83+
MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
84+
MYSQL_LDFLAGS="`$MYSQL_CONFIG --libs`"
85+
86+
MYSQL_VERSION=`$MYSQL_CONFIG --version`
87+
88+
found_mysql="yes"
89+
else
90+
found_mysql="no"
91+
fi
92+
fi
93+
94+
dnl
95+
dnl Check if required version of MySQL is available
96+
dnl
97+
98+
99+
mysql_version_req=ifelse([$1], [], [], [$1])
100+
101+
if test "$found_mysql" = "yes" -a -n "$mysql_version_req"; then
102+
103+
AC_MSG_CHECKING([if MySQL version is >= $mysql_version_req])
104+
105+
dnl Decompose required version string of MySQL
106+
dnl and calculate its number representation
107+
mysql_version_req_major=`expr $mysql_version_req : '\([[0-9]]*\)'`
108+
mysql_version_req_minor=`expr $mysql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
109+
mysql_version_req_micro=`expr $mysql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
110+
if test "x$mysql_version_req_micro" = "x"; then
111+
mysql_version_req_micro="0"
112+
fi
113+
114+
mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
115+
\+ $mysql_version_req_minor \* 1000 \
116+
\+ $mysql_version_req_micro`
117+
118+
dnl Decompose version string of installed MySQL
119+
dnl and calculate its number representation
120+
mysql_version_major=`expr $MYSQL_VERSION : '\([[0-9]]*\)'`
121+
mysql_version_minor=`expr $MYSQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
122+
mysql_version_micro=`expr $MYSQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
123+
if test "x$mysql_version_micro" = "x"; then
124+
mysql_version_micro="0"
125+
fi
126+
127+
mysql_version_number=`expr $mysql_version_major \* 1000000 \
128+
\+ $mysql_version_minor \* 1000 \
129+
\+ $mysql_version_micro`
130+
131+
mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
132+
if test "$mysql_version_check" = "1"; then
133+
AC_MSG_RESULT([yes])
134+
else
135+
AC_MSG_RESULT([no])
136+
fi
137+
fi
138+
139+
if test "$found_mysql" = "yes" ; then
140+
AC_DEFINE([HAVE_MYSQL], [1],
141+
[Define to 1 if MySQL libraries are available])
142+
fi
143+
144+
AC_SUBST([MYSQL_VERSION])
145+
AC_SUBST([MYSQL_CFLAGS])
146+
AC_SUBST([MYSQL_LDFLAGS])
147+
])

0 commit comments

Comments
 (0)