484b751a405eb7c959d6d9a871d032ef5f4c5d89
[xfstests-dev.git] / m4 / package_gdbmdev.m4
1 AC_DEFUN([AC_PACKAGE_WANT_GDBM],
2   [ AC_CHECK_HEADER(gdbm-ndbm.h, [ gdbm_ndbm=true; have_db=true ], [ gdbm_ndbm=false; have_db=false ])
3
4     if test $gdbm_ndbm = true; then
5         AC_DEFINE(HAVE_GDBM_NDBM_H, [1], [Define to 1 if you have the <gdbm-ndbm.h> header file.])
6     else
7         AS_UNSET([ac_cv_header_gdbm_ndbm_h])
8         AC_CHECK_HEADER(gdbm/ndbm.h, [ gdbm_ndbm_=true; have_db=true ], [ gdbm_ndbm_=false; have_db=false ])
9         if test $gdbm_ndbm_ = true; then
10             AC_DEFINE(HAVE_GDBM_NDBM_H_, [1], [Define to 1 if you have the <gdbm/ndbm.h> header file.])
11         else
12             AC_CHECK_HEADER(gdbm.h, [ gdbm_ndbm_=true; have_db=true ], [ gdbm_ndbm_=false; have_db=false ])
13             AC_CHECK_HEADER(ndbm.h, [ ndbm_=true ], [ ndbm_=false ])
14                 if test $gdbm_ndbm_ = true; then
15                     if test $ndbm_ = true; then
16                         AC_DEFINE(HAVE_GDBM_H, [1], [Define to 1 if you have both <gdbm.h> and <ndbm.h> header files.])
17                     fi
18                 fi
19         fi
20     fi
21
22     found=false
23     libgdbm=""
24
25     if test $have_db = true; then
26       AC_CHECK_LIB(gdbm,dbm_open,found=true,found=false)
27       AC_CHECK_LIB(gdbm,dbm_fetch,,found=false)
28       AC_CHECK_LIB(gdbm,dbm_store,,found=false)
29       AC_CHECK_LIB(gdbm,dbm_close,,found=false)
30
31       if test $found = true; then
32         libgdbm="${libgdbm} -lgdbm"
33       fi
34
35       found="no"
36       AC_CHECK_LIB(gdbm_compat,dbm_open,found=true,found=false,-lgdbm)
37       AC_CHECK_LIB(gdbm_compat,dbm_fetch,,found=false,-lgdbm)
38       AC_CHECK_LIB(gdbm_compat,dbm_store,,found=false,-lgdbm)
39       AC_CHECK_LIB(gdbm_compat,dbm_close,,found="no",-lgdbm)
40
41       if test $found = true ; then
42         libgdbm="${libgdbm} -lgdbm_compat -lgdbm"
43       fi
44     fi
45
46     AC_SUBST(libgdbm)
47     AC_SUBST(have_db)
48   ])
49