Home | History | Annotate | Line # | Download | only in cf
db.m4 revision 1.1
      1  1.1  elric dnl $Id: db.m4,v 1.1 2011/04/13 18:14:32 elric Exp $
      2  1.1  elric dnl
      3  1.1  elric dnl tests for various db libraries
      4  1.1  elric dnl
      5  1.1  elric 
      6  1.1  elric AC_DEFUN([rk_DB],[
      7  1.1  elric AC_ARG_WITH(berkeley-db,
      8  1.1  elric                        AS_HELP_STRING([--with-berkeley-db],
      9  1.1  elric                                       [enable support for berkeley db @<:@default=check@:>@]),
     10  1.1  elric                        [],
     11  1.1  elric                        [with_berkeley_db=check])
     12  1.1  elric 
     13  1.1  elric dbheader=""
     14  1.1  elric AC_ARG_WITH(berkeley-db-include,
     15  1.1  elric                        AS_HELP_STRING([--with-berkeley-db-include=dir],
     16  1.1  elric 		                      [use berkeley-db headers in dir]),
     17  1.1  elric 		       [dbheader=$withval],
     18  1.1  elric 		       [with_berkeley_db_include=check])
     19  1.1  elric 
     20  1.1  elric AC_ARG_ENABLE(ndbm-db,
     21  1.1  elric                        AS_HELP_STRING([--disable-ndbm-db],
     22  1.1  elric                                       [if you don't want ndbm db]),[
     23  1.1  elric ])
     24  1.1  elric 
     25  1.1  elric have_ndbm=no
     26  1.1  elric db_type=unknown
     27  1.1  elric 
     28  1.1  elric AS_IF([test "x$with_berkeley_db" != xno],
     29  1.1  elric   [AS_IF([test "x$with_berkeley_db_include" != xcheck],
     30  1.1  elric     [AC_CHECK_HEADERS(["$dbheader/db.h"],
     31  1.1  elric                    [AC_SUBST([DBHEADER], [$dbheader])
     32  1.1  elric 		    AC_DEFINE([HAVE_DBHEADER], [1],
     33  1.1  elric 		                      [Define if you have user supplied header location])
     34  1.1  elric 	           ],
     35  1.1  elric 		   [if test "x$with_berkeley_db_include" != xcheck; then
     36  1.1  elric 		     AC_MSG_FAILURE(
     37  1.1  elric 		       [--with-berkeley-db-include was given but include test failed])
     38  1.1  elric 		    fi
     39  1.1  elric 		   ])],
     40  1.1  elric     [AC_CHECK_HEADERS([					\
     41  1.1  elric 	           db5/db.h				\
     42  1.1  elric 	           db4/db.h				\
     43  1.1  elric 	           db3/db.h				\
     44  1.1  elric 	           db.h					\
     45  1.1  elric     ])])
     46  1.1  elric 
     47  1.1  elric dnl db_create is used by db3 and db4 and db5
     48  1.1  elric 
     49  1.1  elric   AC_FIND_FUNC_NO_LIBS(db_create, [$dbheader] db5 db4 db3 db, [
     50  1.1  elric   #include <stdio.h>
     51  1.1  elric   #ifdef HAVE_DBHEADER
     52  1.1  elric   #include <$dbheader/db.h>
     53  1.1  elric   #elif HAVE_DB5_DB_H
     54  1.1  elric   #include <db5/db.h>
     55  1.1  elric   #elif HAVE_DB4_DB_H
     56  1.1  elric   #include <db4/db.h>
     57  1.1  elric   #elif defined(HAVE_DB3_DB_H)
     58  1.1  elric   #include <db3/db.h>
     59  1.1  elric   #else
     60  1.1  elric   #include <db.h>
     61  1.1  elric   #endif
     62  1.1  elric   ],[NULL, NULL, 0])
     63  1.1  elric 
     64  1.1  elric   if test "$ac_cv_func_db_create" = "yes"; then
     65  1.1  elric     db_type=db3
     66  1.1  elric     if test "$ac_cv_funclib_db_create" != "yes"; then
     67  1.1  elric       DBLIB="$ac_cv_funclib_db_create"
     68  1.1  elric     else
     69  1.1  elric       DBLIB=""
     70  1.1  elric     fi
     71  1.1  elric     AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4/5 library])
     72  1.1  elric   fi
     73  1.1  elric 
     74  1.1  elric dnl dbopen is used by db1/db2
     75  1.1  elric 
     76  1.1  elric   AC_FIND_FUNC_NO_LIBS(dbopen, db2 db, [
     77  1.1  elric   #include <stdio.h>
     78  1.1  elric   #if defined(HAVE_DB2_DB_H)
     79  1.1  elric   #include <db2/db.h>
     80  1.1  elric   #elif defined(HAVE_DB_H)
     81  1.1  elric   #include <db.h>
     82  1.1  elric   #else
     83  1.1  elric   #error no db.h
     84  1.1  elric   #endif
     85  1.1  elric   ],[NULL, 0, 0, 0, NULL])
     86  1.1  elric 
     87  1.1  elric   if test "$ac_cv_func_dbopen" = "yes"; then
     88  1.1  elric     db_type=db1
     89  1.1  elric     if test "$ac_cv_funclib_dbopen" != "yes"; then
     90  1.1  elric       DBLIB="$ac_cv_funclib_dbopen"
     91  1.1  elric     else
     92  1.1  elric       DBLIB=""
     93  1.1  elric     fi
     94  1.1  elric     AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library])
     95  1.1  elric   fi
     96  1.1  elric 
     97  1.1  elric dnl test for ndbm compatability
     98  1.1  elric 
     99  1.1  elric   if test "$ac_cv_func_dbm_firstkey" != yes; then
    100  1.1  elric     AC_FIND_FUNC_NO_LIBS2(dbm_firstkey, $ac_cv_funclib_dbopen $ac_cv_funclib_db_create, [
    101  1.1  elric     #include <stdio.h>
    102  1.1  elric     #define DB_DBM_HSEARCH 1
    103  1.1  elric     #include <db.h>
    104  1.1  elric     DBM *dbm;
    105  1.1  elric     ],[NULL])
    106  1.1  elric   
    107  1.1  elric     if test "$ac_cv_func_dbm_firstkey" = "yes"; then
    108  1.1  elric       if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
    109  1.1  elric         LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
    110  1.1  elric       else
    111  1.1  elric         LIB_NDBM=""
    112  1.1  elric       fi
    113  1.1  elric       AC_DEFINE(HAVE_DB_NDBM, 1, [define if you have ndbm compat in db])
    114  1.1  elric       AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
    115  1.1  elric     else
    116  1.1  elric       $as_unset ac_cv_func_dbm_firstkey
    117  1.1  elric       $as_unset ac_cv_funclib_dbm_firstkey
    118  1.1  elric     fi
    119  1.1  elric   fi
    120  1.1  elric 
    121  1.1  elric ]) # fi berkeley db
    122  1.1  elric 
    123  1.1  elric if test "$enable_ndbm_db" != "no"; then
    124  1.1  elric 
    125  1.1  elric   if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then
    126  1.1  elric 
    127  1.1  elric     AC_CHECK_HEADERS([				\
    128  1.1  elric   	dbm.h					\
    129  1.1  elric   	ndbm.h					\
    130  1.1  elric     ])
    131  1.1  elric   
    132  1.1  elric     AC_FIND_FUNC_NO_LIBS(dbm_firstkey, ndbm, [
    133  1.1  elric     #include <stdio.h>
    134  1.1  elric     #if defined(HAVE_NDBM_H)
    135  1.1  elric     #include <ndbm.h>
    136  1.1  elric     #elif defined(HAVE_DBM_H)
    137  1.1  elric     #include <dbm.h>
    138  1.1  elric     #endif
    139  1.1  elric     DBM *dbm;
    140  1.1  elric     ],[NULL])
    141  1.1  elric   
    142  1.1  elric     if test "$ac_cv_func_dbm_firstkey" = "yes"; then
    143  1.1  elric       if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
    144  1.1  elric         LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
    145  1.1  elric       else
    146  1.1  elric         LIB_NDBM=""
    147  1.1  elric       fi
    148  1.1  elric       AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
    149  1.1  elric       have_ndbm=yes
    150  1.1  elric       if test "$db_type" = "unknown"; then
    151  1.1  elric         db_type=ndbm
    152  1.1  elric         DBLIB="$LIB_NDBM"
    153  1.1  elric       fi
    154  1.1  elric     else
    155  1.1  elric   
    156  1.1  elric       $as_unset ac_cv_func_dbm_firstkey
    157  1.1  elric       $as_unset ac_cv_funclib_dbm_firstkey
    158  1.1  elric   
    159  1.1  elric       AC_CHECK_HEADERS([				\
    160  1.1  elric   	  gdbm/ndbm.h				\
    161  1.1  elric       ])
    162  1.1  elric   
    163  1.1  elric       AC_FIND_FUNC_NO_LIBS(dbm_firstkey, gdbm, [
    164  1.1  elric       #include <stdio.h>
    165  1.1  elric       #include <gdbm/ndbm.h>
    166  1.1  elric       DBM *dbm;
    167  1.1  elric       ],[NULL])
    168  1.1  elric   
    169  1.1  elric       if test "$ac_cv_func_dbm_firstkey" = "yes"; then
    170  1.1  elric         if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
    171  1.1  elric   	LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
    172  1.1  elric         else
    173  1.1  elric   	LIB_NDBM=""
    174  1.1  elric         fi
    175  1.1  elric         AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
    176  1.1  elric         have_ndbm=yes
    177  1.1  elric         if test "$db_type" = "unknown"; then
    178  1.1  elric   	db_type=ndbm
    179  1.1  elric   	DBLIB="$LIB_NDBM"
    180  1.1  elric         fi
    181  1.1  elric       fi
    182  1.1  elric     fi
    183  1.1  elric   fi #enable_ndbm_db
    184  1.1  elric fi # unknown
    185  1.1  elric 
    186  1.1  elric if test "$have_ndbm" = "yes"; then
    187  1.1  elric   AC_MSG_CHECKING([if ndbm is implemented with db])
    188  1.1  elric   AC_RUN_IFELSE([AC_LANG_SOURCE([[
    189  1.1  elric #include <unistd.h>
    190  1.1  elric #include <fcntl.h>
    191  1.1  elric #if defined(HAVE_GDBM_NDBM_H)
    192  1.1  elric #include <gdbm/ndbm.h>
    193  1.1  elric #elif defined(HAVE_NDBM_H)
    194  1.1  elric #include <ndbm.h>
    195  1.1  elric #elif defined(HAVE_DBM_H)
    196  1.1  elric #include <dbm.h>
    197  1.1  elric #endif
    198  1.1  elric int main(int argc, char **argv)
    199  1.1  elric {
    200  1.1  elric   DBM *d;
    201  1.1  elric 
    202  1.1  elric   d = dbm_open("conftest", O_RDWR | O_CREAT, 0666);
    203  1.1  elric   if (d == NULL)
    204  1.1  elric     return 1;
    205  1.1  elric   dbm_close(d);
    206  1.1  elric   return 0;
    207  1.1  elric }]])],[
    208  1.1  elric     if test -f conftest.db; then
    209  1.1  elric       AC_MSG_RESULT([yes])
    210  1.1  elric       AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
    211  1.1  elric     else
    212  1.1  elric       AC_MSG_RESULT([no])
    213  1.1  elric     fi],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no-cross])])
    214  1.1  elric fi
    215  1.1  elric 
    216  1.1  elric AM_CONDITIONAL(HAVE_DB1, test "$db_type" = db1)dnl
    217  1.1  elric AM_CONDITIONAL(HAVE_DB3, test "$db_type" = db3)dnl
    218  1.1  elric AM_CONDITIONAL(HAVE_NDBM, test "$db_type" = ndbm)dnl
    219  1.1  elric AM_CONDITIONAL(HAVE_DBHEADER, test "$dbheader" != "")dnl
    220  1.1  elric 
    221  1.1  elric ## it's probably not correct to include LDFLAGS here, but we might
    222  1.1  elric ## need it, for now just add any possible -L
    223  1.1  elric z=""
    224  1.1  elric for i in $LDFLAGS; do
    225  1.1  elric 	case "$i" in
    226  1.1  elric 	-L*) z="$z $i";;
    227  1.1  elric 	esac
    228  1.1  elric done
    229  1.1  elric DBLIB="$z $DBLIB"
    230  1.1  elric AC_SUBST(DBLIB)dnl
    231  1.1  elric AC_SUBST(LIB_NDBM)dnl
    232  1.1  elric ])
    233