1 dnl Checks to see if this is SUNPro we're building with
4 AC_DEFUN([AC_PROG_CC_SUNPRO],
5 [AC_CACHE_CHECK(whether we are using SUNPro C, ac_cv_prog_suncc,
6 [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
12 if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
19 dnl # FR_CHECK_TYPE_INCLUDE([#includes ...], type, default-C-types)
21 dnl # This function is like AC_CHECK_TYPE, but you can give this one
22 dnl # a list of include files to check.
24 AC_DEFUN([FR_CHECK_TYPE_INCLUDE],
26 AC_CACHE_CHECK(for $2, ac_cv_type_$2,
35 if test "$ac_cv_type_$2" != "yes"; then
41 dnl # Locate the directory in which a particular file is found.
43 dnl # Usage: FR_LOCATE_DIR(MYSQLLIB_DIR, libmysqlclient.a)
45 dnl # Defines the variable MYSQLLIB_DIR to be the directory(s) in
46 dnl # which the file libmysqlclient.a is to be found.
49 AC_DEFUN([FR_LOCATE_DIR],
51 dnl # If we have the program 'locate', then the problem of finding a
52 dnl # particular file becomes MUCH easier.
56 dnl # No 'locate' defined, do NOT do anything.
58 if test "x$LOCATE" != "x"; then
60 dnl # Root through a series of directories, looking for the given file.
65 for x in `${LOCATE} $file 2>/dev/null`; do
67 dnl # When asked for 'foo', locate will also find 'foo_bar', which we
68 dnl # don't want. We want that EXACT filename.
70 dnl # We ALSO want to be able to look for files like 'mysql/mysql.h',
71 dnl # and properly match them, too. So we try to strip off the last
72 dnl # part of the filename, using the name of the file we're looking
73 dnl # for. If we CANNOT strip it off, then the name will be unchanged.
75 base=`echo $x | sed "s%/${file}%%"`
76 if test "x$x" = "x$base"; then
80 dir=`${DIRNAME} $x 2>/dev/null`
82 dnl # Exclude a number of directories.
84 exclude=`echo ${dir} | ${GREP} /home`
85 if test "x$exclude" != "x"; then
90 dnl # OK, we have an exact match. Let's be sure that we only find ONE
91 dnl # matching directory.
93 already=`echo \$$1 ${DIRS} | ${GREP} ${dir}`
94 if test "x$already" = "x"; then
101 dnl # And remember the directory in which we found the file.
103 eval "$1=\"\$$1 $DIRS\""
107 dnl #######################################################################
109 dnl # Look for a library in a number of places.
111 dnl # FR_SMART_CHECK_LIB(library, function)
113 AC_DEFUN([FR_SMART_CHECK_LIB], [
115 sm_lib_safe=`echo "$1" | sed 'y%./+-%__p_%'`
116 sm_func_safe=`echo "$2" | sed 'y%./+-%__p_%'`
119 dnl # We pass all arguments for linker testing in CCPFLAGS as these
120 dnl # will be passed to the compiler (then linker) first.
122 dnl # The linker will search through -L directories in the order they
123 dnl # appear on the command line. Unfortunately the same rules appear
124 dnl # to apply to directories specified with --sysroot, so we must
125 dnl # pass the user specified directory first.
127 dnl # Really we should be using LDFLAGS (-L<dir>) for this.
130 old_CPPFLAGS="$CPPFLAGS"
136 dnl # Try first any user-specified directory, otherwise we may pick up
137 dnl # the wrong version.
139 if test "x$smart_try_dir" != "x"; then
140 for try in $smart_try_dir; do
141 AC_MSG_CHECKING([for $2 in -l$1 in $try])
142 LIBS="-l$1 $old_LIBS"
143 CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS"
144 AC_TRY_LINK([extern char $2();],
148 smart_ldflags="-L$try -Wl,-rpath,$try"
155 CPPFLAGS="$old_CPPFLAGS"
159 dnl # Try using the default library path
161 if test "x$smart_lib" = "x"; then
162 AC_MSG_CHECKING([for $2 in -l$1])
163 LIBS="-l$1 $old_LIBS"
164 AC_TRY_LINK([extern char $2();],
175 dnl # Try to guess possible locations.
177 if test "x$smart_lib" = "x"; then
178 FR_LOCATE_DIR(smart_lib_dir,[lib$1${libltdl_cv_shlibext}])
179 FR_LOCATE_DIR(smart_lib_dir,[lib$1.a])
181 for try in $smart_lib_dir /usr/local/lib /opt/lib; do
182 AC_MSG_CHECKING([for $2 in -l$1 in $try])
183 LIBS="-l$1 $old_LIBS"
184 CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS"
185 AC_TRY_LINK([extern char $2();],
189 smart_ldflags="-L$try -Wl,-rpath,$try"
196 CPPFLAGS="$old_CPPFLAGS"
200 dnl # Found it, set the appropriate variable.
202 if test "x$smart_lib" != "x"; then
203 eval "ac_cv_lib_${sm_lib_safe}_${sm_func_safe}=yes"
204 LIBS="$smart_ldflags $smart_lib $old_LIBS"
205 SMART_LIBS="$smart_ldflags $smart_lib $SMART_LIBS"
209 dnl #######################################################################
211 dnl # Look for a header file in a number of places.
213 dnl # FR_SMART_CHECK_INCLUDE(foo.h, [ #include <other.h> ])
215 AC_DEFUN([FR_SMART_CHECK_INCLUDE], [
217 ac_safe=`echo "$1" | sed 'y%./+-%__pm%'`
218 old_CPPFLAGS="$CPPFLAGS"
223 dnl # Try first any user-specified directory, otherwise we may pick up
224 dnl # the wrong version.
226 if test "x$smart_try_dir" != "x"; then
227 for try in $smart_try_dir; do
228 AC_MSG_CHECKING([for $1 in $try])
229 CPPFLAGS="-isystem $try $old_CPPFLAGS"
234 smart_include="-isystem $try"
243 CPPFLAGS="$old_CPPFLAGS"
247 dnl # Try using the default includes.
249 if test "x$smart_include" = "x"; then
250 AC_MSG_CHECKING([for $1])
266 dnl # Try to guess possible locations.
268 if test "x$smart_include" = "x"; then
269 FR_LOCATE_DIR(smart_include_dir,$1)
270 for try in $smart_include_dir /usr/local/include /opt/include; do
271 AC_MSG_CHECKING([for $1 in $try])
272 CPPFLAGS="-isystem $try $old_CPPFLAGS"
277 smart_include="-isystem $try"
286 CPPFLAGS="$old_CPPFLAGS"
290 dnl # Found it, set the appropriate variable.
292 if test "x$smart_include" != "x"; then
293 eval "ac_cv_header_$ac_safe=yes"
294 CPPFLAGS="$smart_include $old_CPPFLAGS"
295 SMART_CPPFLAGS="$smart_include $SMART_CPPFLAGS"
299 dnl #######################################################################
301 dnl # Look for a header file in a number of places.
303 dnl # Usage: FR_CHECK_STRUCT_HAS_MEMBER([#include <foo.h>], [struct foo], member)
304 dnl # If the member is defined, then the variable
305 dnl # ac_cv_type_struct_foo_has_member is set to 'yes'
307 AC_DEFUN([FR_CHECK_STRUCT_HAS_MEMBER], [
308 AC_MSG_CHECKING([for $3 in $2])
310 dnl BASED on 'offsetof':
311 dnl #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
320 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
323 [ int foo = offsetof($2, $3) ],
327 ac_safe_type=`echo "$2" | sed 'y% %_%'`
328 if test "x$has_element" != "x"; then
330 eval "ac_cv_type_${ac_safe_type}_has_$3=yes"
333 eval "ac_cv_type_${ac_safe_type}_has_$3="
337 dnl Autoconf 2.61 breaks the support for chained configure scripts
338 dnl in combination with config.cache
339 m4_pushdef([AC_OUTPUT],
341 unset ac_cv_env_LIBS_set
342 unset ac_cv_env_LIBS_value
343 m4_popdef([AC_OUTPUT])
344 AC_OUTPUT([$1],[$2],[$3])
348 dnl # Figure out which storage class specifier for Thread Local Storage is supported by the compiler
353 dnl # See if the compilation works with __thread, for thread-local storage
355 AC_MSG_CHECKING(for __thread support in compiler)
359 static __thread int val;
360 int main(int argc, char **argv) {
365 ],[have_tls=yes],[have_tls=no],[have_tls=no])
366 AC_MSG_RESULT($have_tls)
367 if test "x$have_tls" = "xyes"; then
368 AC_DEFINE([TLS_STORAGE_CLASS],[__thread],[Define if the compiler supports a thread local storage class])
372 dnl # __declspec(thread) does exactly the same thing as __thread, but is supported by MSVS
374 if test "x$have_tls" = "xno"; then
375 AC_MSG_CHECKING(for __declspec(thread) support in compiler)
379 static _Thread_local int val;
380 int main(int argc, char **argv) {
385 ],[have_tls=yes],[have_tls=no],[have_tls=no])
386 AC_MSG_RESULT($have_tls)
387 if test "x$have_tls" = "xyes"; then
388 AC_DEFINE([TLS_STORAGE_CLASS],[__declspec(thread)],[Define if the compiler supports a thread local storage class])
392 dnl # _Thread_local does exactly the same thing as __thread, but it's standards compliant with C11.
393 dnl # we, however, state we are only compliant with C99, so the compiler will probably emit warnings
394 dnl # if we use it. So save it as a last resort.
396 if test "x$have_tls" = "xno"; then
397 AC_MSG_CHECKING(for _Thread_local support in compiler)
401 static _Thread_local int val;
402 int main(int argc, char **argv) {
407 ],[have_tls=yes],[have_tls=no],[have_tls=no])
408 AC_MSG_RESULT($have_tls)
409 if test "x$have_tls" = "xyes"; then
410 AC_DEFINE([TLS_STORAGE_CLASS],[_Thread_local],[Define if the compiler supports a thread local storage class])
415 AC_DEFUN([VL_LIB_READLINE], [
416 AC_CACHE_CHECK([for a readline compatible library],
417 vl_cv_lib_readline, [
419 for readline_lib in readline edit editline; do
420 for termcap_lib in "" termcap curses ncurses; do
421 if test -z "$termcap_lib"; then
422 TRY_LIB="-l$readline_lib"
424 TRY_LIB="-l$readline_lib -l$termcap_lib"
426 LIBS="$ORIG_LIBS $TRY_LIB"
427 AC_TRY_LINK_FUNC(readline, vl_cv_lib_readline="$TRY_LIB")
428 if test -n "$vl_cv_lib_readline"; then
432 if test -n "$vl_cv_lib_readline"; then
436 if test -z "$vl_cv_lib_readline"; then
437 vl_cv_lib_readline="no"
442 if test "$vl_cv_lib_readline" != "no"; then
443 LIBREADLINE="$vl_cv_lib_readline"
444 AC_DEFINE(HAVE_LIBREADLINE, 1,
445 [Define if you have a readline compatible library])
446 AC_CHECK_HEADERS(readline.h readline/readline.h)
447 AC_CACHE_CHECK([whether readline supports history],
448 [vl_cv_lib_readline_history], [
449 vl_cv_lib_readline_history="no"
450 AC_TRY_LINK_FUNC([add_history], [vl_cv_lib_readline_history="yes"])
452 if test "$vl_cv_lib_readline_history" = "yes"; then
453 AC_DEFINE(HAVE_READLINE_HISTORY, 1,
454 [Define if your readline library has \`add_history'])
455 AC_CHECK_HEADERS(history.h readline/history.h)
458 AC_SUBST(LIBREADLINE)
462 dnl # Check if we have the choose expr builtin
464 AC_DEFUN([FR_HAVE_BUILTIN_CHOOSE_EXPR],
466 AC_MSG_CHECKING(for __builtin_choose_expr support in compiler)
470 int main(int argc, char **argv) {
471 return __builtin_choose_expr(0, 1, 0);
474 ],[have_builtin_choose_expr=yes],[have_builtin_choose_expr=no],[have_builtin_choose_expr=no])
475 AC_MSG_RESULT($have_builtin_choose_expr)
476 if test "x$have_builtin_choose_expr" = "xyes"; then
477 AC_DEFINE([HAVE_BUILTIN_CHOOSE_EXPR],1,[Define if the compiler supports __builtin_choose_expr])
482 dnl # Check if we have the types compatible p builtin
484 AC_DEFUN([FR_HAVE_BUILTIN_TYPES_COMPATIBLE_P],
486 AC_MSG_CHECKING(for __builtin_types_compatible_p support in compiler)
490 int main(int argc, char **argv) {
491 return !(__builtin_types_compatible_p(char *, char *));
494 ],[have_builtin_types_compatible_p=yes],[have_builtin_types_compatible_p=no],[have_builtin_types_compatible_p=no])
495 AC_MSG_RESULT($have_builtin_types_compatible_p)
496 if test "x$have_builtin_types_compatible_p" = "xyes"; then
497 AC_DEFINE([HAVE_BUILTIN_TYPES_COMPATIBLE_P],1,[Define if the compiler supports __builtin_types_compatible_p])
502 dnl # Check if we have the bwsap64 builtin
504 AC_DEFUN([FR_HAVE_BUILTIN_BSWAP_64],
507 dnl # See if the compilation works with __thread, for thread-local storage
509 AC_MSG_CHECKING(for __builtin_bswap64 support in compiler)
513 int main(int argc, char **argv) {
514 return (__builtin_bswap64(0));
517 ],[have_builtin_bswap64=yes],[have_builtin_bswap64=no],[have_builtin_bswap64=no])
518 AC_MSG_RESULT($have_builtin_bswap64)
519 if test "x$have_builtin_bswap64" = "xyes"; then
520 AC_DEFINE([HAVE_BUILTIN_BSWAP_64],1,[Define if the compiler supports __builtin_types_compatible_p])
524 AC_INCLUDE(aclocal.m4)