db.m4 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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, [ --with-db=PATH Berkeley DB directory],
  24. [
  25. if test "$withval" = "yes"; then
  26. AC_MSG_RESULT(yes)
  27. dnl - check in system locations
  28. if test -f "/usr/include/db.h"; then
  29. db_incdir="/usr/include"
  30. db_inc="-I/usr/include"
  31. db_lib='-L$(libdir)'
  32. db_libdir='$(libdir)'
  33. else
  34. AC_MSG_ERROR([db.h not found])
  35. fi
  36. elif test -d "$withval"/include -a -d "$withval"/lib; then
  37. AC_MSG_RESULT([using $withval])
  38. dnl - check the user provided location
  39. DBDIR=$withval
  40. db_lib="-L$DBDIR/lib"
  41. db_libdir="$DBDIR/lib"
  42. db_incdir="$DBDIR/include"
  43. if ! test -e "$db_incdir/db.h" ; then
  44. AC_MSG_ERROR([$withval include dir not found])
  45. fi
  46. db_inc="-I$db_incdir"
  47. else
  48. echo
  49. AC_MSG_ERROR([$withval not found])
  50. fi
  51. ],
  52. AC_MSG_RESULT(no))
  53. dnl default path for the db tools (see [210947] for more details)
  54. dnl - check in system locations
  55. if test -z "$db_inc"; then
  56. AC_MSG_CHECKING(for db.h)
  57. if test -f "/usr/include/db.h"; then
  58. AC_MSG_RESULT([using /usr/include/db.h])
  59. db_incdir="/usr/include"
  60. db_inc="-I/usr/include"
  61. db_lib='-L$(libdir)'
  62. db_libdir='$(libdir)'
  63. else
  64. AC_MSG_RESULT(no)
  65. AC_MSG_ERROR([db not found, specify with --with-db.])
  66. fi
  67. fi
  68. dnl figure out which version of db we're using from the header file
  69. db_ver_maj=`grep DB_VERSION_MAJOR $db_incdir/db.h | awk '{print $3}'`
  70. db_ver_min=`grep DB_VERSION_MINOR $db_incdir/db.h | awk '{print $3}'`
  71. db_ver_pat=`grep DB_VERSION_PATCH $db_incdir/db.h | awk '{print $3}'`
  72. dnl libname is libdb-maj.min e.g. libdb-4.2
  73. db_libver=${db_ver_maj}.${db_ver_min}
  74. dnl make sure the lib is available
  75. dnl use true so libdb won't be added to LIBS
  76. save_ldflags="$LDFLAGS"
  77. LDFLAGS="$db_lib $LDFLAGS"
  78. AC_CHECK_LIB([db-$db_libver], [db_create], [true],
  79. [AC_MSG_ERROR([$db_incdir/db.h is version $db_libver but libdb-$db_libver not found])],
  80. [$LIBNSL])
  81. LDFLAGS="$save_ldflags"
  82. # if DB is not found yet, try pkg-config
  83. # last resort
  84. # Although the other db_* variables are correctly assigned at this point,
  85. # db_bindir needs to be set by pkg-config if possible (e.g., on 64-bit Solaris)
  86. if test -n "$PKG_CONFIG"; then
  87. if $PKG_CONFIG --exists db; then
  88. db_bindir=`$PKG_CONFIG --variable=bindir db`
  89. else
  90. db_bindir=/usr/bin
  91. fi
  92. else
  93. db_bindir=/usr/bin
  94. fi