fstests: GDBM detection cleanup
cover fstests: GDBM detection cleanup
From: Jeff Mahoney <[email protected]>
Commit 2353022 (build: update AC_PACKAGE_WANT_GDBM() and src/dbtest.c to build) fixed building on newer SUSE systems but broke older ones. Where we used to skip building src/dbtest on SLES systems, now we'd fail to build on SLES11. The reason was that we were now detecting ndbm.h but also including gdbm.h, which doesn't work on older systems due to both defining the datum type. It turns out that no system needs gdbm.h at all.
This series cleans up the macros and fixes detection for all systems that only have /usr/include/ndbm.h.
-Jeff
---
Jeff Mahoney (4):
build: remove dead AC_PACKAGE_WANT_NDBM macro
build: AC_PACKAGE_WANT_GDBM, fall back to compat if libgdbm detection
fails
build: clean up AC_PACKAGE_WANT_GDBM
build: fix <ndbm.h> detection in AC_PACKAGE_WANT_GDBM
m4/package_gdbmdev.m4 | 104 ++++++++++++++++++++++---------------------------- src/dbtest.c | 3 -- 2 files changed, 46 insertions(+), 61 deletions(-)
Signature · 1 line
2.15.1
PATCH 1/4 build: remove dead AC_PACKAGE_WANT_NDBM macro
From: Jeff Mahoney <[email protected]>
Commit fb05a918085 build: remove IRIX-specific build logic) removed the tests used on IRIX but missed AC_PACKAGE_WANT_NDBM.
--- m4/package_gdbmdev.m4 | 20 -------------------- 1 file changed, 20 deletions(-)
m4/package_gdbmdev.m4 +0 -20
@@ -1,23 +1,3 @@ -AC_DEFUN([AC_PACKAGE_WANT_NDBM], - [ AC_CHECK_HEADERS(ndbm.h, [ have_db=true ], [ have_db=false ]) - found=false - libgdbm="" - - if test $have_db = true; then - AC_CHECK_LIB(ndbm,dbm_open,found=true,found=false) - AC_CHECK_LIB(ndbm,dbm_fetch,,found=false) - AC_CHECK_LIB(ndbm,dbm_store,,found=false) - AC_CHECK_LIB(ndbm,dbm_close,,found=false) - - if test $found = true; then - libgdbm="$ndbm" - fi - fi - - AC_SUBST(libgdbm) - AC_SUBST(have_db) - ]) - AC_DEFUN([AC_PACKAGE_WANT_GDBM], [ AC_CHECK_HEADER(gdbm-ndbm.h, [ gdbm_ndbm=true; have_db=true ], [ gdbm_ndbm=false; have_db=false ])
Signature · 1 line
2.15.1
PATCH 2/4 build: AC_PACKAGE_WANT_GDBM, fall back to compat if libgdbm detection fails
In reply to [email protected]From: Jeff Mahoney <[email protected]>
We currently check if libgdbm_compat contains the required symbols even if libgdbm does. Let's fall back only when necessary (which is pretty much always anyway).
--- m4/package_gdbmdev.m4 | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
m4/package_gdbmdev.m4 +9 -10
@@ -30,16 +30,15 @@ AC_DEFUN([AC_PACKAGE_WANT_GDBM], if test $found = true; then libgdbm="${libgdbm} -lgdbm" - fi - - found="no" - AC_CHECK_LIB(gdbm_compat,dbm_open,found=true,found=false,-lgdbm) - AC_CHECK_LIB(gdbm_compat,dbm_fetch,,found=false,-lgdbm) - AC_CHECK_LIB(gdbm_compat,dbm_store,,found=false,-lgdbm) - AC_CHECK_LIB(gdbm_compat,dbm_close,,found="no",-lgdbm) - - if test $found = true ; then - libgdbm="${libgdbm} -lgdbm_compat -lgdbm" + else + AC_CHECK_LIB(gdbm_compat,dbm_open,found=true,found=false,-lgdbm) + AC_CHECK_LIB(gdbm_compat,dbm_fetch,,found=false,-lgdbm) + AC_CHECK_LIB(gdbm_compat,dbm_store,,found=false,-lgdbm) + AC_CHECK_LIB(gdbm_compat,dbm_close,,found="false",-lgdbm) + + if test $found = true ; then + libgdbm="${libgdbm} -lgdbm_compat -lgdbm" + fi fi fi
Signature · 1 line
2.15.1
PATCH 3/4 build: clean up AC_PACKAGE_WANT_GDBM
In reply to [email protected]From: Jeff Mahoney <[email protected]>
The AC_PACKAGE_WANT_GDBM macro is not easily read. It's not doing anything particularly complex other than working through a set of alternatives for headers and libraries.
This patch cleans it up to be more readable. We also only attempt to check in libgdbm_compat if the checks in libgdbm fail.
--- m4/package_gdbmdev.m4 | 87 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 32 deletions(-)
m4/package_gdbmdev.m4 +55 -32
@@ -1,43 +1,66 @@ AC_DEFUN([AC_PACKAGE_WANT_GDBM], - [ AC_CHECK_HEADER(gdbm-ndbm.h, [ gdbm_ndbm=true; have_db=true ], [ gdbm_ndbm=false; have_db=false ]) + [ + have_db= + AC_CHECK_HEADER(gdbm-ndbm.h, + [ + have_db=true + AC_DEFINE(HAVE_GDBM_NDBM_H, [1], + [Define to 1 if you have the <gdbm-ndbm.h> header file.]) + ]) - if test $gdbm_ndbm = true; then - AC_DEFINE(HAVE_GDBM_NDBM_H, [1], [Define to 1 if you have the <gdbm-ndbm.h> header file.]) - else - AS_UNSET([ac_cv_header_gdbm_ndbm_h]) - AC_CHECK_HEADER(gdbm/ndbm.h, [ gdbm_ndbm_=true; have_db=true ], [ gdbm_ndbm_=false; have_db=false ]) - if test $gdbm_ndbm_ = true; then - AC_DEFINE(HAVE_GDBM_NDBM_H_, [1], [Define to 1 if you have the <gdbm/ndbm.h> header file.]) - else - AC_CHECK_HEADER(gdbm.h, [ gdbm_ndbm_=true; have_db=true ], [ gdbm_ndbm_=false; have_db=false ]) - AC_CHECK_HEADER(ndbm.h, [ ndbm_=true ], [ ndbm_=false ]) - if test $gdbm_ndbm_ = true; then - if test $ndbm_ = true; then - AC_DEFINE(HAVE_GDBM_H, [1], [Define to 1 if you have both <gdbm.h> and <ndbm.h> header files.]) - fi - fi - fi + if test -z "$have_db"; then + dnl gdbm-ndbm.h and gdbm/ndbm.h map to the same autoconf internal + dnl variable. We need to clear it or this test will be skipped + dnl and the cached result from first test will be used. + AS_UNSET([ac_cv_header_gdbm_ndbm_h]) + AC_CHECK_HEADER(gdbm/ndbm.h, + [ + have_db=true + AC_DEFINE(HAVE_GDBM_NDBM_H_, [1], + [Define to 1 if you have the <gdbm/ndbm.h> header file.]) + ]) fi - found=false - libgdbm="" + if test -z "$have_db"; then + AC_CHECK_HEADER(gdbm.h, + [ + have_db=true + gdbm_ndbm_=true + ], [ + have_db=false + gdbm_ndbm_=false + ]) + AC_CHECK_HEADER(ndbm.h, + [ + ndbm_=true + ], [ + ndbm_=false + ]) + if test $gdbm_ndbm_ = true; then + if test $ndbm_ = true; then + AC_DEFINE(HAVE_GDBM_H, [1], + [Define to 1 if you have both <gdbm.h> and <ndbm.h> header files.]) + fi + fi + fi - if test $have_db = true; then - AC_CHECK_LIB(gdbm,dbm_open,found=true,found=false) - AC_CHECK_LIB(gdbm,dbm_fetch,,found=false) - AC_CHECK_LIB(gdbm,dbm_store,,found=false) - AC_CHECK_LIB(gdbm,dbm_close,,found=false) + if test "$have_db" = true; then + found=false + AC_CHECK_LIB(gdbm, dbm_open, found=true, found=false) + AC_CHECK_LIB(gdbm, dbm_fetch,, found=false) + AC_CHECK_LIB(gdbm, dbm_store,, found=false) + AC_CHECK_LIB(gdbm, dbm_close,, found=false) - if test $found = true; then - libgdbm="${libgdbm} -lgdbm" + if test "$found" = true; then + libgdbm="-lgdbm" else - AC_CHECK_LIB(gdbm_compat,dbm_open,found=true,found=false,-lgdbm) - AC_CHECK_LIB(gdbm_compat,dbm_fetch,,found=false,-lgdbm) - AC_CHECK_LIB(gdbm_compat,dbm_store,,found=false,-lgdbm) - AC_CHECK_LIB(gdbm_compat,dbm_close,,found="false",-lgdbm) + AC_CHECK_LIB(gdbm_compat, dbm_open, found=true, found=false, -lgdbm) + AC_CHECK_LIB(gdbm_compat, dbm_fetch,, found=false, -lgdbm) + AC_CHECK_LIB(gdbm_compat, dbm_store,, found=false, -lgdbm) + AC_CHECK_LIB(gdbm_compat, dbm_close,, found="no", -lgdbm) - if test $found = true ; then - libgdbm="${libgdbm} -lgdbm_compat -lgdbm" + if test "$found" = "true"; then + libgdbm="-lgdbm_compat -lgdbm" fi fi fi
Signature · 1 line
2.15.1
PATCH 4/4 build: fix <ndbm.h> detection in AC_PACKAGE_WANT_GDBM
In reply to [email protected]From: Jeff Mahoney <[email protected]>
SUSE systems export the NDBM interface via /usr/include/ndbm.h
This means that dbtest wasn't built on SUSE systems until commit 2353022 (build: update AC_PACKAGE_WANT_GDBM() and src/dbtest.c to build). That change was incompatible with older
SLES releases due to <ndbm.h> and <gdbm.h> both defining the datum type, resulting in build failures.
Nothing has ever set HAVE_GDBM_H or checked for the <gdbm.h> header prior to the above commit, and it's not required on SUSE systems either, so just remove that entirely.
--- m4/package_gdbmdev.m4 | 20 +++----------------- src/dbtest.c | 3 --- 2 files changed, 3 insertions(+), 20 deletions(-)
m4/package_gdbmdev.m4 +3 -17
@@ -22,26 +22,12 @@ AC_DEFUN([AC_PACKAGE_WANT_GDBM], fi if test -z "$have_db"; then - AC_CHECK_HEADER(gdbm.h, - [ - have_db=true - gdbm_ndbm_=true - ], [ - have_db=false - gdbm_ndbm_=false - ]) AC_CHECK_HEADER(ndbm.h, [ - ndbm_=true - ], [ - ndbm_=false + have_db=true + AC_DEFINE(HAVE_NDBM_H, [1], + [Define to 1 if you have the <ndbm.h> header file.]) ]) - if test $gdbm_ndbm_ = true; then - if test $ndbm_ = true; then - AC_DEFINE(HAVE_GDBM_H, [1], - [Define to 1 if you have both <gdbm.h> and <ndbm.h> header files.]) - fi - fi fi if test "$have_db" = true; then
src/dbtest.c +0 -3
@@ -22,9 +22,6 @@#include <gdbm/ndbm.h> #elif HAVE_GDBM_NDBM_H #include <gdbm-ndbm.h> -#elif HAVE_GDBM_H -#include <gdbm.h> -#include <ndbm.h> #elif HAVE_NDBM_H #include <ndbm.h> #else
Signature · 1 line
2.15.1
Quoted 10 lines · On Thu, Mar 15, 2018 at 05:54:51PM -0400, [email protected] wrote:
From: Jeff Mahoney <[email protected]>
Commit 2353022 (build: update
AC_PACKAGE_WANT_GDBM()andsrc/dbtest.cto build) fixed building on newer SUSE systems but broke older ones. Where we used to skip building src/dbtest on SLES systems, now we'd fail to build on SLES11. The reason was that we were now detectingndbm.hbut also includinggdbm.h, which doesn't work on older systems due to both defining the datum type. It turns out that no system needsgdbm.hat all.
Quoted 2 lines
This series cleans up the macros and fixes detection for all systems that only have
/usr/include/ndbm.h.
Thanks for the fixes and cleanups! I tested them on Fedora 27, RHEL7 and Debian stretch, with/without gdbm devel package installed, all worked fine. But I don't have SUSE systems by hand, I assume you've tested them successfully.
Thanks,
Eryu