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.

153 lines
5.2KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_berkeley_db_cxx.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_BERKELEY_DB_CXX([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro tries to find Berkeley DB C++ support. It honors
  12. # MINIMUM-VERSION if given.
  13. #
  14. # If libdb_cxx is found, DB_CXX_HEADER and DB_CXX_LIBS variables are set
  15. # and ACTION-IF-FOUND shell code is executed if specified. DB_CXX_HEADER
  16. # is set to location of db.h header in quotes (e.g. "db3/db_cxx.h") and
  17. # AC_DEFINE_UNQUOTED is called on it, so that you can type
  18. #
  19. # #include DB_CXX_HEADER
  20. #
  21. # in your C/C++ code. DB_CXX_LIBS is set to linker flags needed to link
  22. # against the library (e.g. -ldb3.1_cxx) and AC_SUBST is called on it.
  23. #
  24. # when specified user-selected spot (via --with-libdb) also sets
  25. #
  26. # DB_CXX_CPPFLAGS to the include directives required
  27. # DB_CXX_LDFLAGS to the -L flags required
  28. #
  29. # LICENSE
  30. #
  31. # Copyright (c) 2008 Vaclav Slavik <vaclav.slavik@matfyz.cz>
  32. # Copyright (c) 2011 Stephan Suerken <absurd@debian.org>
  33. # Copyright (c) 2014 Kirill A. Korinskiy <catap@catap.ru>
  34. #
  35. # Copying and distribution of this file, with or without modification, are
  36. # permitted in any medium without royalty provided the copyright notice
  37. # and this notice are preserved. This file is offered as-is, without any
  38. # warranty.
  39. #serial 6
  40. AC_DEFUN([AX_BERKELEY_DB_CXX],
  41. [
  42. AC_LANG_ASSERT(C++)
  43. old_LIBS="$LIBS"
  44. old_LDFLAGS="$LDFLAGS"
  45. old_CPPFLAGS="$CPPFLAGS"
  46. libdbdir=""
  47. AC_ARG_WITH(libdb,
  48. AS_HELP_STRING([--with-libdb=DIR],
  49. [root of the Berkeley DB directory]),
  50. [
  51. case "$withval" in
  52. "" | y | ye | yes | n | no)
  53. AC_MSG_ERROR([Invalid --with-libdb value])
  54. ;;
  55. *) libdbdir="$withval"
  56. ;;
  57. esac
  58. ], [])
  59. minversion=ifelse([$1], ,,$1)
  60. DB_CXX_HEADER=""
  61. DB_CXX_LIBS=""
  62. DB_CXX_LDFLAGS=""
  63. DB_CXX_CPPFLAGS=""
  64. if test -z $minversion ; then
  65. minvermajor=0
  66. minverminor=0
  67. minverpatch=0
  68. AC_MSG_CHECKING([for Berkeley DB (C++)])
  69. else
  70. minvermajor=`echo $minversion | cut -d. -f1`
  71. minverminor=`echo $minversion | cut -d. -f2 -s`
  72. minverpatch=`echo $minversion | cut -d. -f3 -s`
  73. if test -z "$minvermajor"; then minvermajor=0; fi
  74. if test -z "$minverminor"; then minverminor=0; fi
  75. if test -z "$minverpatch"; then minverpatch=0; fi
  76. AC_MSG_CHECKING([for Berkeley DB (C++) >= $minvermajor.$minverminor.$minverpatch])
  77. fi
  78. if test x$libdbdir != x""; then
  79. DB_CXX_CPPFLAGS="-I${libdbdir}/include"
  80. DB_CXX_LDFLAGS="-L${libdbdir}/lib"
  81. LDFLAGS="$DB_CXX_LDFLAGS $old_LDFLAGS"
  82. CPPFLAGS="$DB_CXX_CPPFLAGS $old_CPPFLAGS"
  83. fi
  84. for major in 4; do
  85. for minor in 0 1 2 3 4 5 6 7 8 9; do
  86. for version in "${major}.${minor}" "${major}${minor}"; do
  87. try_libs="-ldb_cxx-${version}%-ldb-${version} -ldb${version}_cxx%-ldb${version}"
  88. try_headers="db${major}.${minor}/db_cxx.h db${major}${minor}/db_cxx.h db${major}/db_cxx.h"
  89. for db_cxx_hdr in $try_headers ; do
  90. for db_cxx_lib in $try_libs; do
  91. db_cxx_lib="$libdbdir `echo "$db_cxx_lib" | sed 's/%/ /g'`"
  92. LIBS="$old_LIBS $db_cxx_lib"
  93. #echo "Trying <$db_cxx_lib> <$db_cxx_hdr>"
  94. if test -z $DB_CXX_HEADER ; then
  95. AC_LINK_IFELSE(
  96. [AC_LANG_PROGRAM(
  97. [
  98. #include <${db_cxx_hdr}>
  99. ],
  100. [
  101. #if !((DB_VERSION_MAJOR > (${minvermajor}) || \
  102. (DB_VERSION_MAJOR == (${minvermajor}) && \
  103. DB_VERSION_MINOR > (${minverminor})) || \
  104. (DB_VERSION_MAJOR == (${minvermajor}) && \
  105. DB_VERSION_MINOR == (${minverminor}) && \
  106. DB_VERSION_PATCH >= (${minverpatch}))))
  107. #error "too old version"
  108. #endif
  109. DB *db;
  110. db_create(&db, NULL, 0);
  111. ])],
  112. [
  113. AC_MSG_RESULT([header $db_cxx_hdr, library $db_cxx_lib])
  114. DB_CXX_HEADER="$db_cxx_hdr"
  115. DB_CXX_LIBS="$db_cxx_lib"
  116. ],
  117. )
  118. fi
  119. done
  120. done
  121. done
  122. done
  123. done
  124. LIBS="$old_LIBS"
  125. LDFLAGS="$old_LDFLAGS"
  126. CPPFLAGS="$old_CPPFLAGS"
  127. if test -z $DB_CXX_HEADER ; then
  128. AC_MSG_RESULT([not found])
  129. DB_CXX_LDFLAGS=""
  130. DB_CXX_CPPFLAGS=""
  131. ifelse([$3], , :, [$3])
  132. else
  133. AC_DEFINE_UNQUOTED(DB_CXX_HEADER, ["$DB_CXX_HEADER"], ["Berkeley DB C++ Header File"])
  134. AC_SUBST(DB_CXX_LIBS)
  135. AC_SUBST(DB_CXX_LDFLAGS)
  136. AC_SUBST(DB_CXX_CPPFLAGS)
  137. ifelse([$2], , :, [$2])
  138. fi
  139. ])