Commit b5d6d5e2 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Allow OpenLDAP to be built without LDBM.

parent e01f6988
This diff is collapsed.
......@@ -24,10 +24,14 @@ AC_PREFIX_DEFAULT(/usr/local)
dnl General "enable" options
CF_ARG_OPTION(debug,[ --enable-debug enable debugging (yes)],[
LDAP_DEBUG=no],[LDAP_DEBUG=yes],yes)dnl
CF_ARG_OPTION(syslog,[ --enable-syslog enable syslog support (no)],[
LDAP_CLDAP=yes],[LDAP_CLDAP=no],no)dnl
CF_ARG_OPTION(libui,[ --enable-libui enable library user interface (yes)],[
LDAP_LIBUI=no],[LDAP_LIBUI=yes],yes)dnl
CF_ARG_OPTION(cache,[ --enable-cache enable caching (yes)],[
LDAP_CACHE=no],[LDAP_CACHE=yes],yes)dnl
CF_ARG_OPTION(dns,[ --enable-dns enable dns support (no)],[
LDAP_DNS=yes],[LDAP_DNS=no],no)dnl
CF_ARG_OPTION(referrals,[ --enable-referrals enable referrals (yes)],[
LDAP_REFERRALS=no],[LDAP_REFERRALS=yes],yes)dnl
......@@ -119,12 +123,23 @@ fi
## general LDAP arguments
LDAP_DEFS=
LDAP_LIBS=
LDBM_DEFS=
LDBM_LIBS=
LUTIL_DEFS=
LUTIL_LIBS=
if test "$LDAP_DEBUG" = "yes" ; then
LDAP_DEFS="$LDAP_DEFS -DLDAP_DEBUG"
fi
if test "$LDAP_SYSLOG" = "yes" ; then
LDAP_DEFS="$LDAP_DEFS -DLDAP_SYSLOG"
fi
if test "$LDAP_DNS" = "yes" ; then
dnl AC_DEFINE(LDAP_DNS,1)
LDAP_DEFS="$LDAP_DEFS -DLDAP_DNS"
fi
if test "$LDAP_REFERRALS" = "yes" ; then
AC_DEFINE(LDAP_REFERRALS,1)
dnl AC_DEFINE(LDAP_REFERRALS,1)
LDAP_DEFS="$LDAP_DEFS -DLDAP_REFERRALS"
fi
if test "$LDAP_CACHE" = "no" ; then
......@@ -143,7 +158,6 @@ LDAPD_LIBS=
## slapd arguments
SLAPD_DEFS=
SLAPD_LIBS=
LUTIL_DEFS=
if test "$SLAPD_PHONETIC" = "yes" ; then
AC_DEFINE(SLAPD_PHONETIC,1)
SLAPD_DEFS="$SLAPD_DEFS -DSOUNDEX"
......@@ -159,9 +173,11 @@ dnl AC_DEFINE(SLAPD_SHA1,1)
LUTIL_DEFS="$LUTIL_DEFS -DLDAP_SHA1"
fi
BUILD_LDBM=no
if test "$SLAPD_LDBM" = "yes" ; then
dnl AC_DEFINE(SLAPD_LDBM,1)
SLAPD_DEFS="$SLAPD_DEFS -DLDAP_LDBM"
BUILD_LDBM=yes
LDBM_DEFS="$LDBM_DEFS -DLDAP_LDBM"
fi
if test "$SLAPD_PASSWD" = "yes" ; then
dnl AC_DEFINE(SLAPD_PASSWD,1)
......@@ -313,12 +329,13 @@ dnl AC_DEFINE(HAVE_LINUX_THREADS,1)
fi
fi
# check for strtok_r
# check for strtok_r (and presumely other reentrant functions)
save_LIBS="$LIBS"
LIBS="$save_LIBS $LTHREAD_LIBS"
AC_CHECK_LIB(pthread,strtok_r)
if test $ac_cv_lib_pthread_strtok_r = no ; then
LIBS="$save_LIBS $LTHREAD_LIBS"
AC_CHECK_LIB(c_r,strtok_r)
AC_CHECK_FUNCS(strtok_r sched_yield)
if test $ac_cv_lib_c_r_strtok_r = yes ; then
......@@ -332,9 +349,6 @@ LIBS="$save_LIBS"
ldbm_use="none"
LDBM_DEFS=
LDBM_LIBS=
if test "$SLAPD_LDBM" = "yes" ; then
if test $ldbm_prefer = any -o $ldbm_prefer = dbbtree \
-o $ldbm_prefer = dbhash ; then
......@@ -502,27 +516,30 @@ AC_CHECK_FUNCS( \
memcpy \
)
AC_REPLACE_FUNCS(strsep strdup)
AC_REPLACE_FUNCS(strdup)
dnl ----------------------------------------------------------------
# Check Configuration
CF_SYS_ERRLIST
dnl ----------------------------------------------------------------
AC_SUBST(BUILD_LDAPD)
AC_SUBST(BUILD_SLAPD)
AC_SUBST(SLAPD_LDBM)
AC_SUBST(SLAPD_PASSWD)
AC_SUBST(SLAPD_SHELL)
AC_SUBST(BUILD_LDBM)
AC_SUBST(BUILD_PASSWD)
AC_SUBST(BUILD_SHELL)
AC_SUBST(BUILD_SLURPD)
AC_SUBST(LDAP_DEFS)
AC_SUBST(LDAP_LIBS)
AC_SUBST(LDAPD_DEFS)
AC_SUBST(LDAPD_LIBS)
AC_SUBST(SLAPD_DEFS)
AC_SUBST(SLAPD_LIBS)
AC_SUBST(SLAPD_LDBM)
AC_SUBST(SLAPD_PASSWD)
AC_SUBST(SLAPD_SHELL)
AC_SUBST(SLURPD_DEFS)
AC_SUBST(SLURPD_LIBS)
AC_SUBST(LDBM_DEFS)
......@@ -532,6 +549,10 @@ AC_SUBST(LTHREAD_LIBS)
AC_SUBST(LUTIL_DEFS)
AC_SUBST(LUTIL_LIBS)
dnl ----------------------------------------------------------------
dnl final output
dnl
dnl AC_OUTPUT( \
dnl contrib/Makefile:build/top.mk:contrib/Makefile.in:build/dir.mk \
dnl contrib/saucer/Makefile:build/top.mk:contrib/saucer/Makefile.in:build/rules.mk \
......
......@@ -79,9 +79,6 @@
/* define this to remove -lldap cache support */
#undef LDAP_NOCACHE
/* define this for LDAP referrals support */
#undef LDAP_REFERRALS
/* define this for phonetic support */
#undef SLAPD_PHONETIC
......
/* ldbm.c - ldap dbm compatibility routines */
/* Patched for Berkeley DB version 2.0; /KSp; 98/02/23
*
* - basic implementation; 1998/02/23, /KSp
* - DB_DBT_MALLOC ; 1998/03/22, /KSp
*/
#ifdef LDAP_LDBM
#include <stdio.h>
#include "ldbm.h"
......@@ -121,10 +129,41 @@ ldbm_errno( LDBM ldbm )
* *
*****************************************************************/
#ifdef LDBM_USE_DB2
/*************************************************
* *
* A malloc routine for use with DB_DBT_MALLOC *
* *
*************************************************/
#include <stdlib.h>
void *
ldbm_malloc( size_t size )
{
return( calloc( 1, size ));
}
#endif
LDBM
ldbm_open( char *name, int rw, int mode, int dbcachesize )
{
LDBM ret;
LDBM ret = NULL;
#ifdef LDBM_USE_DB2
DB_INFO dbinfo;
memset( &dbinfo, 0, sizeof( dbinfo ));
dbinfo.db_cachesize = dbcachesize;
dbinfo.db_pagesize = DEFAULT_DB_PAGE_SIZE;
dbinfo.db_malloc = ldbm_malloc;
db_open( name, DB_TYPE, rw, mode, NULL, &dbinfo, &ret );
#else
void *info;
BTREEINFO binfo;
HASHINFO hinfo;
......@@ -140,14 +179,22 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize )
} else {
info = NULL;
}
ret = dbopen( name, rw, mode, DB_TYPE, info );
#endif
return( ret );
}
void
ldbm_close( LDBM ldbm )
{
#ifdef LDBM_USE_DB2
(*ldbm->close)( ldbm, 0 );
#else
(*ldbm->close)( ldbm );
#endif
}
void
......@@ -167,6 +214,10 @@ ldbm_datum_dup( LDBM ldbm, Datum data )
{
Datum dup;
#ifdef LDBM_USE_DB2
memset( &dup, 0, sizeof( dup ));
#endif
if ( data.dsize == 0 ) {
dup.dsize = 0;
dup.dptr = NULL;
......@@ -186,9 +237,18 @@ ldbm_fetch( LDBM ldbm, Datum key )
Datum data;
int rc;
#ifdef LDBM_USE_DB2
memset( &data, 0, sizeof( data ));
data.flags = DB_DBT_MALLOC;
if ( (rc = (*ldbm->get)( ldbm, NULL, &key, &data, 0 )) != 0 ) {
if ( data.dptr ) free( data.dptr );
#else
if ( (rc = (*ldbm->get)( ldbm, &key, &data, 0 )) == 0 ) {
data = ldbm_datum_dup( ldbm, data );
} else {
#endif
data.dptr = NULL;
data.dsize = 0;
}
......@@ -201,7 +261,12 @@ ldbm_store( LDBM ldbm, Datum key, Datum data, int flags )
{
int rc;
#ifdef LDBM_USE_DB2
rc = (*ldbm->put)( ldbm, NULL, &key, &data, flags & ~LDBM_SYNC );
rc = (-1 ) * rc;
#else
rc = (*ldbm->put)( ldbm, &key, &data, flags & ~LDBM_SYNC );
#endif
if ( flags & LDBM_SYNC )
(*ldbm->sync)( ldbm, 0 );
return( rc );
......@@ -212,38 +277,88 @@ ldbm_delete( LDBM ldbm, Datum key )
{
int rc;
#ifdef LDBM_USE_DB2
rc = (*ldbm->del)( ldbm, NULL, &key, 0 );
rc = (-1 ) * rc;
#else
rc = (*ldbm->del)( ldbm, &key, 0 );
#endif
(*ldbm->sync)( ldbm, 0 );
return( rc );
}
Datum
#ifdef LDBM_USE_DB2
ldbm_firstkey( LDBM ldbm, DBC **dbch )
#else
ldbm_firstkey( LDBM ldbm )
#endif
{
Datum key, data;
int rc;
#ifdef LDBM_USE_DB2
DBC *dbci;
memset( &key, 0, sizeof( key ));
memset( &data, 0, sizeof( data ));
key.flags = data.flags = DB_DBT_MALLOC;
/* acquire a cursor for the DB */
if ( (*ldbm->cursor)( ldbm, NULL, &dbci )) {
return( key );
} else {
*dbch = dbci;
if ( (*dbci->c_get)( dbci, &key, &data, DB_NEXT ) == 0 ) {
if ( data.dptr ) free( data.dptr );
#else
if ( (rc = (*ldbm->seq)( ldbm, &key, &data, R_FIRST )) == 0 ) {
key = ldbm_datum_dup( ldbm, key );
#endif
} else {
key.dptr = NULL;
key.dsize = 0;
}
#ifdef LDBM_USE_DB2
}
#endif
return( key );
}
Datum
#ifdef LDBM_USE_DB2
ldbm_nextkey( LDBM ldbm, Datum key, DBC *dbcp )
#else
ldbm_nextkey( LDBM ldbm, Datum key )
#endif
{
Datum data;
int rc;
#ifdef LDBM_USE_DB2
void *oldKey = key.dptr;
memset( &data, 0, sizeof( data ));
data.flags = DB_DBT_MALLOC;
if ( (*dbcp->c_get)( dbcp, &key, &data, DB_NEXT ) == 0 ) {
if ( data.dptr ) free( data.dptr );
#else
if ( (rc = (*ldbm->seq)( ldbm, &key, &data, R_NEXT )) == 0 ) {
key = ldbm_datum_dup( ldbm, key );
#endif
} else {
key.dptr = NULL;
key.dsize = 0;
}
#ifdef LDBM_USE_DB2
if ( oldKey ) free( oldKey );
#endif
return( key );
}
......@@ -346,3 +461,4 @@ ldbm_errno( LDBM ldbm )
#endif /* ndbm */
#endif /* db */
#endif /* gdbm */
#endif /* ldbm */
......@@ -30,7 +30,16 @@ OBJS2 = ../config.o ../ch_malloc.o ../backend.o ../charray.o \
../dn.o ../filter.o ../str2filter.o ../ava.o ../init.o \
../schemaparse.o ../strdup.o
all-local: build-edb2ldif build-chlog2replog $(PROGRAMS)
all-local: build-ldbm build-edb2ldif build-chlog2replog
build-ldbm: FORCE
@if [ "$(BUILD_LDBM)" = "yes" ]; then \
$(MAKE) $(MFLAGS) ldbm-tools; \
else \
echo "run configure with --with-ldbm to build LDBM tools"; \
fi
ldbm-tools: $(PROGRAMS)
XDEFS = @SLAPD_DEFS@ @LDBM_DEFS@ @LTHREAD_DEFS@
XLIBS = @SLAPD_LIBS@ -lavl -lldbm @LDBM_LIBS@ -llthread @LTHREAD_LIBS@ -llutil @LUTIL_LIBS@
......@@ -95,21 +104,37 @@ clean-local: FORCE
$(RM) $(PROGRAMS) $(XPROGRAMS) $(XSRCS) edb2-vers.c *.o a.out core
depend-local: FORCE
@if [ "$(HAVE_ISODE)" = "yes" ]; then \
DEPENDEXTRAS="$(ISODEINCLUDEFLAG) chlog2replog.c $(EDB2LDIFSRCS)"; \
@DEPEND=no ; DEPEND_LDBM= ; DEPEND_ISODE= ;\
if [ "$(BUILD_LDBM)" = "yes" ]; then \
DEPEND_LDBM="$(SRCS)"; \
DEPEND=yes ; \
fi; \
if [ "$(HAVE_ISODE)" = "yes" ]; then \
DEPEND_ISODE="$(ISODEINCLUDEFLAG) chlog2replog.c $(EDB2LDIFSRCS)"; \
DEPEND=yes ; \
fi; \
$(MKDEP) $(DEFS) $(DEFINES) $$DEPENDEXTRAS $(SRCS)
if [ "$$DEPEND" = "yes" ]; then \
$(MKDEP) $(DEFS) $(DEFINES) $$DEPEND_ISODE $$DEPEND_LDBM \
else \
exit 0 ; \
fi
install-local: install-ldbm install-isode FORCE
install-local: install-isode FORCE
install-ldbm: FORCE
@-$(MKDIR) -p $(sbindir)
$(INSTALL) $(INSTALLFLAGS) -m 755 ldif2ldbm $(sbindir)
$(INSTALL) $(INSTALLFLAGS) -m 755 ldif2index $(sbindir)
$(INSTALL) $(INSTALLFLAGS) -m 755 ldif2id2entry $(sbindir)
$(INSTALL) $(INSTALLFLAGS) -m 755 ldif2id2children $(sbindir)
$(INSTALL) $(INSTALLFLAGS) -m 755 ldbmcat $(sbindir)
$(INSTALL) $(INSTALLFLAGS) -m 755 ldif $(sbindir)
$(INSTALL) $(INSTALLFLAGS) -m 755 centipede $(sbindir)
$(INSTALL) $(INSTALLFLAGS) -m 755 ldbmtest $(sbindir)
@if [ "$(BUILD_LDBM)" = "yes" ]; then \
$(INSTALL) $(INSTALLFLAGS) -m 755 ldif2ldbm $(sbindir) \
$(INSTALL) $(INSTALLFLAGS) -m 755 ldif2index $(sbindir) \
$(INSTALL) $(INSTALLFLAGS) -m 755 ldif2id2entry $(sbindir) \
$(INSTALL) $(INSTALLFLAGS) -m 755 ldif2id2children $(sbindir) \
$(INSTALL) $(INSTALLFLAGS) -m 755 ldbmcat $(sbindir) \
$(INSTALL) $(INSTALLFLAGS) -m 755 ldif $(sbindir) \
$(INSTALL) $(INSTALLFLAGS) -m 755 centipede $(sbindir) \
$(INSTALL) $(INSTALLFLAGS) -m 755 ldbmtest $(sbindir) \
else \
exit 0; \
fi
install-isode: FORCE
@-$(MKDIR) -p $(sbindir)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment