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