xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / m4 / package_gdbmdev.m4
1 AC_DEFUN([AC_PACKAGE_WANT_GDBM],
2   [
3     have_db=
4     AC_CHECK_HEADER(gdbm-ndbm.h,
5       [
6         have_db=true
7         AC_DEFINE(HAVE_GDBM_NDBM_H, [1],
8                   [Define to 1 if you have the <gdbm-ndbm.h> header file.])
9       ])
10
11     if test -z "$have_db"; then
12       dnl gdbm-ndbm.h and gdbm/ndbm.h map to the same autoconf internal
13       dnl variable.  We need to clear it or this test will be skipped
14       dnl and the cached result from first test will be used.
15       AS_UNSET([ac_cv_header_gdbm_ndbm_h])
16       AC_CHECK_HEADER(gdbm/ndbm.h,
17         [
18           have_db=true
19           AC_DEFINE(HAVE_GDBM_NDBM_H_, [1],
20                     [Define to 1 if you have the <gdbm/ndbm.h> header file.])
21         ])
22     fi
23
24     if test -z "$have_db"; then
25       AC_CHECK_HEADER(ndbm.h,
26         [
27           have_db=true
28           AC_DEFINE(HAVE_NDBM_H, [1],
29                     [Define to 1 if you have the <ndbm.h> header file.])
30         ])
31     fi
32
33     if test "$have_db" = true; then
34       found=false
35       AC_CHECK_LIB(gdbm, dbm_open, found=true, found=false)
36       AC_CHECK_LIB(gdbm, dbm_fetch,, found=false)
37       AC_CHECK_LIB(gdbm, dbm_store,, found=false)
38       AC_CHECK_LIB(gdbm, dbm_close,, found=false)
39
40       if test "$found" = true; then
41         libgdbm="-lgdbm"
42       else
43         AC_CHECK_LIB(gdbm_compat, dbm_open, found=true, found=false, -lgdbm)
44         AC_CHECK_LIB(gdbm_compat, dbm_fetch,, found=false, -lgdbm)
45         AC_CHECK_LIB(gdbm_compat, dbm_store,, found=false, -lgdbm)
46         AC_CHECK_LIB(gdbm_compat, dbm_close,, found="no", -lgdbm)
47
48         if test "$found" = "true"; then
49           libgdbm="-lgdbm_compat -lgdbm"
50         fi
51       fi
52     fi
53
54     AC_SUBST(libgdbm)
55     AC_SUBST(have_db)
56   ])
57