~drizzle-trunk/drizzle/development

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