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.

149 lines
4.3KB

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