-
Notifications
You must be signed in to change notification settings - Fork 42
/
configure.ac
264 lines (220 loc) · 6.61 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
AC_INIT([pinba_engine], [1.2.0])
AC_CONFIG_MACRO_DIR([m4])
AM_CONFIG_HEADER(src/config.h)
AX_PREFIX_CONFIG_H([src/pinba_config.h])
AM_INIT_AUTOMAKE
AC_CONFIG_SUBDIRS([sparsehash])
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_LIBTOOL
LIBTOOL="$LIBTOOL --preserve-dup-deps"
AC_SUBST(LIBTOOL)
AC_SUBST(MYSQL_INC)
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 recvmmsg])
changequote({,})
CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/ -DMYSQL_DYNAMIC_PLUGIN -DNDEBUG//g'`
CFLAGS=`echo "$CFLAGS" | sed -e 's/ -DNDEBUG//g'`
changequote([,])
CXXFLAGS="$CXXFLAGS -DMYSQL_DYNAMIC_PLUGIN -DNDEBUG"
CFLAGS="$CFLAGS -DNDEBUG"
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"
dnl autorevision {{{
AUTOREVISION="$srcdir/autorevision.sh"
v=$($AUTOREVISION -t sh)
if test "$?" = "0"; then
eval "$v"
AC_DEFINE_UNQUOTED([VCS_DATE], "$VCS_DATE", [vcs date])
AC_DEFINE_UNQUOTED([VCS_BRANCH], "$VCS_BRANCH", [vcs branch])
AC_DEFINE_UNQUOTED([VCS_FULL_HASH], "$VCS_FULL_HASH", [vcs full hash])
AC_DEFINE_UNQUOTED([VCS_SHORT_HASH], "$VCS_SHORT_HASH", [vcs short hash])
AC_DEFINE_UNQUOTED([VCS_WC_MODIFIED], "$VCS_WC_MODIFIED", [vcs wc modified])
fi
dnl }}}
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 {{{ --enable-static-build
AC_ARG_ENABLE(static-build,
[AS_HELP_STRING([--enable-static-build],[link against non-system libs statically])
],
[
AC_MSG_CHECKING([if static linking is forced])
if test x"$enableval" = xyes ; then
FORCE_STATIC_BUILD=yes
else
FORCE_STATIC_BUILD=no
fi
AC_MSG_RESULT([$FORCE_STATIC_BUILD])
]
)
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])
dnl Make sure to strip symbols from non-developer object files.
INSTALL_STRIP_FLAG="-s"
fi
dnl }}}
dnl {{{ --with-build-string
AC_ARG_WITH(build-string,
[AS_HELP_STRING([--with-build-string],[set custom build information here])
],
[
dq="\""
ws=" "
if test "${with_build_string#*$ws}" != "$with_build_string" || test "${with_build_string#*$dq}" != "$with_build_string"; then
AC_MSG_ERROR([Build string cannot contain whitespaces or double quotes])
fi
AC_DEFINE_UNQUOTED([PINBA_BUILD_STRING], "$with_build_string", [custom build string])
],
[ ]
)
dnl }}}
AC_SUBST(INSTALL_STRIP_FLAG)
AC_SUBST(DEPS_LIBS)
AC_SUBST(DEPS_CFLAGS)
AC_OUTPUT(Makefile src/Makefile)