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.

182 lines
6.0KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_lib_mysqlcppconn.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_LIB_MYSQLCPPCONN([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Test for the MySQL Connector/C++ libraries
  12. #
  13. # If no path to the installed library is given the macro searches under
  14. # /usr, /usr/local, /opt and /opt/local.
  15. #
  16. # This macro calls:
  17. #
  18. # AC_SUBST(LIBMYSQLCPPCONN_CXXFLAGS) / AC_SUBST(LIBMYSQLCPPCONN_LDFLAGS)
  19. #
  20. # And sets:
  21. #
  22. # HAVE_LIBMYSQLCPPCONN
  23. #
  24. # Note that this library needs to link with either MySQL client library or
  25. # MySQL Connector/C to work. The macros defined here don't take care of
  26. # external dependencies so you have to do it on your own. See also
  27. # AX_LIB_MYSQL macro.
  28. #
  29. # LICENSE
  30. #
  31. # Copyright (c) 2011 Xiyue Deng <manphiz@gmail.com>
  32. #
  33. # Copying and distribution of this file, with or without modification, are
  34. # permitted in any medium without royalty provided the copyright notice
  35. # and this notice are preserved. This file is offered as-is, without any
  36. # warranty.
  37. #serial 3
  38. AC_DEFUN([AX_LIB_MYSQLCPPCONN],
  39. [
  40. AC_ARG_WITH([libmysqlcppconn],
  41. [AS_HELP_STRING([--with-libmysqlcppconn@<:@=ARG@:>@],
  42. [use libmysqlcppconn from a standard location (ARG=yes),
  43. from the specified location (ARG=<path>),
  44. or disable if (ARG=no)
  45. @<:@ARG=yes@:>@ ])],
  46. [
  47. if test "x$withval" = "xno"; then
  48. want_libmysqlcppconn="no"
  49. elif test "x$withval" = "xyes"; then
  50. want_libmysqlcppconn="yes"
  51. else
  52. want_libmysqlcppconn="yes"
  53. ac_libmysqlcppconn_path="$withval"
  54. fi
  55. ],
  56. [want_libmysqlcppconn="yes"])
  57. AC_ARG_WITH([libmysqlcppconn-include],
  58. [AS_HELP_STRING([--with-libmysqlcppconn-include=INCLUDE_DIR],
  59. [Force given directory for libmysqlcppconn include path. Note that this will overwrite general library path setting.])
  60. ], [
  61. if test -d "$withval"; then
  62. ac_libmysqlcppconn_include_path="$withval"
  63. else
  64. AC_MSG_ERROR([--with-libmysqlcppconn-include expected directory name])
  65. fi
  66. ],
  67. [ac_libmysqlcppconn_include_path=""]
  68. )
  69. AC_ARG_WITH([libmysqlcppconn-lib],
  70. [AS_HELP_STRING([--with-libmysqlcppconn-lib=LIB_DIR],
  71. [Force given directory for libmysqlcppconn libraries. Note that this will overwrite general library path setting.])
  72. ], [
  73. if test -d "$withval"; then
  74. ac_libmysqlcppconn_lib_path="$withval"
  75. else
  76. AC_MSG_ERROR([--with-libmysqlcppconn-lib expected directory name])
  77. fi
  78. ],
  79. [ac_libmysqlcppconn_lib_path=""]
  80. )
  81. if test "x$want_libmysqlcppconn" = "xyes"; then
  82. succeeded=no
  83. dnl On x86_64 systems check for system libraries in both lib64 and lib.
  84. dnl The former is specified by FHS, but e.g. Debian does not adhere to
  85. dnl this (as it rises problems for generic multi-arch support).
  86. dnl The last entry in the list is chosen by default when no libraries
  87. dnl are found, e.g. when only header-only libraries are installed!
  88. libsubdirs="lib"
  89. if test `uname -m` = x86_64; then
  90. libsubdirs="lib lib64"
  91. fi
  92. if test "x$ac_libmysqlcppconn_path" != "x"; then
  93. for libsubdir in $libsubdirs ; do
  94. if ls "$ac_libmysqlcppconn_path/$libsubdir/libmysqlcppconn"* >/dev/null 2>&1 ; then
  95. LIBMYSQLCPPCONN_LDFLAGS="-L$ac_libmysqlcppconn_path/$libsubdir"
  96. LIBMYSQLCPPCONN_CXXFLAGS="-I$ac_libmysqlcppconn_path/include"
  97. break;
  98. fi
  99. done
  100. elif test "x$cross_compiling" != yes; then
  101. for ac_libmysqlcppconn_path_tmp in /usr /usr/local /opt /opt/local ; do
  102. for libsubdir in $libsubdirs ; do
  103. if ls "$ac_libmysqlcppconn_path_tmp/$libsubdir/libmysqlcppconn"* >/dev/null 2>&1 ; then
  104. LIBMYSQLCPPCONN_LDFLAGS="-L$ac_libmysqlcppconn_path_tmp/$libsubdir"
  105. LIBMYSQLCPPCONN_CXXFLAGS="-I$ac_libmysqlcppconn_path_tmp/include"
  106. break;
  107. fi
  108. done
  109. done
  110. fi
  111. if test "x$ac_libmysqlcppconn_include_path" != "x" ; then
  112. LIBMYSQLCPPCONN_CXXFLAGS="-I$ac_libmysqlcppconn_include_path"
  113. fi
  114. if test "x$ac_libmysqlcppconn_lib_path" != "x" ; then
  115. LIBMYSQLCPPCONN_LDFLAGS="-L$ac_libmysqlcppconn_lib_path"
  116. fi
  117. CXXFLAGS_SAVED="$CXXFLAGS"
  118. CXXFLAGS="$CXXFLAGS $LIBMYSQLCPPCONN_CXXFLAGS"
  119. export CXXFLAGS
  120. CPPFLAGS_SAVED="$CPPFLAGS"
  121. CPPFLAGS="$CPPFLAGS $LIBMYSQLCPPCONN_CXXFLAGS"
  122. export CPPFLAGS
  123. LDFLAGS_SAVED="$LDFLAGS"
  124. LDFLAGS="$LDFLAGS $LIBMYSQLCPPCONN_LDFLAGS"
  125. export LDFLAGS
  126. AC_LANG_PUSH([C++])
  127. AC_CHECK_HEADERS([mysql_connection.h mysql_driver.h], [
  128. ax_cv_libmysqlcppconn_version_check=yes
  129. ], [
  130. ax_cv_libmysqlcppconn_version_check=no
  131. ]
  132. )
  133. AS_IF([test "x$ax_cv_libmysqlcppconn_version_check" != "xyes"], [
  134. AC_MSG_ERROR([Could not find working libmysqlcppconn $libmysqlcppconn_version_req installation.])
  135. ])
  136. AC_CHECK_LIB([mysqlcppconn], [main], [
  137. LIBMYSQLCPPCONN_LDFLAGS="$LIBMYSQLCPPCONN_LDFLAGS -lmysqlcppconn"
  138. succeeded=yes
  139. ], [
  140. AC_MSG_ERROR([Could not find working libmysqlcppconn library.])
  141. ax_cv_libmysqlcppconn_link=no
  142. ])
  143. if test "x$succeeded" = "xyes"; then
  144. AC_SUBST(LIBMYSQLCPPCONN_CXXFLAGS)
  145. AC_SUBST(LIBMYSQLCPPCONN_LDFLAGS)
  146. AC_DEFINE(HAVE_LIBMYSQLCPPCONN, , [define if libmysqlcppconn is available])
  147. ifelse([$1], , :, [$1])
  148. else
  149. AC_MSG_NOTICE([[Could not detect the libmysqlcppconn installation. Please make sure you have a working libmysqlcppconn installation and specify its path with --with-libmysqlcppconn option.]])
  150. ifelse([$2], , :, [$2])
  151. fi
  152. CXXFLAGS="$CXXFLAGS_SAVED"
  153. export CXXFLAGS
  154. CPPFLAGS="$CPPFLAGS_SAVED"
  155. export CPPFLAGS
  156. LDFLAGS="$LDFLAGS_SAVED"
  157. export LDFLAGS
  158. fi
  159. ])