1
# Local macros for automake & autoconf
3
#---START: Used in for client configure
4
AC_DEFUN([DRIZZLE_TYPE_ACCEPT],
5
[ac_save_CXXFLAGS="$CXXFLAGS"
6
AC_CACHE_CHECK([base type of last arg to accept], mysql_cv_btype_last_arg_accept,
8
if test "$ac_cv_prog_gxx" = "yes"
10
# Add -Werror, remove -fbranch-probabilities (Bug #268)
11
CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-Wcheck//'`
13
mysql_cv_btype_last_arg_accept=none
14
[AC_TRY_COMPILE([#if defined(inline)
18
#include <sys/types.h>
19
#include <sys/socket.h>
21
[int a = accept(1, (struct sockaddr *) 0, (socklen_t *) 0); return (a != 0);],
22
mysql_cv_btype_last_arg_accept=socklen_t)]
23
if test "$mysql_cv_btype_last_arg_accept" = "none"; then
24
[AC_TRY_COMPILE([#if defined(inline)
28
#include <sys/types.h>
29
#include <sys/socket.h>
31
[int a = accept(1, (struct sockaddr *) 0, (size_t *) 0); return (a != 0);],
32
mysql_cv_btype_last_arg_accept=size_t)]
34
if test "$mysql_cv_btype_last_arg_accept" = "none"; then
35
mysql_cv_btype_last_arg_accept=int
38
AC_DEFINE_UNQUOTED([SOCKET_SIZE_TYPE], [$mysql_cv_btype_last_arg_accept],
39
[The base type of the last arg to accept])
40
CXXFLAGS="$ac_save_CXXFLAGS"
44
dnl Find type of qsort
45
AC_DEFUN([DRIZZLE_TYPE_QSORT],
46
[AC_CACHE_CHECK([return type of qsort], mysql_cv_type_qsort,
47
[AC_TRY_COMPILE([#include <stdlib.h>
51
void qsort(void *base, size_t nel, size_t width,
52
int (*compar) (const void *, const void *));
54
[int i;], mysql_cv_type_qsort=void, mysql_cv_type_qsort=int)])
55
AC_DEFINE_UNQUOTED([RETQSORTTYPE], [$mysql_cv_type_qsort],
56
[The return type of qsort (int or void).])
57
if test "$mysql_cv_type_qsort" = "void"
59
AC_DEFINE_UNQUOTED([QSORT_TYPE_IS_VOID], [1], [qsort returns void])
63
#---START: Figure out whether to use 'struct rlimit' or 'struct rlimit64'
64
AC_DEFUN([DRIZZLE_TYPE_STRUCT_RLIMIT],
65
[ac_save_CXXFLAGS="$CXXFLAGS"
66
AC_CACHE_CHECK([struct type to use with setrlimit], mysql_cv_btype_struct_rlimit,
68
if test "$ac_cv_prog_gxx" = "yes"
70
# Add -Werror, remove -fbranch-probabilities (Bug #268)
71
CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-Wcheck//'`
73
mysql_cv_btype_struct_rlimit=none
74
[AC_TRY_COMPILE([#if defined(inline)
78
#include <sys/resource.h>
80
[struct rlimit64 rl; setrlimit(RLIMIT_CORE, &rl);],
81
mysql_cv_btype_struct_rlimit="struct rlimit64")]
82
if test "$mysql_cv_btype_struct_rlimit" = "none"; then
83
mysql_cv_btype_struct_rlimit="struct rlimit"
86
AC_DEFINE_UNQUOTED([STRUCT_RLIMIT], [$mysql_cv_btype_struct_rlimit],
87
[The struct rlimit type to use with setrlimit])
88
CXXFLAGS="$ac_save_CXXFLAGS"
92
AC_DEFUN([DRIZZLE_TIMESPEC_TS],
93
[AC_CACHE_CHECK([if struct timespec has a ts_sec member], mysql_cv_timespec_ts,
94
[AC_TRY_COMPILE([#include <pthread.h>
99
[struct timespec abstime;
101
abstime.ts_sec = time(NULL)+1;
103
], mysql_cv_timespec_ts=yes, mysql_cv_timespec_ts=no)])
104
if test "$mysql_cv_timespec_ts" = "yes"
106
AC_DEFINE([HAVE_TIMESPEC_TS_SEC], [1],
107
[Timespec has a ts_sec instead of tv_sev])
111
AC_DEFUN([DRIZZLE_TZNAME],
112
[AC_CACHE_CHECK([if we have tzname variable], mysql_cv_tzname,
113
[AC_TRY_COMPILE([#include <time.h>
119
return tzname[0] != 0;
120
], mysql_cv_tzname=yes, mysql_cv_tzname=no)])
121
if test "$mysql_cv_tzname" = "yes"
123
AC_DEFINE([HAVE_TZNAME], [1], [Have the tzname variable])
128
AC_DEFUN([DRIZZLE_PTHREAD_YIELD],[
129
# Some OSes like Mac OS X have that as a replacement for pthread_yield()
130
AC_CHECK_FUNCS(pthread_yield_np, AC_DEFINE([HAVE_PTHREAD_YIELD_NP],[],[Define if you have pthread_yield_np]))
131
AC_CACHE_CHECK([if pthread_yield takes zero arguments], ac_cv_pthread_yield_zero_arg,
132
[AC_TRY_LINK([#define _GNU_SOURCE
140
], ac_cv_pthread_yield_zero_arg=yes, ac_cv_pthread_yield_zero_arg=yeso)])
141
if test "$ac_cv_pthread_yield_zero_arg" = "yes"
143
AC_DEFINE([HAVE_PTHREAD_YIELD_ZERO_ARG], [1],
144
[pthread_yield that doesn't take any arguments])
146
AC_CACHE_CHECK([if pthread_yield takes 1 argument], ac_cv_pthread_yield_one_arg,
147
[AC_TRY_LINK([#define _GNU_SOURCE
155
], ac_cv_pthread_yield_one_arg=yes, ac_cv_pthread_yield_one_arg=no)])
156
if test "$ac_cv_pthread_yield_one_arg" = "yes"
158
AC_DEFINE([HAVE_PTHREAD_YIELD_ONE_ARG], [1],
159
[pthread_yield function with one argument])
166
# From fileutils-3.14/aclocal.m4
168
# @defmac AC_PROG_CC_STDC
169
# @maindex PROG_CC_STDC
171
# If the C compiler in not in ANSI C mode by default, try to add an option
172
# to output variable @code{CC} to make it so. This macro tries various
173
# options that select ANSI C on some system or another. It considers the
174
# compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and
175
# handles function prototypes correctly.
177
# Patched by monty to only check if __STDC__ is defined. With the original
178
# check it's impossible to get things to work with the Sunpro compiler from
181
# If you use this macro, you should check after calling it whether the C
182
# compiler has been set to accept ANSI C; if not, the shell variable
183
# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
184
# code in ANSI C, you can make an un-ANSIfied copy of it by using the
185
# program @code{ansi2knr}, which comes with Ghostscript.
188
AC_DEFUN([AM_PROG_CC_STDC],
189
[AC_REQUIRE([AC_PROG_CC])
190
AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
191
AC_CACHE_VAL(am_cv_prog_cc_stdc,
192
[am_cv_prog_cc_stdc=no
194
# Don't try gcc -ansi; that turns off useful extensions and
195
# breaks some systems' header files.
197
# Ultrix and OSF/1 -std1
198
# HP-UX -Aa -D_HPUX_SOURCE
199
# SVR4 -Xc -D__EXTENSIONS__
200
# removed "-Xc -D__EXTENSIONS__" beacause sun c++ does not like it.
201
for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE"
203
CC="$ac_save_CC $ac_arg"
205
[#if !defined(__STDC__)
208
/* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */
210
# include <sys/types.h>
211
# include <sys/stat.h>
214
int test (int i, double x);
215
struct s1 {int (*f) (int a);};
216
struct s2 {int (*f) (double a);};],
217
[am_cv_prog_cc_stdc="$ac_arg"; break])
221
AC_MSG_RESULT($am_cv_prog_cc_stdc)
222
case "x$am_cv_prog_cc_stdc" in
224
*) CC="$CC $am_cv_prog_cc_stdc" ;;
228
# Orginal from bash-2.0 aclocal.m4, Changed to use termcap last by monty.
230
AC_DEFUN([DRIZZLE_CHECK_LIB_TERMCAP],
232
AC_CACHE_VAL(mysql_cv_termcap_lib,
233
[AC_CHECK_LIB(ncurses, tgetent, mysql_cv_termcap_lib=libncurses,
234
[AC_CHECK_LIB(curses, tgetent, mysql_cv_termcap_lib=libcurses,
235
[AC_CHECK_LIB(termcap, tgetent, mysql_cv_termcap_lib=libtermcap,
236
[AC_CHECK_LIB(tinfo, tgetent, mysql_cv_termcap_lib=libtinfo,
237
mysql_cv_termcap_lib=NOT_FOUND)])])])])
238
AC_MSG_CHECKING(for termcap functions library)
239
if test "$mysql_cv_termcap_lib" = "NOT_FOUND"; then
240
AC_MSG_ERROR([No curses/termcap library found])
241
elif test "$mysql_cv_termcap_lib" = "libtermcap"; then
242
TERMCAP_LIB=-ltermcap
243
elif test "$mysql_cv_termcap_lib" = "libncurses"; then
244
TERMCAP_LIB=-lncurses
245
elif test "$mysql_cv_termcap_lib" = "libtinfo"; then
250
AC_MSG_RESULT($TERMCAP_LIB)
253
dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
254
AC_DEFUN([DRIZZLE_SIGNAL_CHECK],
255
[AC_REQUIRE([AC_TYPE_SIGNAL])
256
AC_MSG_CHECKING(for type of signal functions)
257
AC_CACHE_VAL(mysql_cv_signal_vintage,
259
AC_TRY_LINK([#include <signal.h>],[
262
sigemptyset(&ss); sigsuspend(&ss);
263
sigaction(SIGINT, &sa, (struct sigaction *) 0);
264
sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
265
], mysql_cv_signal_vintage=posix,
267
AC_TRY_LINK([#include <signal.h>], [
268
int mask = sigmask(SIGINT);
269
sigsetmask(mask); sigblock(mask); sigpause(mask);
270
], mysql_cv_signal_vintage=4.2bsd,
274
RETSIGTYPE foo() { }], [
275
int mask = sigmask(SIGINT);
276
sigset(SIGINT, foo); sigrelse(SIGINT);
277
sighold(SIGINT); sigpause(SIGINT);
278
], mysql_cv_signal_vintage=svr3, mysql_cv_signal_vintage=v7
283
AC_MSG_RESULT($mysql_cv_signal_vintage)
284
if test "$mysql_cv_signal_vintage" = posix; then
285
AC_DEFINE(HAVE_POSIX_SIGNALS, [1],
286
[Signal handling is POSIX (sigset/sighold, etc)])
287
elif test "$mysql_cv_signal_vintage" = "4.2bsd"; then
288
AC_DEFINE([HAVE_BSD_SIGNALS], [1], [BSD style signals])
289
elif test "$mysql_cv_signal_vintage" = svr3; then
290
AC_DEFINE(HAVE_USG_SIGHOLD, [1], [sighold() is present and usable])
294
AC_DEFUN([DRIZZLE_CHECK_GETPW_FUNCS],
295
[AC_MSG_CHECKING(whether programs are able to redeclare getpw functions)
296
AC_CACHE_VAL(mysql_cv_can_redecl_getpw,
297
[AC_TRY_COMPILE([#include <sys/types.h>
299
extern struct passwd *getpwent();], [struct passwd *z; z = getpwent();],
300
mysql_cv_can_redecl_getpw=yes,mysql_cv_can_redecl_getpw=no)])
301
AC_MSG_RESULT($mysql_cv_can_redecl_getpw)
302
if test "$mysql_cv_can_redecl_getpw" = "no"; then
303
AC_DEFINE(HAVE_GETPW_DECLS, [1], [getpwent() declaration present])
307
AC_DEFUN([DRIZZLE_HAVE_TIOCGWINSZ],
308
[AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
309
AC_CACHE_VAL(mysql_cv_tiocgwinsz_in_ioctl,
310
[AC_TRY_COMPILE([#include <sys/types.h>
311
#include <sys/ioctl.h>], [int x = TIOCGWINSZ;],
312
mysql_cv_tiocgwinsz_in_ioctl=yes,mysql_cv_tiocgwinsz_in_ioctl=no)])
313
AC_MSG_RESULT($mysql_cv_tiocgwinsz_in_ioctl)
314
if test "$mysql_cv_tiocgwinsz_in_ioctl" = "yes"; then
315
AC_DEFINE([GWINSZ_IN_SYS_IOCTL], [1],
316
[READLINE: your system defines TIOCGWINSZ in sys/ioctl.h.])
320
AC_DEFUN([DRIZZLE_HAVE_TIOCSTAT],
321
[AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
322
AC_CACHE_VAL(mysql_cv_tiocstat_in_ioctl,
323
[AC_TRY_COMPILE([#include <sys/types.h>
324
#include <sys/ioctl.h>], [int x = TIOCSTAT;],
325
mysql_cv_tiocstat_in_ioctl=yes,mysql_cv_tiocstat_in_ioctl=no)])
326
AC_MSG_RESULT($mysql_cv_tiocstat_in_ioctl)
327
if test "$mysql_cv_tiocstat_in_ioctl" = "yes"; then
328
AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL, [1],
329
[declaration of TIOCSTAT in sys/ioctl.h])
333
AC_DEFUN([DRIZZLE_TYPE_SIGHANDLER],
334
[AC_MSG_CHECKING([whether signal handlers are of type void])
335
AC_CACHE_VAL(mysql_cv_void_sighandler,
336
[AC_TRY_COMPILE([#include <sys/types.h>
344
void (*signal ()) ();],
345
[int i;], mysql_cv_void_sighandler=yes, mysql_cv_void_sighandler=no)])dnl
346
AC_MSG_RESULT($mysql_cv_void_sighandler)
347
if test "$mysql_cv_void_sighandler" = "yes"; then
348
AC_DEFINE(VOID_SIGHANDLER, [1], [sighandler type is void (*signal ()) ();])
352
AC_DEFUN([DRIZZLE_STACK_DIRECTION],
353
[AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
354
[AC_TRY_RUN([#include <stdlib.h>
355
int find_stack_direction ()
357
static char *addr = 0;
362
return find_stack_direction ();
365
return (&dummy > addr) ? 1 : -1;
369
exit (find_stack_direction() < 0);
370
}], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1,
371
ac_cv_c_stack_direction=)])
372
AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
375
AC_DEFUN([DRIZZLE_CHECK_LONGLONG_TO_FLOAT],
377
AC_MSG_CHECKING(if conversion of int64_t to float works)
378
AC_CACHE_VAL(ac_cv_conv_longlong_to_float,
379
[AC_TRY_RUN([#include <stdio.h>
385
FILE *file=fopen("conftestval", "w");
387
fprintf(file,"%g\n",f);
390
}], ac_cv_conv_longlong_to_float=`cat conftestval`,
391
ac_cv_conv_longlong_to_float=0,
392
ac_cv_conv_longlong_to_float="yes")])dnl # Cross compiling, assume can convert
393
if test "$ac_cv_conv_longlong_to_float" = "1" -o "$ac_cv_conv_longlong_to_float" = "yes"
395
ac_cv_conv_longlong_to_float=yes
397
ac_cv_conv_longlong_to_float=no
399
AC_MSG_RESULT($ac_cv_conv_longlong_to_float)
402
AC_DEFUN([DRIZZLE_CHECK_VIO], [
404
dnl we always use vio: no need for special defines
406
AC_DEFINE([HAVE_VIO_READ_BUFF], [1],
407
[Define to enable buffered read. This works only if syscalls
408
read/recv return as soon as there is some data in the kernel
409
buffer, no matter how big the given buffer is.])
412
# Local version of _AC_PROG_CXX_EXIT_DECLARATION that does not
413
# include #stdlib.h as default as this breaks things on Solaris
414
# (Conflicts with pthreads and big file handling)
416
m4_define([_AC_PROG_CXX_EXIT_DECLARATION],
417
[for ac_declaration in \
419
'extern "C" void std::exit (int) throw (); using std::exit;' \
420
'extern "C" void std::exit (int); using std::exit;' \
421
'extern "C" void exit (int) throw ();' \
422
'extern "C" void exit (int);' \
424
'#include <stdlib.h>'
426
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration
427
@%:@include <stdlib.h>],
431
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration],
436
if test -n "$ac_declaration"; then
437
echo '#ifdef __cplusplus' >>confdefs.h
438
echo $ac_declaration >>confdefs.h
439
echo '#endif' >>confdefs.h
441
])# _AC_PROG_CXX_EXIT_DECLARATION
443
dnl ---------------------------------------------------------------------------
446
dnl ---------------------------------------------------------------------------
447
dnl Macro: DRIZZLE_CHECK_MAX_INDEXES
449
dnl ---------------------------------------------------------------------------
450
AC_DEFUN([DRIZZLE_CHECK_MAX_INDEXES], [
451
AC_ARG_WITH([max-indexes],
452
AS_HELP_STRING([--with-max-indexes=N],
453
[Sets the maximum number of indexes per table, default 64]),
454
[max_indexes="$withval"],
456
AC_MSG_CHECKING([max indexes per table])
457
AC_DEFINE_UNQUOTED([MAX_INDEXES], [$max_indexes],
458
[Maximum number of indexes per table])
459
AC_MSG_RESULT([$max_indexes])
461
dnl ---------------------------------------------------------------------------
462
dnl END OF DRIZZLE_CHECK_MAX_INDEXES SECTION
463
dnl ---------------------------------------------------------------------------
465
AC_DEFUN([DRIZZLE_CHECK_C_VERSION],[
467
dnl Print version of C compiler
468
AC_MSG_CHECKING("C Compiler version")
469
if test "$GCC" = "yes"
471
CC_VERSION=`$CC --version | sed 1q`
472
elif test "$SUNCC" = "yes"
478
AC_MSG_RESULT("$CC $CC_VERSION")
483
AC_DEFUN([DRIZZLE_CHECK_CXX_VERSION], [
484
dnl Print version of CXX compiler
485
AC_MSG_CHECKING("C++ Compiler version")
486
if test "$GCC" = "yes"
488
CXX_VERSION=`$CXX --version | sed 1q`
489
elif test "$SUNCC" = "yes"
491
CXX_VERSION=`$CXX -V`
495
AC_MSG_RESULT("$CXX $CXX_VERSION")
496
AC_SUBST(CXX_VERSION)
499
AC_DEFUN([DRIZZLE_PROG_AR], [
510
AC_CHECK_PROG([AR], [ar], [ar])
511
if test -z "$AR" || test "$AR" = "false"
513
AC_MSG_ERROR([You need ar to build the library])
515
if test -z "$ARFLAGS"
525
dnl Macro to check time_t range: according to C standard
526
dnl array index must be greater than 0 => if time_t is signed,
527
dnl the code in the macros below won't compile.
530
AC_DEFUN([DRIZZLE_CHECK_TIME_T],[
531
AC_MSG_CHECKING(if time_t is unsigned)
532
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
537
int array[(((time_t)-1) > 0) ? 1 : -1];
540
AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])