forked from alibaba/TDH_Socket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
332 lines (278 loc) · 8.88 KB
/
configure.ac
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT([TDH_Socket_Plugin_for_MySQL], [0.5])
#init
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PREFIX_DEFAULT(/usr)
m4_pattern_allow([AM_PROG_AR])
AM_PROG_AR
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_LN_S
AC_PROG_LIBTOOL
AC_PROG_RANLIB
#FLAGS
PRESET_CFLAGS="$CFLAGS"
PRESET_CXXFLAGS="$CXXFLAGS"
PRESET_LDFLAGS="$LDFLAGS"
CFLAGS="$PRESET_CFLAGS -Wall -fPIC -D_GNU_SOURCE -fno-strict-aliasing"
CXXFLAGS="$PRESET_CXXFLAGS -D_GNU_SOURCE -D__STDC_LIMIT_MACROS"
CXXFLAGS="$CXXFLAGS -Wall -fno-rtti -fno-exceptions -fPIC -DPIC"
AC_CHECK_LIB([pthread], [main])
AC_CHECK_LIB([tcmalloc], [main])
EASY_INCLUDES="-I`pwd`/libeasy/include/ -I`pwd`/libeasy/memory -I`pwd`/libeasy/util/"
EASY_INCLUDES="$EASY_INCLUDES -I`pwd`/libeasy/thread/ -I`pwd`/libeasy/io/ -I`pwd`/libeasy/packet/ -I`pwd`/libeasy/packet/http -I."
AC_SUBST(EASY_INCLUDES)
#config
if test "$prefix" = "NONE"; then
prefix="/usr"
fi
ac_tdhs_debug=
AC_ARG_ENABLE(tdhs-debug,
[AS_HELP_STRING([--enable-tdhs-debug], [specify whether tdh_socket is build with DEBUG])],[ac_tdhs_debug="$enableval"],[ac_tdhs_debug=no])
AC_MSG_CHECKING([if --enable-tdhs-debug is specified])
AC_MSG_RESULT($ac_tdhs_debug)
if test "$ac_tdhs_debug" = "yes"; then
AC_DEFINE([TDHS_DEBUG], [1],
[tdh_socket is build with DEBUG])
fi
ac_tdhs_row_cache=
AC_ARG_ENABLE(tdhs-row-cache,
[AS_HELP_STRING([--enable-tdhs-row-cache], [specify whether tdh_socket is build with row_cache])],[ac_tdhs_row_cache="$enableval"],[ac_tdhs_row_cache=no])
AC_MSG_CHECKING([if --enable-tdhs-row-cache is specified])
AC_MSG_RESULT($ac_tdhs_row_cache)
if test "$ac_tdhs_row_cache" = "yes"; then
AC_DEFINE([TDHS_ROW_CACHE], [1],
[tdh_socket is build with row_cache])
fi
ac_mysql_debug=
AC_ARG_ENABLE(mysql-debug,
[AS_HELP_STRING([--enable-mysql-debug], [specify whether MySQL is build with DBUG_ON])],[ac_mysql_debug="$enableval"],[ac_mysql_debug=no])
AC_MSG_CHECKING([if --enable-mysql-debug is specified])
AC_MSG_RESULT($ac_mysql_debug)
AC_DEFUN([CONFIG_OPTION_MYSQL],[
AC_MSG_CHECKING([mysql source])
MYSQL_SOURCE_VERSION=
MYSQL_INC=
ac_mysql_source_dir=
AC_ARG_WITH([mysql-source],
[AS_HELP_STRING([--with-mysql-source=PATH], [MySQL source directory PATH])],
[
ac_mysql_source_dir=`cd $withval && pwd`
if test -f "$ac_mysql_source_dir/sql/handler.h" ; then
MYSQL_INC="-I$ac_mysql_source_dir/sql"
MYSQL_INC="$MYSQL_INC -I$ac_mysql_source_dir/include"
MYSQL_INC="$MYSQL_INC -I$ac_mysql_source_dir/regex"
MYSQL_INC="$MYSQL_INC -I$ac_mysql_source_dir"
AC_SUBST(MYSQL_INC)
if test -f "$ac_mysql_source_dir/VERSION"; then
source "$ac_mysql_source_dir/VERSION"
MYSQL_SOURCE_VERSION="$MYSQL_VERSION_MAJOR.$MYSQL_VERSION_MINOR.$MYSQL_VERSION_PATCH"
else
if test -f "$ac_mysql_source_dir/configure.in"; then
MYSQL_SOURCE_VERSION=`cat $ac_mysql_source_dir/configure.in | grep "\[[MySQL Server\]]" | sed -e "s|.*\([[0-9]]\+\.[[0-9]]\+\.[[0-9]]\+[[0-9a-zA-Z\_\-]]*\).*|\1|"`
else
AC_MSG_ERROR([invalid MySQL source directory: $ac_mysql_source_dir])
fi
fi
AC_MSG_RESULT([yes: Using $ac_mysql_source_dir, version $MYSQL_SOURCE_VERSION])
else
AC_MSG_ERROR([invalid MySQL source directory: $ac_mysql_source_dir])
fi
],
[AC_MSG_ERROR([--with-mysql-source=PATH is required for standalone build])]
)
MYSQL_BIN_VERSION=
ac_mysql_config=
AC_ARG_WITH([mysql-bindir],
[AS_HELP_STRING([--with-mysql-bindir=PATH], [MySQL binary directory PATH. This should be the directory where mysql_config is located.])],
[
mysql_bin_dir=`cd $withval 2> /dev/null && pwd || echo ""`
ac_mysql_config="$mysql_bin_dir/mysql_config"
],
[
AC_PATH_PROG([ac_mysql_config], [mysql_config])
]
)
AC_MSG_CHECKING([mysql binary])
if test ! -x "$ac_mysql_config" ; then
AC_MSG_ERROR([mysql_config not found! You have to specify the directory where mysql_config resides to --with-mysql-bindir=PATH.])
fi
MYSQL_CFLAGS_ADD=`"$ac_mysql_config" --cflags`
MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_CFLAGS_ADD"
if test "$ac_mysql_debug" = "yes"; then
MYSQL_CFLAGS="$MYSQL_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DENABLED_DEBUG_SYNC"
else
MYSQL_CFLAGS="$MYSQL_CFLAGS -DDBUG_OFF"
fi
AC_SUBST(MYSQL_CFLAGS)
MYSQL_BIN_VERSION=`"$ac_mysql_config" --version`
AC_MSG_RESULT([yes: Using $ac_mysql_config, version $MYSQL_BIN_VERSION])
MYSQL_LIB=`"$ac_mysql_config" --libs_r`
LIB_DIR=`echo $MYSQL_LIB | sed -e "s|.*-L/|/|" | sed -e "s| .*||"`
# FIXME
if test a`basename "$LIB_DIR"` = amysql ; then
MYSQL_LIB="-L`dirname $LIB_DIR` $MYSQL_LIB"
# FIXME
fi
AC_SUBST(MYSQL_LIB)
if test a$MYSQL_SOURCE_VERSION != a$MYSQL_BIN_VERSION ; then
AC_MSG_ERROR([MySQL source version does not match MySQL binary version])
fi
AC_MSG_CHECKING([mysql plugin dir])
ac_mysql_plugin_dir=
AC_ARG_WITH([mysql-plugindir],
[AS_HELP_STRING([--with-mysql-plugindir=PATH], [MySQL plugin directory where tdhsocket.so to be copied])],
[
ac_mysql_plugin_dir=`cd $withval && pwd`
if test -d "$ac_mysql_plugin_dir/" ; then
PLUGIN_DIR="$ac_mysql_plugin_dir"
AC_SUBST(PLUGIN_DIR)
AC_MSG_RESULT([yes: Using $ac_mysql_plugin_dir])
else
AC_MSG_ERROR([invalid MySQL plugin directory : $ac_mysql_plugin_dir])
fi
],
[
LIB_DIR_TMP=`"$ac_mysql_config" --plugindir`
if test ! -d "$LIB_DIR_TMP"; then
LIB_DIR_TMP=`"$ac_mysql_config" --libs_r | sed -e "s|.*-L/|/|" | sed -e "s| .*||"`/plugin
# FIXME
fi
ac_mysql_plugin_dir=$LIB_DIR_TMP
PLUGIN_DIR="$ac_mysql_plugin_dir"
AC_SUBST(PLUGIN_DIR)
AC_MSG_RESULT([--with-mysql-plugindir was not set. Using $ac_mysql_plugin_dir])
]
)
])
AC_MSG_CHECKING(whether GCC atomic builtins are available)
# either define HAVE_IB_GCC_ATOMIC_BUILTINS or not
AC_TRY_RUN(
[
int main()
{
long x;
long y;
long res;
char c;
x = 10;
y = 123;
res = __sync_bool_compare_and_swap(&x, x, y);
if (!res || x != y) {
return(1);
}
x = 10;
y = 123;
res = __sync_bool_compare_and_swap(&x, x + 1, y);
if (res || x != 10) {
return(1);
}
x = 10;
y = 123;
res = __sync_add_and_fetch(&x, y);
if (res != 123 + 10 || x != 123 + 10) {
return(1);
}
c = 10;
res = __sync_lock_test_and_set(&c, 123);
if (res != 10 || c != 123) {
return(1);
}
return(0);
}
],
[
AC_DEFINE([HAVE_IB_GCC_ATOMIC_BUILTINS], [1],
[GCC atomic builtins are available])
AC_MSG_RESULT(yes)
],
[
AC_MSG_RESULT(no)
]
)
AC_MSG_CHECKING(whether pthread_t can be used by GCC atomic builtins)
# either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
AC_TRY_RUN(
[
#include <pthread.h>
#include <string.h>
int main(int argc, char** argv) {
pthread_t x1;
pthread_t x2;
pthread_t x3;
memset(&x1, 0x0, sizeof(x1));
memset(&x2, 0x0, sizeof(x2));
memset(&x3, 0x0, sizeof(x3));
__sync_bool_compare_and_swap(&x1, x2, x3);
return(0);
}
],
[
AC_DEFINE([HAVE_IB_ATOMIC_PTHREAD_T_GCC], [1],
[pthread_t can be used by GCC atomic builtins])
AC_MSG_RESULT(yes)
],
[
AC_MSG_RESULT(no)
]
)
AC_MSG_CHECKING(whether Solaris libc atomic functions are available)
# either define HAVE_IB_SOLARIS_ATOMICS or not
AC_CHECK_FUNCS(atomic_add_long \
atomic_cas_32 \
atomic_cas_64 \
atomic_cas_ulong,
AC_DEFINE([HAVE_IB_SOLARIS_ATOMICS], [1],
[Define to 1 if Solaris libc atomic functions \
are available])
)
AC_MSG_CHECKING(whether pthread_t can be used by Solaris libc atomic functions)
# either define HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS or not
AC_TRY_RUN(
[
#include <pthread.h>
#include <string.h>
int main(int argc, char** argv) {
pthread_t x1;
pthread_t x2;
pthread_t x3;
memset(&x1, 0x0, sizeof(x1));
memset(&x2, 0x0, sizeof(x2));
memset(&x3, 0x0, sizeof(x3));
if (sizeof(pthread_t) == 4) {
atomic_cas_32(&x1, x2, x3);
} else if (sizeof(pthread_t) == 8) {
atomic_cas_64(&x1, x2, x3);
} else {
return(1);
}
return(0);
}
],
[
AC_DEFINE([HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS], [1],
[pthread_t can be used by solaris atomics])
AC_MSG_RESULT(yes)
],
[
AC_MSG_RESULT(no)
]
)
TDHSOCKET_SUBDIRS="libeasy libtdhs TDHSocket"
CONFIG_OPTION_MYSQL
AC_SUBST(TDHSOCKET_SUBDIRS)
AC_CONFIG_FILES(Makefile
libeasy/Makefile
libeasy/include/Makefile
libeasy/memory/Makefile
libeasy/util/Makefile
libeasy/thread/Makefile
libeasy/io/Makefile
libeasy/packet/Makefile
libtdhs/Makefile
TDHSocket/Makefile
)
AC_OUTPUT