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.

592 lines
21KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_path_bdb.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_PATH_BDB([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro finds the latest version of Berkeley DB on the system, and
  12. # ensures that the header file and library versions match. If
  13. # MINIMUM-VERSION is specified, it will ensure that the library found is
  14. # at least that version.
  15. #
  16. # It determines the name of the library as well as the path to the header
  17. # file and library. It will check both the default environment as well as
  18. # the default Berkeley DB install location. When found, it sets BDB_LIBS,
  19. # BDB_CPPFLAGS, and BDB_LDFLAGS to the necessary values to add to LIBS,
  20. # CPPFLAGS, and LDFLAGS, as well as setting BDB_VERSION to the version
  21. # found. HAVE_DB_H is defined also.
  22. #
  23. # The option --with-bdb-dir=DIR can be used to specify a specific Berkeley
  24. # DB installation to use.
  25. #
  26. # An example of it's use is:
  27. #
  28. # AX_PATH_BDB([3],[
  29. # LIBS="$BDB_LIBS $LIBS"
  30. # LDFLAGS="$BDB_LDFLAGS $LDFLAGS"
  31. # CPPFLAGS="$CPPFLAGS $BDB_CPPFLAGS"
  32. # ])
  33. #
  34. # which will locate the latest version of Berkeley DB on the system, and
  35. # ensure that it is version 3.0 or higher.
  36. #
  37. # Details: This macro does not use either AC_CHECK_HEADERS or AC_CHECK_LIB
  38. # because, first, the functions inside the library are sometimes renamed
  39. # to contain a version code that is only available from the db.h on the
  40. # system, and second, because it is common to have multiple db.h and libdb
  41. # files on a system it is important to make sure the ones being used
  42. # correspond to the same version. Additionally, there are many different
  43. # possible names for libdb when installed by an OS distribution, and these
  44. # need to be checked if db.h does not correspond to libdb.
  45. #
  46. # When cross compiling, only header versions are verified since it would
  47. # be difficult to check the library version. Additionally the default
  48. # Berkeley DB installation locations /usr/local/BerkeleyDB* are not
  49. # searched for higher versions of the library.
  50. #
  51. # The format for the list of library names to search came from the Cyrus
  52. # IMAP distribution, although they are generated dynamically here, and
  53. # only for the version found in db.h.
  54. #
  55. # The macro AX_COMPARE_VERSION is required to use this macro, and should
  56. # be available from the Autoconf Macro Archive.
  57. #
  58. # The author would like to acknowledge the generous and valuable feedback
  59. # from Guido Draheim, without which this macro would be far less robust,
  60. # and have poor and inconsistent cross compilation support.
  61. #
  62. # Changes:
  63. #
  64. # 1/5/05 applied patch from Rafal Rzepecki to eliminate compiler
  65. # warning about unused variable, argv
  66. #
  67. # LICENSE
  68. #
  69. # Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu>
  70. #
  71. # Copying and distribution of this file, with or without modification, are
  72. # permitted in any medium without royalty provided the copyright notice
  73. # and this notice are preserved. This file is offered as-is, without any
  74. # warranty.
  75. #serial 15
  76. dnl #########################################################################
  77. AC_DEFUN([AX_PATH_BDB], [
  78. dnl # Used to indicate success or failure of this function.
  79. ax_path_bdb_ok=no
  80. # Add --with-bdb-dir option to configure.
  81. AC_ARG_WITH([bdb-dir],
  82. [AS_HELP_STRING([--with-bdb-dir=DIR],
  83. [Berkeley DB installation directory])])
  84. # Check if --with-bdb-dir was specified.
  85. if test "x$with_bdb_dir" = "x" ; then
  86. # No option specified, so just search the system.
  87. AX_PATH_BDB_NO_OPTIONS([$1], [HIGHEST], [
  88. ax_path_bdb_ok=yes
  89. ])
  90. else
  91. # Set --with-bdb-dir option.
  92. ax_path_bdb_INC="$with_bdb_dir/include"
  93. ax_path_bdb_LIB="$with_bdb_dir/lib"
  94. dnl # Save previous environment, and modify with new stuff.
  95. ax_path_bdb_save_CPPFLAGS="$CPPFLAGS"
  96. CPPFLAGS="-I$ax_path_bdb_INC $CPPFLAGS"
  97. ax_path_bdb_save_LDFLAGS=$LDFLAGS
  98. LDFLAGS="-L$ax_path_bdb_LIB $LDFLAGS"
  99. # Check for specific header file db.h
  100. AC_MSG_CHECKING([db.h presence in $ax_path_bdb_INC])
  101. if test -f "$ax_path_bdb_INC/db.h" ; then
  102. AC_MSG_RESULT([yes])
  103. # Check for library
  104. AX_PATH_BDB_NO_OPTIONS([$1], [ENVONLY], [
  105. ax_path_bdb_ok=yes
  106. BDB_CPPFLAGS="-I$ax_path_bdb_INC"
  107. BDB_LDFLAGS="-L$ax_path_bdb_LIB"
  108. ])
  109. else
  110. AC_MSG_RESULT([no])
  111. AC_MSG_NOTICE([no usable Berkeley DB not found])
  112. fi
  113. dnl # Restore the environment.
  114. CPPFLAGS="$ax_path_bdb_save_CPPFLAGS"
  115. LDFLAGS="$ax_path_bdb_save_LDFLAGS"
  116. fi
  117. dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND.
  118. if test "$ax_path_bdb_ok" = "yes" ; then
  119. m4_ifvaln([$2],[$2],[:])dnl
  120. m4_ifvaln([$3],[else $3])dnl
  121. fi
  122. ]) dnl AX_PATH_BDB
  123. dnl #########################################################################
  124. dnl Check for berkeley DB of at least MINIMUM-VERSION on system.
  125. dnl
  126. dnl The OPTION argument determines how the checks occur, and can be one of:
  127. dnl
  128. dnl HIGHEST - Check both the environment and the default installation
  129. dnl directories for Berkeley DB and choose the version that
  130. dnl is highest. (default)
  131. dnl ENVFIRST - Check the environment first, and if no satisfactory
  132. dnl library is found there check the default installation
  133. dnl directories for Berkeley DB which is /usr/local/BerkeleyDB*
  134. dnl ENVONLY - Check the current environment only.
  135. dnl
  136. dnl Requires AX_PATH_BDB_PATH_GET_VERSION, AX_PATH_BDB_PATH_FIND_HIGHEST,
  137. dnl AX_PATH_BDB_ENV_CONFIRM_LIB, AX_PATH_BDB_ENV_GET_VERSION, and
  138. dnl AX_COMPARE_VERSION macros.
  139. dnl
  140. dnl Result: sets ax_path_bdb_no_options_ok to yes or no
  141. dnl sets BDB_LIBS, BDB_CPPFLAGS, BDB_LDFLAGS, BDB_VERSION
  142. dnl
  143. dnl AX_PATH_BDB_NO_OPTIONS([MINIMUM-VERSION], [OPTION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  144. AC_DEFUN([AX_PATH_BDB_NO_OPTIONS], [
  145. dnl # Used to indicate success or failure of this function.
  146. ax_path_bdb_no_options_ok=no
  147. # Values to add to environment to use Berkeley DB.
  148. BDB_VERSION=''
  149. BDB_LIBS=''
  150. BDB_CPPFLAGS=''
  151. BDB_LDFLAGS=''
  152. # Check cross compilation here.
  153. if test "x$cross_compiling" = "xyes" ; then
  154. # If cross compiling, can't use AC_RUN_IFELSE so do these tests.
  155. # The AC_PREPROC_IFELSE confirms that db.h is preprocessable,
  156. # and extracts the version number from it.
  157. AC_MSG_CHECKING([for db.h])
  158. AS_VAR_PUSHDEF([HEADER_VERSION],[ax_path_bdb_no_options_HEADER_VERSION])dnl
  159. HEADER_VERSION=''
  160. AC_PREPROC_IFELSE([
  161. AC_LANG_SOURCE([[
  162. #include <db.h>
  163. AX_PATH_BDB_STUFF DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH
  164. ]])
  165. ],[
  166. # Extract version from preprocessor output.
  167. HEADER_VERSION=`eval "$ac_cpp conftest.$ac_ext" 2> /dev/null \
  168. | grep AX_PATH_BDB_STUFF | sed 's/[[^0-9,]]//g;s/,/./g;1q'`
  169. ],[])
  170. if test "x$HEADER_VERSION" = "x" ; then
  171. AC_MSG_RESULT([no])
  172. else
  173. AC_MSG_RESULT([$HEADER_VERSION])
  174. # Check that version is high enough.
  175. AX_COMPARE_VERSION([$HEADER_VERSION],[ge],[$1],[
  176. # get major and minor version numbers
  177. AS_VAR_PUSHDEF([MAJ],[ax_path_bdb_no_options_MAJOR])dnl
  178. MAJ=`echo $HEADER_VERSION | sed 's,\..*,,'`
  179. AS_VAR_PUSHDEF([MIN],[ax_path_bdb_no_options_MINOR])dnl
  180. MIN=`echo $HEADER_VERSION | sed 's,^[[0-9]]*\.,,;s,\.[[0-9]]*$,,'`
  181. dnl # Save LIBS.
  182. ax_path_bdb_no_options_save_LIBS="$LIBS"
  183. # Check that we can link with the library.
  184. AC_SEARCH_LIBS([db_version],
  185. [db db-$MAJ.$MIN db$MAJ.$MIN db$MAJ$MIN db-$MAJ db$MAJ],[
  186. # Successfully found library.
  187. ax_path_bdb_no_options_ok=yes
  188. BDB_VERSION=$HEADER_VERSION
  189. # Extract library from LIBS
  190. ax_path_bdb_no_options_LEN=` \
  191. echo "x$ax_path_bdb_no_options_save_LIBS" \
  192. | awk '{print(length)}'`
  193. BDB_LIBS=`echo "x$LIBS " \
  194. | sed "s/.\{$ax_path_bdb_no_options_LEN\}\$//;s/^x//;s/ //g"`
  195. ],[])
  196. dnl # Restore LIBS
  197. LIBS="$ax_path_bdb_no_options_save_LIBS"
  198. AS_VAR_POPDEF([MAJ])dnl
  199. AS_VAR_POPDEF([MIN])dnl
  200. ])
  201. fi
  202. AS_VAR_POPDEF([HEADER_VERSION])dnl
  203. else
  204. # Not cross compiling.
  205. # Check version of Berkeley DB in the current environment.
  206. AX_PATH_BDB_ENV_GET_VERSION([
  207. AX_COMPARE_VERSION([$ax_path_bdb_env_get_version_VERSION],[ge],[$1],[
  208. # Found acceptable version in current environment.
  209. ax_path_bdb_no_options_ok=yes
  210. BDB_VERSION="$ax_path_bdb_env_get_version_VERSION"
  211. BDB_LIBS="$ax_path_bdb_env_get_version_LIBS"
  212. ])
  213. ])
  214. # Determine if we need to search /usr/local/BerkeleyDB*
  215. ax_path_bdb_no_options_DONE=no
  216. if test "x$2" = "xENVONLY" ; then
  217. ax_path_bdb_no_options_DONE=yes
  218. elif test "x$2" = "xENVFIRST" ; then
  219. ax_path_bdb_no_options_DONE=$ax_path_bdb_no_options_ok
  220. fi
  221. if test "$ax_path_bdb_no_options_DONE" = "no" ; then
  222. # Check for highest in /usr/local/BerkeleyDB*
  223. AX_PATH_BDB_PATH_FIND_HIGHEST([
  224. if test "$ax_path_bdb_no_options_ok" = "yes" ; then
  225. # If we already have an acceptable version use this if higher.
  226. AX_COMPARE_VERSION(
  227. [$ax_path_bdb_path_find_highest_VERSION],[gt],[$BDB_VERSION])
  228. else
  229. # Since we didn't have an acceptable version check if this one is.
  230. AX_COMPARE_VERSION(
  231. [$ax_path_bdb_path_find_highest_VERSION],[ge],[$1])
  232. fi
  233. ])
  234. dnl # If result from _AX_COMPARE_VERSION is true we want this version.
  235. if test "$ax_compare_version" = "true" ; then
  236. ax_path_bdb_no_options_ok=yes
  237. BDB_LIBS="-ldb"
  238. if test "x$ax_path_bdb_path_find_highest_DIR" != x ; then
  239. BDB_CPPFLAGS="-I$ax_path_bdb_path_find_highest_DIR/include"
  240. BDB_LDFLAGS="-L$ax_path_bdb_path_find_highest_DIR/lib"
  241. fi
  242. BDB_VERSION="$ax_path_bdb_path_find_highest_VERSION"
  243. fi
  244. fi
  245. fi
  246. dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND.
  247. if test "$ax_path_bdb_no_options_ok" = "yes" ; then
  248. AC_MSG_NOTICE([using Berkeley DB version $BDB_VERSION])
  249. AC_DEFINE([HAVE_DB_H],[1],
  250. [Define to 1 if you have the <db.h> header file.])
  251. m4_ifvaln([$3],[$3])dnl
  252. else
  253. AC_MSG_NOTICE([no Berkeley DB version $1 or higher found])
  254. m4_ifvaln([$4],[$4])dnl
  255. fi
  256. ]) dnl AX_PATH_BDB_NO_OPTIONS
  257. dnl #########################################################################
  258. dnl Check the default installation directory for Berkeley DB which is
  259. dnl of the form /usr/local/BerkeleyDB* for the highest version.
  260. dnl
  261. dnl Result: sets ax_path_bdb_path_find_highest_ok to yes or no,
  262. dnl sets ax_path_bdb_path_find_highest_VERSION to version,
  263. dnl sets ax_path_bdb_path_find_highest_DIR to directory.
  264. dnl
  265. dnl AX_PATH_BDB_PATH_FIND_HIGHEST([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  266. AC_DEFUN([AX_PATH_BDB_PATH_FIND_HIGHEST], [
  267. dnl # Used to indicate success or failure of this function.
  268. ax_path_bdb_path_find_highest_ok=no
  269. AS_VAR_PUSHDEF([VERSION],[ax_path_bdb_path_find_highest_VERSION])dnl
  270. VERSION=''
  271. ax_path_bdb_path_find_highest_DIR=''
  272. # find highest version in default install directory for Berkeley DB
  273. AS_VAR_PUSHDEF([CURDIR],[ax_path_bdb_path_find_highest_CURDIR])dnl
  274. AS_VAR_PUSHDEF([CUR_VERSION],[ax_path_bdb_path_get_version_VERSION])dnl
  275. for CURDIR in `ls -d /usr/local/BerkeleyDB* 2> /dev/null`
  276. do
  277. AX_PATH_BDB_PATH_GET_VERSION([$CURDIR],[
  278. AX_COMPARE_VERSION([$CUR_VERSION],[gt],[$VERSION],[
  279. ax_path_bdb_path_find_highest_ok=yes
  280. ax_path_bdb_path_find_highest_DIR="$CURDIR"
  281. VERSION="$CUR_VERSION"
  282. ])
  283. ])
  284. done
  285. AS_VAR_POPDEF([VERSION])dnl
  286. AS_VAR_POPDEF([CUR_VERSION])dnl
  287. AS_VAR_POPDEF([CURDIR])dnl
  288. dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND.
  289. if test "$ax_path_bdb_path_find_highest_ok" = "yes" ; then
  290. m4_ifvaln([$1],[$1],[:])dnl
  291. m4_ifvaln([$2],[else $2])dnl
  292. fi
  293. ]) dnl AX_PATH_BDB_PATH_FIND_HIGHEST
  294. dnl #########################################################################
  295. dnl Checks for Berkeley DB in specified directory's lib and include
  296. dnl subdirectories.
  297. dnl
  298. dnl Result: sets ax_path_bdb_path_get_version_ok to yes or no,
  299. dnl sets ax_path_bdb_path_get_version_VERSION to version.
  300. dnl
  301. dnl AX_PATH_BDB_PATH_GET_VERSION(BDB-DIR, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  302. AC_DEFUN([AX_PATH_BDB_PATH_GET_VERSION], [
  303. dnl # Used to indicate success or failure of this function.
  304. ax_path_bdb_path_get_version_ok=no
  305. # Indicate status of checking for Berkeley DB header.
  306. AC_MSG_CHECKING([in $1/include for db.h])
  307. ax_path_bdb_path_get_version_got_header=no
  308. test -f "$1/include/db.h" && ax_path_bdb_path_get_version_got_header=yes
  309. AC_MSG_RESULT([$ax_path_bdb_path_get_version_got_header])
  310. # Indicate status of checking for Berkeley DB library.
  311. AC_MSG_CHECKING([in $1/lib for library -ldb])
  312. ax_path_bdb_path_get_version_VERSION=''
  313. if test -d "$1/include" && test -d "$1/lib" &&
  314. test "$ax_path_bdb_path_get_version_got_header" = "yes" ; then
  315. dnl # save and modify environment
  316. ax_path_bdb_path_get_version_save_CPPFLAGS="$CPPFLAGS"
  317. CPPFLAGS="-I$1/include $CPPFLAGS"
  318. ax_path_bdb_path_get_version_save_LIBS="$LIBS"
  319. LIBS="$LIBS -ldb"
  320. ax_path_bdb_path_get_version_save_LDFLAGS="$LDFLAGS"
  321. LDFLAGS="-L$1/lib $LDFLAGS"
  322. # Compile and run a program that compares the version defined in
  323. # the header file with a version defined in the library function
  324. # db_version.
  325. AC_RUN_IFELSE([
  326. AC_LANG_SOURCE([[
  327. #include <stdio.h>
  328. #include <db.h>
  329. int main(int argc,char **argv)
  330. {
  331. int major,minor,patch;
  332. (void) argv;
  333. db_version(&major,&minor,&patch);
  334. if (argc > 1)
  335. printf("%d.%d.%d\n",DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH);
  336. if (DB_VERSION_MAJOR == major && DB_VERSION_MINOR == minor &&
  337. DB_VERSION_PATCH == patch)
  338. return 0;
  339. else
  340. return 1;
  341. }
  342. ]])
  343. ],[
  344. # Program compiled and ran, so get version by adding argument.
  345. ax_path_bdb_path_get_version_VERSION=`./conftest$ac_exeext x`
  346. ax_path_bdb_path_get_version_ok=yes
  347. ],[],[])
  348. dnl # restore environment
  349. CPPFLAGS="$ax_path_bdb_path_get_version_save_CPPFLAGS"
  350. LIBS="$ax_path_bdb_path_get_version_save_LIBS"
  351. LDFLAGS="$ax_path_bdb_path_get_version_save_LDFLAGS"
  352. fi
  353. dnl # Finally, execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND.
  354. if test "$ax_path_bdb_path_get_version_ok" = "yes" ; then
  355. AC_MSG_RESULT([$ax_path_bdb_path_get_version_VERSION])
  356. m4_ifvaln([$2],[$2])dnl
  357. else
  358. AC_MSG_RESULT([no])
  359. m4_ifvaln([$3],[$3])dnl
  360. fi
  361. ]) dnl AX_PATH_BDB_PATH_GET_VERSION
  362. #############################################################################
  363. dnl Checks if version of library and header match specified version.
  364. dnl Only meant to be used by AX_PATH_BDB_ENV_GET_VERSION macro.
  365. dnl
  366. dnl Requires AX_COMPARE_VERSION macro.
  367. dnl
  368. dnl Result: sets ax_path_bdb_env_confirm_lib_ok to yes or no.
  369. dnl
  370. dnl AX_PATH_BDB_ENV_CONFIRM_LIB(VERSION, [LIBNAME])
  371. AC_DEFUN([AX_PATH_BDB_ENV_CONFIRM_LIB], [
  372. dnl # Used to indicate success or failure of this function.
  373. ax_path_bdb_env_confirm_lib_ok=no
  374. dnl # save and modify environment to link with library LIBNAME
  375. ax_path_bdb_env_confirm_lib_save_LIBS="$LIBS"
  376. LIBS="$LIBS $2"
  377. # Compile and run a program that compares the version defined in
  378. # the header file with a version defined in the library function
  379. # db_version.
  380. AC_RUN_IFELSE([
  381. AC_LANG_SOURCE([[
  382. #include <stdio.h>
  383. #include <db.h>
  384. int main(int argc,char **argv)
  385. {
  386. int major,minor,patch;
  387. (void) argv;
  388. db_version(&major,&minor,&patch);
  389. if (argc > 1)
  390. printf("%d.%d.%d\n",DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH);
  391. if (DB_VERSION_MAJOR == major && DB_VERSION_MINOR == minor &&
  392. DB_VERSION_PATCH == patch)
  393. return 0;
  394. else
  395. return 1;
  396. }
  397. ]])
  398. ],[
  399. # Program compiled and ran, so get version by giving an argument,
  400. # which will tell the program to print the output.
  401. ax_path_bdb_env_confirm_lib_VERSION=`./conftest$ac_exeext x`
  402. # If the versions all match up, indicate success.
  403. AX_COMPARE_VERSION([$ax_path_bdb_env_confirm_lib_VERSION],[eq],[$1],[
  404. ax_path_bdb_env_confirm_lib_ok=yes
  405. ])
  406. ],[],[])
  407. dnl # restore environment
  408. LIBS="$ax_path_bdb_env_confirm_lib_save_LIBS"
  409. ]) dnl AX_PATH_BDB_ENV_CONFIRM_LIB
  410. #############################################################################
  411. dnl Finds the version and library name for Berkeley DB in the
  412. dnl current environment. Tries many different names for library.
  413. dnl
  414. dnl Requires AX_PATH_BDB_ENV_CONFIRM_LIB macro.
  415. dnl
  416. dnl Result: set ax_path_bdb_env_get_version_ok to yes or no,
  417. dnl set ax_path_bdb_env_get_version_VERSION to the version found,
  418. dnl and ax_path_bdb_env_get_version_LIBNAME to the library name.
  419. dnl
  420. dnl AX_PATH_BDB_ENV_GET_VERSION([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  421. AC_DEFUN([AX_PATH_BDB_ENV_GET_VERSION], [
  422. dnl # Used to indicate success or failure of this function.
  423. ax_path_bdb_env_get_version_ok=no
  424. ax_path_bdb_env_get_version_VERSION=''
  425. ax_path_bdb_env_get_version_LIBS=''
  426. AS_VAR_PUSHDEF([HEADER_VERSION],[ax_path_bdb_env_get_version_HEADER_VERSION])dnl
  427. AS_VAR_PUSHDEF([TEST_LIBNAME],[ax_path_bdb_env_get_version_TEST_LIBNAME])dnl
  428. # Indicate status of checking for Berkeley DB library.
  429. AC_MSG_CHECKING([for db.h])
  430. # Compile and run a program that determines the Berkeley DB version
  431. # in the header file db.h.
  432. HEADER_VERSION=''
  433. AC_RUN_IFELSE([
  434. AC_LANG_SOURCE([[
  435. #include <stdio.h>
  436. #include <db.h>
  437. int main(int argc,char **argv)
  438. {
  439. (void) argv;
  440. if (argc > 1)
  441. printf("%d.%d.%d\n",DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH);
  442. return 0;
  443. }
  444. ]])
  445. ],[
  446. # Program compiled and ran, so get version by adding an argument.
  447. HEADER_VERSION=`./conftest$ac_exeext x`
  448. AC_MSG_RESULT([$HEADER_VERSION])
  449. ],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no])])
  450. # Have header version, so try to find corresponding library.
  451. # Looks for library names in the order:
  452. # nothing, db, db-X.Y, dbX.Y, dbXY, db-X, dbX
  453. # and stops when it finds the first one that matches the version
  454. # of the header file.
  455. if test "x$HEADER_VERSION" != "x" ; then
  456. AC_MSG_CHECKING([for library containing Berkeley DB $HEADER_VERSION])
  457. AS_VAR_PUSHDEF([MAJOR],[ax_path_bdb_env_get_version_MAJOR])dnl
  458. AS_VAR_PUSHDEF([MINOR],[ax_path_bdb_env_get_version_MINOR])dnl
  459. # get major and minor version numbers
  460. MAJOR=`echo $HEADER_VERSION | sed 's,\..*,,'`
  461. MINOR=`echo $HEADER_VERSION | sed 's,^[[0-9]]*\.,,;s,\.[[0-9]]*$,,'`
  462. # see if it is already specified in LIBS
  463. TEST_LIBNAME=''
  464. AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
  465. if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then
  466. # try format "db"
  467. TEST_LIBNAME='-ldb'
  468. AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
  469. fi
  470. if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then
  471. # try format "db-X.Y"
  472. TEST_LIBNAME="-ldb-${MAJOR}.$MINOR"
  473. AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
  474. fi
  475. if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then
  476. # try format "dbX.Y"
  477. TEST_LIBNAME="-ldb${MAJOR}.$MINOR"
  478. AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
  479. fi
  480. if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then
  481. # try format "dbXY"
  482. TEST_LIBNAME="-ldb$MAJOR$MINOR"
  483. AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
  484. fi
  485. if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then
  486. # try format "db-X"
  487. TEST_LIBNAME="-ldb-$MAJOR"
  488. AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
  489. fi
  490. if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then
  491. # try format "dbX"
  492. TEST_LIBNAME="-ldb$MAJOR"
  493. AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME])
  494. fi
  495. dnl # Found a valid library.
  496. if test "$ax_path_bdb_env_confirm_lib_ok" = "yes" ; then
  497. if test "x$TEST_LIBNAME" = "x" ; then
  498. AC_MSG_RESULT([none required])
  499. else
  500. AC_MSG_RESULT([$TEST_LIBNAME])
  501. fi
  502. ax_path_bdb_env_get_version_VERSION="$HEADER_VERSION"
  503. ax_path_bdb_env_get_version_LIBS="$TEST_LIBNAME"
  504. ax_path_bdb_env_get_version_ok=yes
  505. else
  506. AC_MSG_RESULT([no])
  507. fi
  508. AS_VAR_POPDEF([MAJOR])dnl
  509. AS_VAR_POPDEF([MINOR])dnl
  510. fi
  511. AS_VAR_POPDEF([HEADER_VERSION])dnl
  512. AS_VAR_POPDEF([TEST_LIBNAME])dnl
  513. dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND.
  514. if test "$ax_path_bdb_env_confirm_lib_ok" = "yes" ; then
  515. m4_ifvaln([$1],[$1],[:])dnl
  516. m4_ifvaln([$2],[else $2])dnl
  517. fi
  518. ]) dnl BDB_ENV_GET_VERSION
  519. #############################################################################