~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
# Local macros for automake & autoconf
2
3
#---START: Used in for client configure
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
4
AC_DEFUN([DRIZZLE_TYPE_ACCEPT],
1 by brian
clean slate
5
[ac_save_CXXFLAGS="$CXXFLAGS"
6
AC_CACHE_CHECK([base type of last arg to accept], mysql_cv_btype_last_arg_accept,
7
AC_LANG_PUSH(C++)
779.2.11 by Monty Taylor
General build cleanup - removed cruft, removed depreated checks.
8
if test "$GXX" = "yes"
1 by brian
clean slate
9
then
10
  # Add -Werror, remove -fbranch-probabilities (Bug #268)
11
  CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-Wcheck//'`
12
fi
13
mysql_cv_btype_last_arg_accept=none
14
[AC_TRY_COMPILE([#if defined(inline)
15
#undef inline
16
#endif
17
#include <stdlib.h>
18
#include <sys/types.h>
19
#include <sys/socket.h>
20
],
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)
25
#undef inline
26
#endif
27
#include <stdlib.h>
28
#include <sys/types.h>
29
#include <sys/socket.h>
30
],
31
[int a = accept(1, (struct sockaddr *) 0, (size_t *) 0); return (a != 0);],
32
mysql_cv_btype_last_arg_accept=size_t)]
33
fi
34
if test "$mysql_cv_btype_last_arg_accept" = "none"; then
35
mysql_cv_btype_last_arg_accept=int
36
fi)
37
AC_LANG_POP(C++)
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"
41
])
42
#---END:
43
44
45
#---START: Figure out whether to use 'struct rlimit' or 'struct rlimit64'
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
46
AC_DEFUN([DRIZZLE_TYPE_STRUCT_RLIMIT],
1 by brian
clean slate
47
[ac_save_CXXFLAGS="$CXXFLAGS"
48
AC_CACHE_CHECK([struct type to use with setrlimit], mysql_cv_btype_struct_rlimit,
49
AC_LANG_PUSH(C++)
779.2.11 by Monty Taylor
General build cleanup - removed cruft, removed depreated checks.
50
if test "$GXX" = "yes"
1 by brian
clean slate
51
then
52
  # Add -Werror, remove -fbranch-probabilities (Bug #268)
53
  CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed -e 's/-fbranch-probabilities//; s/-Wall//; s/-Wcheck//'`
54
fi
55
mysql_cv_btype_struct_rlimit=none
56
[AC_TRY_COMPILE([#if defined(inline)
57
#undef inline
58
#endif
59
#include <stdlib.h>
60
#include <sys/resource.h>
61
],
62
[struct rlimit64 rl; setrlimit(RLIMIT_CORE, &rl);],
63
mysql_cv_btype_struct_rlimit="struct rlimit64")]
64
if test "$mysql_cv_btype_struct_rlimit" = "none"; then
65
mysql_cv_btype_struct_rlimit="struct rlimit"
66
fi)
67
AC_LANG_POP(C++)
68
AC_DEFINE_UNQUOTED([STRUCT_RLIMIT], [$mysql_cv_btype_struct_rlimit],
69
                   [The struct rlimit type to use with setrlimit])
70
CXXFLAGS="$ac_save_CXXFLAGS"
71
])
72
#---END:
73
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
74
AC_DEFUN([DRIZZLE_TIMESPEC_TS],
1 by brian
clean slate
75
[AC_CACHE_CHECK([if struct timespec has a ts_sec member], mysql_cv_timespec_ts,
76
[AC_TRY_COMPILE([#include <pthread.h>
77
#ifdef __cplusplus
78
extern "C"
79
#endif
80
],
81
[struct timespec abstime;
82
83
abstime.ts_sec = time(NULL)+1;
84
abstime.ts_nsec = 0;
85
], mysql_cv_timespec_ts=yes, mysql_cv_timespec_ts=no)])
86
if test "$mysql_cv_timespec_ts" = "yes"
87
then
88
  AC_DEFINE([HAVE_TIMESPEC_TS_SEC], [1],
89
            [Timespec has a ts_sec instead of tv_sev])
90
fi
91
])
92
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
93
AC_DEFUN([DRIZZLE_TZNAME],
1 by brian
clean slate
94
[AC_CACHE_CHECK([if we have tzname variable], mysql_cv_tzname,
95
[AC_TRY_COMPILE([#include <time.h>
96
#ifdef __cplusplus
97
extern "C"
98
#endif
99
],
100
[ tzset();
101
  return tzname[0] != 0;
102
], mysql_cv_tzname=yes, mysql_cv_tzname=no)])
103
if test "$mysql_cv_tzname" = "yes"
104
then
105
  AC_DEFINE([HAVE_TZNAME], [1], [Have the tzname variable])
106
fi
107
])
108
109
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
110
AC_DEFUN([DRIZZLE_PTHREAD_YIELD],[
1 by brian
clean slate
111
# Some OSes like Mac OS X have that as a replacement for pthread_yield()
112
AC_CHECK_FUNCS(pthread_yield_np, AC_DEFINE([HAVE_PTHREAD_YIELD_NP],[],[Define if you have pthread_yield_np]))
113
AC_CACHE_CHECK([if pthread_yield takes zero arguments], ac_cv_pthread_yield_zero_arg,
114
[AC_TRY_LINK([#define _GNU_SOURCE
115
#include <pthread.h>
116
#ifdef __cplusplus
117
extern "C"
118
#endif
119
],
120
[
121
  pthread_yield();
122
], ac_cv_pthread_yield_zero_arg=yes, ac_cv_pthread_yield_zero_arg=yeso)])
123
if test "$ac_cv_pthread_yield_zero_arg" = "yes"
124
then
125
  AC_DEFINE([HAVE_PTHREAD_YIELD_ZERO_ARG], [1],
126
            [pthread_yield that doesn't take any arguments])
127
fi
128
AC_CACHE_CHECK([if pthread_yield takes 1 argument], ac_cv_pthread_yield_one_arg,
129
[AC_TRY_LINK([#define _GNU_SOURCE
130
#include <pthread.h>
131
#ifdef __cplusplus
132
extern "C"
133
#endif
134
],
135
[
136
  pthread_yield(0);
137
], ac_cv_pthread_yield_one_arg=yes, ac_cv_pthread_yield_one_arg=no)])
138
if test "$ac_cv_pthread_yield_one_arg" = "yes"
139
then
140
  AC_DEFINE([HAVE_PTHREAD_YIELD_ONE_ARG], [1],
141
            [pthread_yield function with one argument])
142
fi
143
]
144
)
145
146
#---END:
147
148
# From fileutils-3.14/aclocal.m4
149
150
# @defmac AC_PROG_CC_STDC
151
# @maindex PROG_CC_STDC
152
# @ovindex CC
153
# If the C compiler in not in ANSI C mode by default, try to add an option
154
# to output variable @code{CC} to make it so.  This macro tries various
155
# options that select ANSI C on some system or another.  It considers the
156
# compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and
157
# handles function prototypes correctly.
158
#
159
# Patched by monty to only check if __STDC__ is defined. With the original 
160
# check it's impossible to get things to work with the Sunpro compiler from
161
# Workshop 4.2
162
#
163
# If you use this macro, you should check after calling it whether the C
164
# compiler has been set to accept ANSI C; if not, the shell variable
165
# @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
166
# code in ANSI C, you can make an un-ANSIfied copy of it by using the
167
# program @code{ansi2knr}, which comes with Ghostscript.
168
# @end defmac
169
170
AC_DEFUN([AM_PROG_CC_STDC],
171
[AC_REQUIRE([AC_PROG_CC])
172
AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
173
AC_CACHE_VAL(am_cv_prog_cc_stdc,
174
[am_cv_prog_cc_stdc=no
175
ac_save_CC="$CC"
176
# Don't try gcc -ansi; that turns off useful extensions and
177
# breaks some systems' header files.
178
# AIX			-qlanglvl=ansi
179
# Ultrix and OSF/1	-std1
180
# HP-UX			-Aa -D_HPUX_SOURCE
181
# SVR4			-Xc -D__EXTENSIONS__
182
# removed "-Xc -D__EXTENSIONS__" beacause sun c++ does not like it.
183
for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" 
184
do
185
  CC="$ac_save_CC $ac_arg"
186
  AC_TRY_COMPILE(
187
[#if !defined(__STDC__)
188
choke me
189
#endif
190
/* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */
191
#ifdef _SEQUENT_
192
# include <sys/types.h>
193
# include <sys/stat.h>
194
#endif
195
], [
196
int test (int i, double x);
197
struct s1 {int (*f) (int a);};
198
struct s2 {int (*f) (double a);};],
199
[am_cv_prog_cc_stdc="$ac_arg"; break])
200
done
201
CC="$ac_save_CC"
202
])
203
AC_MSG_RESULT($am_cv_prog_cc_stdc)
204
case "x$am_cv_prog_cc_stdc" in
205
  x|xno) ;;
206
  *) CC="$CC $am_cv_prog_cc_stdc" ;;
207
esac
208
])
209
210
211
dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
212
AC_DEFUN([DRIZZLE_SIGNAL_CHECK],
1 by brian
clean slate
213
[AC_REQUIRE([AC_TYPE_SIGNAL])
214
AC_MSG_CHECKING(for type of signal functions)
215
AC_CACHE_VAL(mysql_cv_signal_vintage,
216
[
217
  AC_TRY_LINK([#include <signal.h>],[
218
    sigset_t ss;
219
    struct sigaction sa;
220
    sigemptyset(&ss); sigsuspend(&ss);
221
    sigaction(SIGINT, &sa, (struct sigaction *) 0);
222
    sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
223
  ], mysql_cv_signal_vintage=posix,
224
  [
225
    AC_TRY_LINK([#include <signal.h>], [
226
	int mask = sigmask(SIGINT);
227
	sigsetmask(mask); sigblock(mask); sigpause(mask);
228
    ], mysql_cv_signal_vintage=4.2bsd,
229
    [
230
      AC_TRY_LINK([
231
	#include <signal.h>
779.2.11 by Monty Taylor
General build cleanup - removed cruft, removed depreated checks.
232
	void foo() { }], [
1 by brian
clean slate
233
		int mask = sigmask(SIGINT);
234
		sigset(SIGINT, foo); sigrelse(SIGINT);
235
		sighold(SIGINT); sigpause(SIGINT);
236
        ], mysql_cv_signal_vintage=svr3, mysql_cv_signal_vintage=v7
237
    )]
238
  )]
239
)
240
])
241
AC_MSG_RESULT($mysql_cv_signal_vintage)
242
if test "$mysql_cv_signal_vintage" = posix; then
243
AC_DEFINE(HAVE_POSIX_SIGNALS, [1],
244
          [Signal handling is POSIX (sigset/sighold, etc)])
245
elif test "$mysql_cv_signal_vintage" = "4.2bsd"; then
246
AC_DEFINE([HAVE_BSD_SIGNALS], [1], [BSD style signals])
247
elif test "$mysql_cv_signal_vintage" = svr3; then
248
AC_DEFINE(HAVE_USG_SIGHOLD, [1], [sighold() is present and usable])
249
fi
250
])
251
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
252
AC_DEFUN([DRIZZLE_CHECK_GETPW_FUNCS],
1 by brian
clean slate
253
[AC_MSG_CHECKING(whether programs are able to redeclare getpw functions)
254
AC_CACHE_VAL(mysql_cv_can_redecl_getpw,
255
[AC_TRY_COMPILE([#include <sys/types.h>
256
#include <pwd.h>
257
extern struct passwd *getpwent();], [struct passwd *z; z = getpwent();],
258
  mysql_cv_can_redecl_getpw=yes,mysql_cv_can_redecl_getpw=no)])
259
AC_MSG_RESULT($mysql_cv_can_redecl_getpw)
260
if test "$mysql_cv_can_redecl_getpw" = "no"; then
261
AC_DEFINE(HAVE_GETPW_DECLS, [1], [getpwent() declaration present])
262
fi
263
])
264
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
265
AC_DEFUN([DRIZZLE_HAVE_TIOCGWINSZ],
1 by brian
clean slate
266
[AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h)
267
AC_CACHE_VAL(mysql_cv_tiocgwinsz_in_ioctl,
268
[AC_TRY_COMPILE([#include <sys/types.h>
269
#include <sys/ioctl.h>], [int x = TIOCGWINSZ;],
270
  mysql_cv_tiocgwinsz_in_ioctl=yes,mysql_cv_tiocgwinsz_in_ioctl=no)])
271
AC_MSG_RESULT($mysql_cv_tiocgwinsz_in_ioctl)
272
if test "$mysql_cv_tiocgwinsz_in_ioctl" = "yes"; then   
273
AC_DEFINE([GWINSZ_IN_SYS_IOCTL], [1],
274
          [READLINE: your system defines TIOCGWINSZ in sys/ioctl.h.])
275
fi
276
])
277
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
278
AC_DEFUN([DRIZZLE_HAVE_TIOCSTAT],
1 by brian
clean slate
279
[AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
280
AC_CACHE_VAL(mysql_cv_tiocstat_in_ioctl,
281
[AC_TRY_COMPILE([#include <sys/types.h>
282
#include <sys/ioctl.h>], [int x = TIOCSTAT;],
283
  mysql_cv_tiocstat_in_ioctl=yes,mysql_cv_tiocstat_in_ioctl=no)])
284
AC_MSG_RESULT($mysql_cv_tiocstat_in_ioctl)
285
if test "$mysql_cv_tiocstat_in_ioctl" = "yes"; then   
286
AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL, [1],
287
          [declaration of TIOCSTAT in sys/ioctl.h])
288
fi
289
])
290
291
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
292
AC_DEFUN([DRIZZLE_STACK_DIRECTION],
1 by brian
clean slate
293
 [AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
294
 [AC_TRY_RUN([#include <stdlib.h>
295
 int find_stack_direction ()
296
 {
297
   static char *addr = 0;
298
   auto char dummy;
299
   if (addr == 0)
300
     {
301
       addr = &dummy;
302
       return find_stack_direction ();
303
     }
304
   else
305
     return (&dummy > addr) ? 1 : -1;
306
 }
307
 int main ()
308
 {
309
   exit (find_stack_direction() < 0);
310
 }], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1,
311
   ac_cv_c_stack_direction=)])
312
 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
313
])dnl
314
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
315
AC_DEFUN([DRIZZLE_CHECK_LONGLONG_TO_FLOAT],
1 by brian
clean slate
316
[
481.1.3 by Monty Taylor
Replaced long long with int64_t.
317
AC_MSG_CHECKING(if conversion of int64_t to float works)
1 by brian
clean slate
318
AC_CACHE_VAL(ac_cv_conv_longlong_to_float,
319
[AC_TRY_RUN([#include <stdio.h>
481.1.8 by Monty Taylor
Fixed partial longlong->int64 prob.
320
#include <stdint.h>
1 by brian
clean slate
321
int main()
322
{
481.1.3 by Monty Taylor
Replaced long long with int64_t.
323
  int64_t ll=1;
1 by brian
clean slate
324
  float f;
325
  FILE *file=fopen("conftestval", "w");
326
  f = (float) ll;
327
  fprintf(file,"%g\n",f);
328
  fclose(file);
329
  return (0);
330
}], ac_cv_conv_longlong_to_float=`cat conftestval`,
331
    ac_cv_conv_longlong_to_float=0,
332
    ac_cv_conv_longlong_to_float="yes")])dnl  # Cross compiling, assume can convert
333
if test "$ac_cv_conv_longlong_to_float" = "1" -o "$ac_cv_conv_longlong_to_float" = "yes"
334
then
335
  ac_cv_conv_longlong_to_float=yes
336
else
337
  ac_cv_conv_longlong_to_float=no
338
fi
339
AC_MSG_RESULT($ac_cv_conv_longlong_to_float)
340
])
341
342
343
dnl ---------------------------------------------------------------------------
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
344
dnl Macro: DRIZZLE_CHECK_MAX_INDEXES
1 by brian
clean slate
345
dnl Sets MAX_INDEXES
346
dnl ---------------------------------------------------------------------------
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
347
AC_DEFUN([DRIZZLE_CHECK_MAX_INDEXES], [
1 by brian
clean slate
348
  AC_ARG_WITH([max-indexes],
349
              AS_HELP_STRING([--with-max-indexes=N],
350
                             [Sets the maximum number of indexes per table, default 64]),
351
              [max_indexes="$withval"],
352
              [max_indexes=64])
353
  AC_MSG_CHECKING([max indexes per table])
354
  AC_DEFINE_UNQUOTED([MAX_INDEXES], [$max_indexes],
355
                     [Maximum number of indexes per table])
356
  AC_MSG_RESULT([$max_indexes])
357
])
358
dnl ---------------------------------------------------------------------------
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
359
dnl END OF DRIZZLE_CHECK_MAX_INDEXES SECTION
1 by brian
clean slate
360
dnl ---------------------------------------------------------------------------
361
520.4.41 by mordred
Fixed configure.ac to work cleanly on Solaris - and define some good compile flags.
362
AC_DEFUN([DRIZZLE_CHECK_C_VERSION],[
363
364
  dnl Print version of C compiler
365
  AC_MSG_CHECKING("C Compiler version")
366
  if test "$GCC" = "yes"
367
  then
368
    CC_VERSION=`$CC --version | sed 1q`
369
  elif test "$SUNCC" = "yes"
370
  then
632.1.21 by Monty Taylor
Cleaned up compiler version checking.
371
    CC_VERSION=`$CC -V 2>&1 | sed 1q`
520.4.41 by mordred
Fixed configure.ac to work cleanly on Solaris - and define some good compile flags.
372
  else
373
    CC_VERSION=""
374
  fi
632.1.23 by Monty Taylor
One more version string cleanup.
375
  AC_MSG_RESULT("$CC_VERSION")
520.4.41 by mordred
Fixed configure.ac to work cleanly on Solaris - and define some good compile flags.
376
  AC_SUBST(CC_VERSION)
377
])
378
1 by brian
clean slate
379
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
380
AC_DEFUN([DRIZZLE_CHECK_CXX_VERSION], [
520.4.41 by mordred
Fixed configure.ac to work cleanly on Solaris - and define some good compile flags.
381
  dnl Print version of CXX compiler
382
  AC_MSG_CHECKING("C++ Compiler version")
383
  if test "$GCC" = "yes"
384
  then
1 by brian
clean slate
385
    CXX_VERSION=`$CXX --version | sed 1q`
520.4.41 by mordred
Fixed configure.ac to work cleanly on Solaris - and define some good compile flags.
386
  elif test "$SUNCC" = "yes"
387
  then
632.1.21 by Monty Taylor
Cleaned up compiler version checking.
388
    CXX_VERSION=`$CXX -V 2>&1 | sed 1q`
520.4.41 by mordred
Fixed configure.ac to work cleanly on Solaris - and define some good compile flags.
389
  else
390
    CXX_VERSION=""
391
  fi
632.1.23 by Monty Taylor
One more version string cleanup.
392
  AC_MSG_RESULT("$CXX_VERSION")
520.4.41 by mordred
Fixed configure.ac to work cleanly on Solaris - and define some good compile flags.
393
  AC_SUBST(CXX_VERSION)
1 by brian
clean slate
394
])
395
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
396
AC_DEFUN([DRIZZLE_PROG_AR], [
1 by brian
clean slate
397
case $CXX_VERSION in
398
  MIPSpro*)
399
    AR=$CXX
400
    ARFLAGS="-ar -o"
401
  ;;
402
  *Forte*)
403
    AR=$CXX
404
    ARFLAGS="-xar -o"
405
  ;;
406
  *)
407
    AC_CHECK_PROG([AR], [ar], [ar])
408
    if test -z "$AR" || test "$AR" = "false"
409
    then
410
      AC_MSG_ERROR([You need ar to build the library])
411
    fi
412
    if test -z "$ARFLAGS"
413
    then
414
      ARFLAGS="cru"
415
    fi
416
esac
417
AC_SUBST(AR)
418
AC_SUBST(ARFLAGS)
419
])
420
421
dnl
422
dnl  Macro to check time_t range: according to C standard
423
dnl  array index must be greater than 0 => if time_t is signed,
424
dnl  the code in the macros below won't compile.
425
dnl
426
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
427
AC_DEFUN([DRIZZLE_CHECK_TIME_T],[
1 by brian
clean slate
428
    AC_MSG_CHECKING(if time_t is unsigned)
429
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
430
        [[
431
#include <time.h>
432
        ]],
433
        [[
434
        int array[(((time_t)-1) > 0) ? 1 : -1];
435
        ]] )
436
    ], [
437
    AC_DEFINE([TIME_T_UNSIGNED], 1, [Define to 1 if time_t is unsigned])
438
    AC_MSG_RESULT(yes)
439
    ],
440
    [AC_MSG_RESULT(no)]
441
    )
442
])
443