ntdb: add autoconf support.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 19 Jun 2012 03:13:17 +0000 (12:43 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 19 Jun 2012 05:31:06 +0000 (07:31 +0200)
This is copied from tdb; we build the utilities, but as nothing else
links against it, we shouldn't be adding anything to the normal samba
binary sizes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User(master): Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date(master): Tue Jun 19 07:31:06 CEST 2012 on sn-devel-104

lib/ntdb/libntdb.m4 [new file with mode: 0644]
source3/Makefile.in
source3/configure.in

diff --git a/lib/ntdb/libntdb.m4 b/lib/ntdb/libntdb.m4
new file mode 100644 (file)
index 0000000..b713aba
--- /dev/null
@@ -0,0 +1,41 @@
+dnl find the ntdb sources. This is meant to work both for
+dnl ntdb standalone builds, and builds of packages using ntdb
+ntdbdir=""
+ntdbpaths=". lib/ntdb ntdb ../ntdb ../lib/ntdb"
+for d in $ntdbpaths; do
+       if test -f "$srcdir/$d/ntdb.c"; then
+               ntdbdir="$d"
+               AC_SUBST(ntdbdir)
+               break;
+       fi
+done
+if test x"$ntdbdir" = "x"; then
+   AC_MSG_ERROR([cannot find ntdb source in $ntdbpaths])
+fi
+NTDB_OBJ="check.o free.o hash.o io.o lock.o ntdb.o open.o pyntdb.o summary.o transaction.o traverse.o"
+AC_SUBST(NTDB_OBJ)
+AC_SUBST(LIBREPLACEOBJ)
+AC_SUBST(CCAN_OBJ)
+
+NTDB_LIBS=""
+AC_SUBST(NTDB_LIBS)
+
+NTDB_DEPS=""
+if test x$libreplace_cv_HAVE_FDATASYNC_IN_LIBRT = xyes ; then
+       NTDB_DEPS="$NTDB_DEPS -lrt"
+fi
+AC_SUBST(NTDB_DEPS)
+
+NTDB_CFLAGS="-I$ntdbdir"
+AC_SUBST(NTDB_CFLAGS)
+
+AC_CHECK_FUNCS(mmap pread pwrite getpagesize utime)
+AC_CHECK_HEADERS(getopt.h sys/select.h sys/time.h)
+
+AC_HAVE_DECL(pread, [#include <unistd.h>])
+AC_HAVE_DECL(pwrite, [#include <unistd.h>])
+
+if test x"$VERSIONSCRIPT" != "x"; then
+    EXPORTSFILE=ntdb.exports
+    AC_SUBST(EXPORTSFILE)
+fi
index 56c81d9aef046ed53836dd5e568e5a1d670d76ff..f4b00a7ff035617e0f8dc5c6d539e104ab9b8781 100644 (file)
@@ -115,6 +115,9 @@ LIBREPLACE_LIBS=@LIBREPLACE_LIBS@
 LIBTDB=@LIBTDB_STATIC@
 LIBTDB_LIBS=@LIBTDB_LIBS@
 TDB_DEPS=@TDB_DEPS@
+LIBNTDB=@LIBNTDB_STATIC@
+LIBNTDB_LIBS=@LIBNTDB_LIBS@
+NTDB_DEPS=@NTDB_DEPS@
 LIBNETAPI=@LIBNETAPI_STATIC@ @LIBNETAPI_SHARED@
 LIBNETAPI_LIBS=@LIBNETAPI_LIBS@
 LIBSMBCLIENT_LIBS=@LIBSMBCLIENT_LIBS@
@@ -127,6 +130,11 @@ TDBTOOL = @TDBTOOL@
 TDBDUMP = @TDBDUMP@
 TDBRESTORE = @TDBRESTORE@
 TDBTORTURE = @TDBTORTURE@
+NTDBBACKUP = @NTDBBACKUP@
+NTDBTOOL = @NTDBTOOL@
+NTDBDUMP = @NTDBDUMP@
+NTDBRESTORE = @NTDBRESTORE@
+NTDBTORTURE = @NTDBTORTURE@
 PTHREADPOOLTEST = @PTHREADPOOLTEST@
 
 INSTALLCMD=@INSTALL@
index 6705a2716b557ee80a3ec8cbf5d0b7ec5620f40a..c5775f810c568bffa7a24cff1c3857bf87630859 100644 (file)
@@ -1913,6 +1913,53 @@ then
        AC_SUBST(TDBTORTURE)
 fi
 
+AC_ARG_ENABLE(external_libntdb,
+       [AS_HELP_STRING([--enable-external-libntdb],
+               [Enable external ntdb [default=auto]])],
+               [ enable_external_libntdb=$enableval ],
+               [ enable_external_libntdb=auto ])
+
+if test "x$enable_external_libntdb" != xno
+then
+       PKG_CHECK_MODULES(LIBNTDB, ntdb >= 1.0,
+               [ enable_external_libntdb=yes ],
+               [
+               if test x$enable_external_libntdb = xyes; then
+                       AC_MSG_ERROR([Unable to find libntdb])
+               else
+                       enable_external_libntdb=no
+               fi
+               ])
+fi
+
+AC_SUBST(LIBNTDB_OBJ0)
+if test "x$enable_external_libntdb" = xno
+then
+       m4_include(../lib/ntdb/libntdb.m4)
+       LINK_LIBNTDB=STATIC
+       LIBNTDBVERSION=`grep ^VERSION ${ntdbdir}/wscript | sed -e "s/'//g" -e 's/.* //'`
+       SMB_LIBRARY(ntdb, 1, ${LIBNTDBVERSION})
+       LIBNTDB_OBJ0=""
+       LIBNTDB_LIBS="$LIBNTDB_LIBS $NTDB_DEPS"
+       for obj in ${NTDB_OBJ}; do
+               LIBNTDB_OBJ0="${LIBNTDB_OBJ0} ${ntdbdir}/${obj}"
+       done
+       AC_SUBST(LIBNTDB_OBJ0)
+       SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${NTDB_CFLAGS}"
+       SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${NTDB_CFLAGS}"
+
+       NTDBBACKUP="bin/ntdbbackup"
+       AC_SUBST(NTDBBACKUP)
+       NTDBDUMP="bin/ntdbdump"
+       AC_SUBST(NTDBDUMP)
+       NTDBRESTORE="bin/ntdbrestore"
+       AC_SUBST(NTDBRESTORE)
+       NTDBTOOL="bin/ntdbtool"
+       AC_SUBST(NTDBTOOL)
+       NTDBTORTURE="bin/ntdbtorture"
+       AC_SUBST(NTDBTORTURE)
+fi
+
 SMB_LIBRARY(netapi, 0)
 SMB_LIBRARY(smbclient, 0)
 SMB_LIBRARY(smbsharemodes, 0)