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