db.m4 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # BEGIN COPYRIGHT BLOCK
  2. # Copyright (C) 2007 Red Hat, Inc.
  3. # All rights reserved.
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. #
  19. # END COPYRIGHT BLOCK
  20. AC_CHECKING(for db)
  21. dnl - check for --with-db
  22. AC_MSG_CHECKING(for --with-db)
  23. AC_ARG_WITH(db, AS_HELP_STRING([--with-db@<:@=PATH@:>@],[Berkeley DB directory]),
  24. [
  25. if test "$withval" = "yes"; then
  26. AC_MSG_RESULT(yes)
  27. elif test "$withval" = "no"; then
  28. AC_MSG_RESULT(no)
  29. AC_MSG_ERROR([db is required.])
  30. elif test -d "$withval"/include -a -d "$withval"/lib; then
  31. AC_MSG_RESULT([using $withval])
  32. dnl - check the user provided location
  33. DBDIR=$withval
  34. db_lib="-L$DBDIR/lib"
  35. db_libdir="$DBDIR/lib"
  36. db_incdir="$DBDIR/include"
  37. if ! test -e "$db_incdir/db.h" ; then
  38. AC_MSG_ERROR([$withval include dir not found])
  39. fi
  40. db_inc="-I$db_incdir"
  41. else
  42. echo
  43. AC_MSG_ERROR([$withval not found])
  44. fi
  45. ],
  46. AC_MSG_RESULT(yes))
  47. dnl default path for the db tools (see [210947] for more details)
  48. # check for --with-db-inc
  49. AC_MSG_CHECKING(for --with-db-inc)
  50. AC_ARG_WITH(db-inc, AS_HELP_STRING([--with-db-inc=PATH],[Berkeley DB include file directory]),
  51. [
  52. if test -e "$withval"/db.h
  53. then
  54. AC_MSG_RESULT([using $withval])
  55. db_incdir="$withval"
  56. db_inc="-I$withval"
  57. else
  58. echo
  59. AC_MSG_ERROR([$withval not found])
  60. fi
  61. ],
  62. AC_MSG_RESULT(no))
  63. # check for --with-db-lib
  64. AC_MSG_CHECKING(for --with-db-lib)
  65. AC_ARG_WITH(db-lib, AS_HELP_STRING([--with-db-lib=PATH],[Berkeley DB library directory]),
  66. [
  67. if test -d "$withval"
  68. then
  69. AC_MSG_RESULT([using $withval])
  70. db_lib="-L$withval"
  71. db_libdir="$withval"
  72. else
  73. echo
  74. AC_MSG_ERROR([$withval not found])
  75. fi
  76. ],
  77. AC_MSG_RESULT(no))
  78. dnl - check in system locations
  79. if test -z "$db_inc"; then
  80. AC_MSG_CHECKING(for db.h)
  81. if test -f "/usr/include/db4/db.h"; then
  82. AC_MSG_RESULT([using /usr/include/db4/db.h])
  83. db_incdir="/usr/include/db4"
  84. db_inc="-I/usr/include/db4"
  85. db_lib='-L$(libdir)'
  86. db_libdir='$(libdir)'
  87. elif test -f "/usr/include/libdb/db.h"; then
  88. AC_MSG_RESULT([using /usr/include/libdb/db.h])
  89. db_incdir="/usr/include/libdb"
  90. db_inc="-I/usr/include/libdb"
  91. db_lib='-L$(libdir)'
  92. db_libdir='$(libdir)'
  93. elif test -f "/usr/include/db.h"; then
  94. AC_MSG_RESULT([using /usr/include/db.h])
  95. db_incdir="/usr/include"
  96. db_inc="-I/usr/include"
  97. db_lib='-L$(libdir)'
  98. db_libdir='$(libdir)'
  99. else
  100. AC_MSG_RESULT(no)
  101. AC_MSG_ERROR([db not found, specify with --with-db.])
  102. fi
  103. fi
  104. dnl figure out which version of db we're using from the header file
  105. db_ver_maj=`grep DB_VERSION_MAJOR $db_incdir/db.h | awk '{print $3}'`
  106. db_ver_min=`grep DB_VERSION_MINOR $db_incdir/db.h | awk '{print $3}'`
  107. db_ver_pat=`grep DB_VERSION_PATCH $db_incdir/db.h | awk '{print $3}'`
  108. dnl libname is libdb-maj.min e.g. libdb-4.2
  109. db_libver=${db_ver_maj}.${db_ver_min}
  110. dnl make sure the lib is available
  111. dnl use true so libdb won't be added to LIBS
  112. save_ldflags="$LDFLAGS"
  113. LDFLAGS="$db_lib $LDFLAGS"
  114. AC_CHECK_LIB([db-$db_libver], [db_create], [true],
  115. [AC_MSG_ERROR([$db_incdir/db.h is version $db_libver but libdb-$db_libver not found])],
  116. [$LIBNSL])
  117. LDFLAGS="$save_ldflags"
  118. # if DB is not found yet, try pkg-config
  119. # last resort
  120. # Although the other db_* variables are correctly assigned at this point,
  121. # db_bindir needs to be set by pkg-config if possible (e.g., on 64-bit Solaris)
  122. if test -n "$PKG_CONFIG"; then
  123. if $PKG_CONFIG --exists db; then
  124. db_bindir=`$PKG_CONFIG --variable=bindir db`
  125. else
  126. db_bindir=/usr/bin
  127. fi
  128. else
  129. db_bindir=/usr/bin
  130. fi