forked from tony2001/pinba_engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
361 lines (302 loc) · 8.77 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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
AC_INIT([pinba_engine], [1.1.0])
AC_CONFIG_MACRO_DIR([m4])
AM_CONFIG_HEADER(src/config.h)
AX_PREFIX_CONFIG_H([src/pinba_config.h])
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_LIBTOOL
LIBTOOL="$LIBTOOL --preserve-dup-deps"
AC_SUBST(LIBTOOL)
AC_SUBST(MYSQL_INC)
dnl CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti"
CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-rtti"
AC_C_CONST
AC_TYPE_SIZE_T
AC_CHECK_HEADERS(limits.h syslimits.h string.h strings.h unistd.h stdint.h)
AC_PROG_SED
AC_PROG_AWK
AC_CHECK_FUNCS([strndup sysconf])
AX_CONFIG_NICE([config.nice])
dnl check for floor and libm
AC_CHECK_LIB([m], [floor], [LIBS="$LIBS -lm"], [AC_MSG_ERROR([can't continue without libm])])
AC_CHECK_LIB([pthread], [pthread_setaffinity_np], [
AC_DEFINE([HAVE_PTHREAD_SETAFFINITY_NP], [1], [Whether pthread_setaffinity_np() is available])
], [AC_MSG_NOTICE([can't find pthread_setaffinity_np()])])
STANDARD_PREFIXES="/usr /usr/local /opt /local"
dir_resolve() dnl {{{
{
pwd=`pwd`
cd "$1" 2>/dev/null || cd "${pwd}/${1}" 2>/dev/null
if test "$?" = "0"; then
echo `pwd -P`
else
echo "$1"
fi
}
dnl }}}
dnl {{{ --with-libdir
AC_ARG_WITH(libdir,
[AS_HELP_STRING([--with-libdir],[look for libraries in .../NAME rather than .../lib])
],
[LIBDIR=$with_libdir],
[LIBDIR=lib]
)
dnl }}}
dnl {{{ --disable-rpath
AC_ARG_ENABLE(rpath,
[AS_HELP_STRING([--disable-rpath],[disable passing additional runtime library search paths])
],
[PINBA_RPATH=no],
[PINBA_RPATH=yes]
)
dnl }}}
dnl {{{ check for rpath support
AC_MSG_CHECKING([if compiler supports -R])
AC_CACHE_VAL(pinba_cv_cc_dashr,[
SAVE_LIBS=$LIBS
LIBS="-R /usr/$LIBDIR $LIBS"
AC_TRY_LINK([], [], pinba_cv_cc_dashr=yes, pinba_cv_cc_dashr=no)
LIBS=$SAVE_LIBS])
AC_MSG_RESULT([$pinba_cv_cc_dashr])
if test $pinba_cv_cc_dashr = "yes"; then
ld_runpath_switch=-R
else
AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
AC_CACHE_VAL(pinba_cv_cc_rpath,[
SAVE_LIBS=$LIBS
LIBS="-Wl,-rpath,/usr/$LIBDIR $LIBS"
AC_TRY_LINK([], [], pinba_cv_cc_rpath=yes, pinba_cv_cc_rpath=no)
LIBS=$SAVE_LIBS])
AC_MSG_RESULT([$pinba_cv_cc_rpath])
if test $pinba_cv_cc_rpath = "yes"; then
ld_runpath_switch=-Wl,-rpath,
else
ld_runpath_switch=-L
fi
fi
if test "$PINBA_RPATH" = "no"; then
ld_runpath_switch=
fi
dnl }}}
dnl {{{ --with-mysql
AC_MSG_CHECKING(for MySQL source code)
AC_ARG_WITH(mysql,
[AS_HELP_STRING([--with-mysql],[specify MySQL sources directory])
],
[
],
[
AC_MSG_ERROR([Please provide path to the MySQL sources directory])
])
if test "x$with_mysql" = "xno"; then
AC_MSG_ERROR([can't continue without MySQL sources])
else
if test "x$with_mysql" = "xyes"; then
AC_MSG_ERROR([sorry, I'm not that smart to guess where the MySQL sources are, please specify the path])
fi
with_mysql=`dir_resolve "$with_mysql"`
HEADERS="include/my_dir.h include/mysql/plugin.h include/mysql.h include/mysql_version.h"
for file in $HEADERS; do
if ! test -r "$with_mysql/$file"; then
AC_MSG_ERROR([Failed to find required header file $file in $with_mysql, check the path and make sure you've run './configure ..<options>.. && cd include && make' in MySQL sources dir])
fi
done
AC_MSG_RESULT([$with_mysql])
CFLAGS_old="$CFLAGS"
CFLAGS="-I$with_mysql/include $CFLAGS"
AC_MSG_CHECKING([for MySQL version >= 5.1])
AC_TRY_RUN([
#include <stdlib.h>
#include <mysql_version.h>
main() {
#if MYSQL_VERSION_ID >= 50100
exit(0);
#else
exit(1);
#endif
}
], [
AC_MSG_RESULT([ok])
], [
AC_MSG_ERROR([MySQL 5.1+ is required])
])
dnl check for 5.5 version with missing files and broken method signatures
MISSING_HEADER="sql/mysql_priv.h"
if ! test -r "$with_mysql/$MISSING_HEADER"; then
AC_DEFINE([MYSQL_VERSION_5_5], [1], [Whether we have MySQL 5.5])
fi
CFLAGS="$CFLAGS_old"
AC_DEFINE([MYSQL_SRC], [1], [Source directory for MySQL])
MYSQL_INC="-I$with_mysql/sql -I$with_mysql/include -I$with_mysql/regex -I$with_mysql"
fi
dnl }}}
dnl {{{ --with-event
AC_ARG_WITH(event,
[AS_HELP_STRING([--with-event],[specify libevent install prefix])
],
[ ],
[with_event=yes]
)
if test "x$with_event" = "xno"; then
AC_MSG_ERROR([can't continue without libevent])
else
AC_MSG_CHECKING([libevent install prefix])
if test "x$with_event" = "xyes"; then
for i in `echo "$STANDARD_PREFIXES"`; do
if test -f "$i/include/event.h"; then
LIBEVENT_DIR="$i"
break;
fi
done
else
with_event=`dir_resolve "$with_event"`
if test -f "$with_event/include/event.h"; then
LIBEVENT_DIR="$with_event"
else
AC_MSG_ERROR([Can't find libevent headers under $with_event directory])
fi
fi
if test "x$LIBEVENT_DIR" = "x"; then
AC_MSG_ERROR([Unable to locate libevent headers, please use --with-event=<DIR>])
fi
AC_MSG_RESULT([$LIBEVENT_DIR])
LDFLAGS="$LDFLAGS -L$LIBEVENT_DIR/$LIBDIR"
LIBS="$LIBS -levent"
CXXFLAGS="$CXXFLAGS -I$LIBEVENT_DIR/include"
CFLAGS="$CFLAGS -I$LIBEVENT_DIR/include"
if test "$PINBA_RPATH" != "no"; then
LDFLAGS="$LDFLAGS $ld_runpath_switch$LIBEVENT_DIR/$LIBDIR"
fi
old_LDFLAGS=$LDFLAGS
if test "$PINBA_RPATH" != "no"; then
LDFLAGS="$ld_runpath_switch$LIBEVENT_DIR/$LIBDIR -L$LIBEVENT_DIR/$LIBDIR -levent"
else
LDFLAGS="-L$LIBEVENT_DIR/$LIBDIR -levent"
fi
LD_LIBRARY_PATH="$LIBEVENT_DIR/$LIBDIR:$LD_LIBRARY_PATH"
AC_MSG_CHECKING([if libevent requires -lrt])
AC_TRY_RUN([
#include <stdlib.h>
#include <event.h>
int main() {
struct event ev;
event_set(&ev, 0, EV_READ, NULL, NULL);
return 0;
}
], [
AC_MSG_RESULT([no])
LIBRT_REQUIRED="no"
], [
if test "$PINBA_RPATH" != "no"; then
LDFLAGS="$ld_runpath_switch$LIBEVENT_DIR/$LIBDIR -L$LIBEVENT_DIR/$LIBDIR -levent -lrt"
else
LDFLAGS="-L$LIBEVENT_DIR/$LIBDIR -levent -lrt"
fi
AC_TRY_RUN([
#include <stdlib.h>
#include <event.h>
int main() {
struct event *ev;
event_set(&ev, 0, EV_READ, NULL, NULL);
return 0;
}
], [
AC_MSG_RESULT([yes])
LIBRT_REQUIRED="yes"
], [
AC_MSG_ERROR([something went wrong - cannot link libevent, please report (attach you config.log)])
])
])
LDFLAGS=$old_LDFLAGS;
if test "$LIBRT_REQUIRED" = "yes"; then
LDFLAGS="$LDFLAGS -lrt"
fi
AC_CHECK_LIB([event], [event_base_new], [], [
AC_MSG_ERROR([event_base_new() is missing - libevent must be too old {minimum required version is 1.4.1}. Check config.log for more details])
])
fi
dnl }}}
dnl {{{ --with-judy
AC_ARG_WITH(judy,
[AS_HELP_STRING([--with-judy],[specify Judy install prefix])
],
[ ],
[with_judy=yes]
)
if test "x$with_judy" = "xno"; then
AC_MSG_ERROR([can't continue without Judy])
else
AC_MSG_CHECKING([Judy install prefix])
if test "x$with_judy" = "xyes"; then
for i in `echo "$STANDARD_PREFIXES"`; do
if test -f "$i/include/Judy.h"; then
JUDY_DIR="$i"
break;
fi
done
else
with_judy=`dir_resolve "$with_judy"`
if test -f "$with_judy/include/Judy.h"; then
JUDY_DIR="$with_judy"
else
AC_MSG_ERROR([Can't find Judy headers under $with_judy directory]);
fi
fi
if test "x$JUDY_DIR" = "x"; then
AC_MSG_ERROR([Unable to locate Judy headers, please use --with-judy=<DIR>]);
fi
AC_MSG_RESULT([$JUDY_DIR])
LDFLAGS="$LDFLAGS -L$JUDY_DIR/$LIBDIR"
LIBS="$LIBS -lJudy"
CXXFLAGS="$CXXFLAGS -I$JUDY_DIR/include"
CFLAGS="$CFLAGS -I$JUDY_DIR/include"
if test "$PINBA_RPATH" != "no"; then
LDFLAGS="$LDFLAGS $ld_runpath_switch$JUDY_DIR/$LIBDIR"
fi
fi
dnl }}}
dnl {{{ --enable-debug
AC_ARG_ENABLE(debug,
[AS_HELP_STRING([--enable-debug],[enable debugging symbols and compile flags])
],
[
if test x"$enableval" = xyes ; then
debug="yes"
else
debug="no"
fi
]
)
if test x"$debug" = xyes ; then
DEBUG_FLAGS="-DSAFE_MUTEX -DDBUG_ON -DEXTRA_DEBUG -DUNIV_MUST_NOT_INLINE -DFORCE_INIT_OF_VARS -DPINBA_DEBUG"
AC_DEFINE([DEBUG_ON], [1], [debug is on])
if test x"$GCC" = xyes; then
dnl Remove any optimization flags from CFLAGS
changequote({,})
CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/-O[0-9s]*//g'`
CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/-g[0-2]\? //g'`
CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9s]*//g'`
CFLAGS=`echo "$CFLAGS" | sed -e 's/-g[0-2]\? //g'`
changequote([,])
CXXFLAGS="$CXXFLAGS -g3 -Wall -O0 $DEBUG_FLAGS"
CFLAGS="$CFLAGS -g3 -Wall -O0 $DEBUG_FLAGS"
fi
ADD_FLAGS=""
dnl Do not strip symbols from developer object files.
INSTALL_STRIP_FLAG=""
else
AC_DEFINE([DEBUG_OFF], [1], [debug is off])
ADD_FLAGS="-DJUDYERROR_NOTEST"
dnl Make sure to strip symbols from non-developer object files.
INSTALL_STRIP_FLAG="-s"
fi
dnl }}}
ADD_FLAGS="-DMYSQL_DYNAMIC_PLUGIN -DNDEBUG $ADD_FLAGS"
CXXFLAGS="$CXXFLAGS $ADD_FLAGS"
CFLAGS="$CFLAGS $ADD_FLAGS"
AC_SUBST(INSTALL_STRIP_FLAG)
AC_SUBST(DEPS_LIBS)
AC_SUBST(DEPS_CFLAGS)
AC_OUTPUT(Makefile src/Makefile)