2
0

ax_lib_mysql.m4 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. ##### http://autoconf-archive.cryp.to/ax_lib_mysql.html
  2. #
  3. # SYNOPSIS
  4. #
  5. # AX_LIB_MYSQL([MINIMUM-VERSION])
  6. #
  7. # DESCRIPTION
  8. #
  9. # This macro provides tests of availability of MySQL client library
  10. # of particular version or newer.
  11. #
  12. # AX_LIB_MYSQL macro takes only one argument which is optional. If
  13. # there is no required version passed, then macro does not run
  14. # version test.
  15. #
  16. # The --with-mysql option takes one of three possible values:
  17. #
  18. # no - do not check for MySQL client library
  19. #
  20. # yes - do check for MySQL library in standard locations
  21. # (mysql_config should be in the PATH)
  22. #
  23. # path - complete path to mysql_config utility, use this option if
  24. # mysql_config can't be found in the PATH
  25. #
  26. # This macro calls:
  27. #
  28. # AC_SUBST(MYSQL_CFLAGS)
  29. # AC_SUBST(MYSQL_LDFLAGS)
  30. # AC_SUBST(MYSQL_VERSION)
  31. #
  32. # And sets:
  33. #
  34. # HAVE_MYSQL
  35. #
  36. # LAST MODIFICATION
  37. #
  38. # 2006-07-16
  39. #
  40. # COPYLEFT
  41. #
  42. # Copyright (c) 2006 Mateusz Loskot <mateusz@loskot.net>
  43. #
  44. # Copying and distribution of this file, with or without
  45. # modification, are permitted in any medium without royalty provided
  46. # the copyright notice and this notice are preserved.
  47. AC_DEFUN([AX_LIB_MYSQL],
  48. [
  49. AC_ARG_WITH([mysql],
  50. AC_HELP_STRING([--with-mysql=@<:@ARG@:>@],
  51. [use MySQL client library @<:@default=yes@:>@, optionally specify path to mysql_config]
  52. ),
  53. [
  54. if test "$withval" = "no"; then
  55. want_mysql="no"
  56. elif test "$withval" = "yes"; then
  57. want_mysql="yes"
  58. else
  59. want_mysql="yes"
  60. MYSQL_CONFIG="$withval"
  61. fi
  62. ],
  63. [want_mysql="yes"]
  64. )
  65. MYSQL_CFLAGS=""
  66. MYSQL_LDFLAGS=""
  67. MYSQL_VERSION=""
  68. dnl
  69. dnl Check MySQL libraries (libpq)
  70. dnl
  71. if test "$want_mysql" = "yes"; then
  72. if test -z "$MYSQL_CONFIG" -o test; then
  73. AC_PATH_PROG([MYSQL_CONFIG], [mysql_config], [no])
  74. fi
  75. if test "$MYSQL_CONFIG" != "no"; then
  76. AC_MSG_CHECKING([for MySQL libraries])
  77. MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
  78. MYSQL_LDFLAGS="`$MYSQL_CONFIG --libs_r`"
  79. MYSQL_VERSION=`$MYSQL_CONFIG --version`
  80. AC_DEFINE([HAVE_MYSQL], [1],
  81. [Define to 1 if MySQL libraries are available])
  82. found_mysql="yes"
  83. AC_MSG_RESULT([yes])
  84. else
  85. found_mysql="no"
  86. AC_MSG_RESULT([no])
  87. fi
  88. fi
  89. dnl
  90. dnl Check if required version of MySQL is available
  91. dnl
  92. mysql_version_req=ifelse([$1], [], [], [$1])
  93. if test "$found_mysql" = "yes" -a -n "$mysql_version_req"; then
  94. AC_MSG_CHECKING([if MySQL version is >= $mysql_version_req])
  95. dnl Decompose required version string of MySQL
  96. dnl and calculate its number representation
  97. mysql_version_req_major=`expr $mysql_version_req : '\([[0-9]]*\)'`
  98. mysql_version_req_minor=`expr $mysql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
  99. mysql_version_req_micro=`expr $mysql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
  100. if test "x$mysql_version_req_micro" = "x"; then
  101. mysql_version_req_micro="0"
  102. fi
  103. mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
  104. \+ $mysql_version_req_minor \* 1000 \
  105. \+ $mysql_version_req_micro`
  106. dnl Decompose version string of installed MySQL
  107. dnl and calculate its number representation
  108. mysql_version_major=`expr $MYSQL_VERSION : '\([[0-9]]*\)'`
  109. mysql_version_minor=`expr $MYSQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
  110. mysql_version_micro=`expr $MYSQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
  111. if test "x$mysql_version_micro" = "x"; then
  112. mysql_version_micro="0"
  113. fi
  114. mysql_version_number=`expr $mysql_version_major \* 1000000 \
  115. \+ $mysql_version_minor \* 1000 \
  116. \+ $mysql_version_micro`
  117. mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
  118. if test "$mysql_version_check" = "1"; then
  119. AC_MSG_RESULT([yes])
  120. else
  121. AC_MSG_RESULT([no])
  122. fi
  123. fi
  124. AC_SUBST([MYSQL_VERSION])
  125. AC_SUBST([MYSQL_CFLAGS])
  126. AC_SUBST([MYSQL_LDFLAGS])
  127. ])