diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f5cc6722da..397451fd01 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/configure.ac b/configure.ac index 5cb7651d62..276ac0f8d3 100644 --- a/configure.ac +++ b/configure.ac @@ -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 "-------------------------------------------------------------------------------" diff --git a/lib/isc/Makefile.am b/lib/isc/Makefile.am index 98a3525522..214b460252 100644 --- a/lib/isc/Makefile.am +++ b/lib/isc/Makefile.am @@ -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) diff --git a/lib/isc/include/isc/lmdb.h b/lib/isc/include/isc/lmdb.h index 391303c24f..e31bfc3c16 100644 --- a/lib/isc/include/isc/lmdb.h +++ b/lib/isc/include/isc/lmdb.h @@ -13,7 +13,11 @@ #pragma once +#ifdef HAVE_LMDB #include +#else +#include "../../openldap-lmdb/lmdb.h" +#endif #define DNS_LMDB_COMMON_FLAGS (MDB_NOSUBDIR | MDB_NOLOCK) #ifndef __OpenBSD__ diff --git a/lib/isc/include/isc/openldap-lmdb.h b/lib/isc/openldap-lmdb/lmdb.h similarity index 99% rename from lib/isc/include/isc/openldap-lmdb.h rename to lib/isc/openldap-lmdb/lmdb.h index 199382a14c..f68dbe7608 100644 --- a/lib/isc/include/isc/openldap-lmdb.h +++ b/lib/isc/openldap-lmdb/lmdb.h @@ -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 * diff --git a/lib/isc/lmdb/mdb.c b/lib/isc/openldap-lmdb/mdb.c similarity index 99% rename from lib/isc/lmdb/mdb.c rename to lib/isc/openldap-lmdb/mdb.c index 668f9660f2..df64c6c5f9 100644 --- a/lib/isc/lmdb/mdb.c +++ b/lib/isc/openldap-lmdb/mdb.c @@ -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 * diff --git a/lib/isc/lmdb/midl.c b/lib/isc/openldap-lmdb/midl.c similarity index 94% rename from lib/isc/lmdb/midl.c rename to lib/isc/openldap-lmdb/midl.c index dc3a1f578c..a0476ef602 100644 --- a/lib/isc/lmdb/midl.c +++ b/lib/isc/openldap-lmdb/midl.c @@ -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$ */ diff --git a/lib/isc/lmdb/midl.h b/lib/isc/openldap-lmdb/midl.h similarity index 93% rename from lib/isc/lmdb/midl.h rename to lib/isc/openldap-lmdb/midl.h index 1abdc8af2a..113ee9d3ed 100644 --- a/lib/isc/lmdb/midl.h +++ b/lib/isc/openldap-lmdb/midl.h @@ -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. *