Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
4.5KB

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