x_ac_databases.m4 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. ##*****************************************************************************
  2. # AUTHOR:
  3. # Danny Auble <da@llnl.gov>
  4. #
  5. # SYNOPSIS:
  6. # X_AC_DATABASES
  7. #
  8. # DESCRIPTION:
  9. # Test for Different Database apis. If found define appropriate ENVs.
  10. ##*****************************************************************************
  11. AC_DEFUN([X_AC_DATABASES],
  12. [
  13. #Check for MySQL
  14. ac_have_mysql="no"
  15. _x_ac_mysql_bin="no"
  16. ### Check for mysql_config program
  17. AC_ARG_WITH(
  18. [mysql_config],
  19. AS_HELP_STRING(--with-mysql_config=PATH,
  20. Specify path of directory where mysql_config binary exists),
  21. [_x_ac_mysql_bin="$withval"])
  22. if test x$_x_ac_mysql_bin = xno; then
  23. AC_PATH_PROG(HAVEMYSQLCONFIG, mysql_config, no)
  24. else
  25. AC_PATH_PROG(HAVEMYSQLCONFIG, mysql_config, no, $_x_ac_mysql_bin)
  26. fi
  27. if test x$HAVEMYSQLCONFIG = xno; then
  28. AC_MSG_WARN([*** mysql_config not found. Evidently no MySQL development libs installed on system.])
  29. else
  30. # check for mysql-5.0.0+
  31. mysql_config_major_version=`$HAVEMYSQLCONFIG --version | \
  32. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[a-zA-Z0-9]]*\)/\1/'`
  33. mysql_config_minor_version=`$HAVEMYSQLCONFIG --version | \
  34. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[a-zA-Z0-9]]*\)/\2/'`
  35. mysql_config_micro_version=`$HAVEMYSQLCONFIG --version | \
  36. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[a-zA-Z0-9]]*\)/\3/'`
  37. if test $mysql_config_major_version -lt 5; then
  38. AC_MSG_WARN([*** mysql-$mysql_config_major_version.$mysql_config_minor_version.$mysql_config_micro_version available, we need >= mysql-5.0.0 installed for the mysql interface.])
  39. ac_have_mysql="no"
  40. else
  41. # In mysql 5.7.4 we can't use the 'IGNORE' option when
  42. # altering tables so deal with it then.
  43. if test $mysql_config_major_version -ge 6 ||
  44. test $mysql_config_minor_version -gt 7 ||
  45. (test $mysql_config_minor_version -eq 7 &&
  46. test $mysql_config_micro_version -ge 4); then
  47. AC_DEFINE(NO_ALTER_IGNORE_MYSQL, 1, [Define to 1 if we can't use the alter ignore when messing with a database table])
  48. fi
  49. # mysql_config puts -I on the front of the dir. We don't
  50. # want that so we remove it.
  51. MYSQL_CFLAGS=`$HAVEMYSQLCONFIG --include`
  52. MYSQL_LIBS=`$HAVEMYSQLCONFIG --libs_r`
  53. save_CFLAGS="$CFLAGS"
  54. save_LIBS="$LIBS"
  55. CFLAGS="$MYSQL_CFLAGS $save_CFLAGS"
  56. LIBS="$MYSQL_LIBS $save_LIBS"
  57. AC_TRY_LINK([#include <mysql.h>],[
  58. MYSQL mysql;
  59. (void) mysql_init(&mysql);
  60. (void) mysql_close(&mysql);
  61. ],
  62. [ac_have_mysql="yes"],
  63. [ac_have_mysql="no"])
  64. CFLAGS="$save_CFLAGS"
  65. LIBS="$save_LIBS"
  66. if test "$ac_have_mysql" = yes; then
  67. AC_MSG_RESULT([MySQL $mysql_config_major_version.$mysql_config_minor_version.$mysql_config_micro_version test program built properly.])
  68. AC_SUBST(MYSQL_LIBS)
  69. AC_SUBST(MYSQL_CFLAGS)
  70. AC_DEFINE(HAVE_MYSQL, 1, [Define to 1 if using MySQL libaries])
  71. else
  72. MYSQL_CFLAGS=`$HAVEMYSQLCONFIG --include`
  73. MYSQL_LIBS=`$HAVEMYSQLCONFIG --libs`
  74. save_CFLAGS="$CFLAGS"
  75. save_LIBS="$LIBS"
  76. CFLAGS="$MYSQL_CFLAGS $save_CFLAGS"
  77. LIBS="$MYSQL_LIBS $save_LIBS"
  78. AC_TRY_LINK([#include <mysql.h>],[
  79. MYSQL mysql;
  80. (void) mysql_init(&mysql);
  81. (void) mysql_close(&mysql);
  82. ],
  83. [ac_have_mysql="yes"],
  84. [ac_have_mysql="no"])
  85. CFLAGS="$save_CFLAGS"
  86. LIBS="$save_LIBS"
  87. if test "$ac_have_mysql" = yes; then
  88. AC_MSG_RESULT([MySQL (non-threaded) test program built properly.])
  89. AC_SUBST(MYSQL_LIBS)
  90. AC_SUBST(MYSQL_CFLAGS)
  91. AC_DEFINE(MYSQL_NOT_THREAD_SAFE, 1, [Define to 1 if with non thread-safe code])
  92. AC_DEFINE(HAVE_MYSQL, 1, [Define to 1 if using MySQL libaries])
  93. else
  94. MYSQL_CFLAGS=""
  95. MYSQL_LIBS=""
  96. AC_MSG_WARN([*** MySQL test program execution failed.])
  97. fi
  98. fi
  99. fi
  100. fi
  101. AM_CONDITIONAL(WITH_MYSQL, test x"$ac_have_mysql" = x"yes")
  102. ])