Various changes to integrate LMDB source files

- revert previous changes from configure.ac script in order to re-use
  the existing logic, as well as the gitlab ci flag which check build
  with two combinations.

- Conditionally build LMDB source code based on HAVE_LMDB. So if
  --without-lmdb is used, HAVE_LMDB won't be set and LMDB source code
  will be compiled and included in libisc. This enable code using LMDB
  to link no matter LMDB is OS-provided or not.

- Regarding the LMDB headers, and in order to make future LMDB update
  easier, all original OpenLDAP code is wrapped under
  lib/isc/openldap-lmdb including the headers. This avoid extra
  changes (putting aside liscence header) to mdb.c to find out its
  headers. The counter-part is the relative inclusion of this header
  from isc/lmdb.h header, but it's probably a good idea to not make
  this header public anyway.

- update LMDB license to add BIND9 SPDX headers but mentioning LMDB
  lisence
This commit is contained in:
Colin Vidal
2025-01-14 12:14:27 +01:00
parent 3929cbfe15
commit 0b5611bda7
8 changed files with 115 additions and 9 deletions
+4 -2
View File
@@ -1029,12 +1029,13 @@ unit:gcc:ossl3:amd64:
artifacts: true
# Jobs for regular GCC builds on Debian "sid" (amd64)
# Also tests configration option: --without-lmdb.
gcc:sid:amd64:
variables:
CC: gcc
CFLAGS: "${CFLAGS_COMMON} -O3"
EXTRA_CONFIGURE: "--with-libidn2 ${WITH_READLINE}"
EXTRA_CONFIGURE: "--with-libidn2 --without-lmdb ${WITH_READLINE}"
RUN_MAKE_INSTALL: 1
<<: *debian_sid_amd64_image
<<: *build_job
@@ -1055,13 +1056,14 @@ unit:gcc:sid:amd64:
artifacts: true
# Job for out-of-tree GCC build on Debian 12 "bookworm" (amd64)
# Also tests configration option: --with-lmdb.
gcc:out-of-tree:
variables:
CC: gcc
CFLAGS: "${CFLAGS_COMMON} -Og"
CONFIGURE: "${CI_PROJECT_DIR}/configure"
EXTRA_CONFIGURE: "--with-libidn2"
EXTRA_CONFIGURE: "--with-libidn2 --with-lmdb"
RUN_MAKE_INSTALL: 1
OUT_OF_TREE_WORKSPACE: workspace
<<: *base_image
+43 -5
View File
@@ -756,13 +756,49 @@ AC_SUBST([KRB5_CFLAGS])
AC_SUBST([KRB5_LIBS])
#
# LMDB is mandatory
# LMDB is mandatory, BIND9 source code provides an LMDB implementation
# if LMDB not installed on the OS
#
PKG_CHECK_MODULES([LMDB], [lmdb])
AX_SAVE_FLAGS([lmdb])
# `--with-lmdb=auto` picks the OS version if installed, or the
# provided version otherwise.
# `--with-lmdb=yes` picks the OS version, fails if not installed.
# `--without-lmdb` picks the provided version.
#
# [pairwise: --with-lmdb=auto, --with-lmdb=yes, --without-lmdb]
#
AC_ARG_WITH([lmdb],
[AS_HELP_STRING([--with-lmdb=@<:@PATH@:>@],
[use LMDB library @<:@default=auto@:>@, optionally specify the prefix for lmdb library])],
[:],
[with_lmdb="auto"])
CFLAGS="$CFLAGS $LMDB_CFLAGS"
LIBS="$LIBS $LMDB_LIBS"
ac_lib_lmdb_found=no
AS_CASE([$with_lmdb],
[no],[],
[auto|yes], [PKG_CHECK_MODULES([LMDB], [lmdb],
[ac_lib_lmdb_found=yes],
[for ac_lib_lmdb_path in /usr /usr/local /opt /opt/local; do
AX_LIB_LMDB([$ac_lib_lmdb_path],
[ac_lib_lmdb_found=yes
break])
done
])],
[AX_LIB_LMDB([$with_lmdb],[ac_lib_lmdb_found=yes])])
# don't fail when in automatic mode
AS_IF([test "$with_lmdb" = "auto" && test "$ac_lib_lmdb_found" = "no"],
[with_lmdb=no])
# hard fail when LMDB requested, but not found
AS_IF([test "$with_lmdb" != "no" && test "$ac_lib_lmdb_found" != "yes"],
[AC_MSG_ERROR([LMDB requested, but not found])])
AS_IF([test "$ac_lib_lmdb_found" = "yes"],
[AC_DEFINE([HAVE_LMDB], [1], [Use lmdb library])])
AC_SUBST([LMDB_CFLAGS])
AC_SUBST([LMDB_LIBS])
AM_CONDITIONAL([HAVE_LMDB], [test -n "$LMDB_LIBS"])
#
# was --with-libxml2 specified?
@@ -1489,6 +1525,7 @@ report() {
test -z "$LIBXML2_LIBS" || echo " XML statistics (--with-libxml2)"
test -z "$JSON_C_LIBS" || echo " JSON statistics (--with-json-c): $JSON_C_CFLAGS $JSON_C_LIBS"
test -z "$ZLIB_LIBS" || echo " HTTP zlib compression (--with-zlib)"
test -z "$LMDB_LIBS" || echo " LMDB database to store configurations (--with-lmdb)"
test -z "$LIBIDN2_LIBS" || echo " IDN support (--with-libidn2)"
fi
@@ -1550,6 +1587,7 @@ report() {
test -z "$LIBXML2_LIBS" && echo " XML statistics (--with-libxml2)"
test -z "$JSON_C_LIBS" && echo " JSON statistics (--with-json-c)"
test -z "$ZLIB_LIBS" && echo " HTTP zlib compression (--with-zlib)"
test -z "$LMDB_LIBS" && echo " LMDB database to store configurations (--with-lmdb)"
test -z "$LIBIDN2_LIBS" && echo " IDN support (--with-libidn2)"
echo "-------------------------------------------------------------------------------"
+12 -2
View File
@@ -216,7 +216,6 @@ libisc_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(LIBISC_CFLAGS) \
$(LIBUV_CFLAGS) \
$(LMDB_CFLAGS) \
$(OPENSSL_CFLAGS) \
$(ZLIB_CFLAGS)
@@ -226,7 +225,6 @@ libisc_la_LDFLAGS = \
libisc_la_LIBADD = \
$(LIBUV_LIBS) \
$(LMDB_LIBS) \
$(OPENSSL_LIBS) \
$(ZLIB_LIBS)
@@ -265,6 +263,18 @@ libisc_la_LIBADD += \
$(LIBXML2_LIBS)
endif HAVE_LIBXML2
if HAVE_LMDB
libisc_la_CPPFLAGS += \
$(LMDB_CFLAGS)
libisc_la_LDFLAGS += \
$(LMDB_LIBS)
else
libisc_la_SOURCES += \
openldap-lmdb/mdb.c
libisc_la_SOURCES += \
openldap-lmdb/midl.c
endif
if !HAVE_SYSTEMTAP
DTRACE_DEPS = libisc_la-rwlock.lo libisc_la-job.lo
DTRACE_OBJS = .libs/libisc_la-rwlock.$(OBJEXT) .libs/libisc_la-job.$(OBJEXT)
+4
View File
@@ -13,7 +13,11 @@
#pragma once
#ifdef HAVE_LMDB
#include <lmdb.h>
#else
#include "../../openldap-lmdb/lmdb.h"
#endif
#define DNS_LMDB_COMMON_FLAGS (MDB_NOSUBDIR | MDB_NOLOCK)
#ifndef __OpenBSD__
@@ -1,3 +1,16 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the OpenLDAP
* Public License. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See license comment below for additional information regarding
* copyright ownership.
*/
/** @file lmdb.h
* @brief Lightning memory-mapped database library
*
@@ -1,3 +1,16 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the OpenLDAP
* Public License. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See license comment below for additional information regarding
* copyright ownership.
*/
/** @file mdb.c
* @brief Lightning memory-mapped database library
*
@@ -1,3 +1,16 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the OpenLDAP
* Public License. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See license comment below for additional information regarding
* copyright ownership.
*/
/** @file midl.c
* @brief ldap bdb back-end ID List functions */
/* $OpenLDAP$ */
@@ -1,3 +1,16 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the OpenLDAP
* Public License. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See license comment below for additional information regarding
* copyright ownership.
*/
/** @file midl.h
* @brief LMDB ID List header file.
*