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