From b7387a5e0d6e7adc28758e1f7597387d318e6ea7 Mon Sep 17 00:00:00 2001 From: Skip Montanaro Date: Sat, 6 Dec 2008 17:39:54 +0000 Subject: [PATCH] issue4483: dbm build failures on systems with gdbm_compat lib. --- Misc/NEWS | 3 +++ Modules/dbmmodule.c | 3 +++ setup.py | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index 876abc82e4b..0fac2aafba7 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -23,6 +23,9 @@ Core and Builtins Library ------- +- Issue #4483: _dbm module now builds on systems with gdbm & gdbm_compat + libs. + - FileIO's mode attribute now always includes ``"b"``. diff --git a/Modules/dbmmodule.c b/Modules/dbmmodule.c index c91ea471a05..0c50b5454c2 100644 --- a/Modules/dbmmodule.c +++ b/Modules/dbmmodule.c @@ -21,6 +21,9 @@ static char *which_dbm = "GNU gdbm"; /* EMX port of GDBM */ #elif defined(HAVE_GDBM_NDBM_H) #include static char *which_dbm = "GNU gdbm"; +#elif defined(HAVE_GDBM_DASH_NDBM_H) +#include +static char *which_dbm = "GNU gdbm"; #elif defined(HAVE_BERKDB_H) #include static char *which_dbm = "Berkeley DB"; diff --git a/setup.py b/setup.py index 5c37e4553f2..e7d3ad3ba57 100644 --- a/setup.py +++ b/setup.py @@ -1019,8 +1019,20 @@ class PyBuildExt(build_ext): exts.append( Extension('dbm', ['dbmmodule.c'], define_macros=[('HAVE_NDBM_H',None)], libraries = ndbm_libs ) ) - elif (self.compiler.find_library_file(lib_dirs, 'gdbm') - and find_file("gdbm/ndbm.h", inc_dirs, []) is not None): + elif self.compiler.find_library_file(lib_dirs, 'gdbm'): + gdbm_libs = ['gdbm'] + if self.compiler.find_library_file(lib_dirs, 'gdbm_compat'): + gdbm_libs.append('gdbm_compat') + if find_file("gdbm/ndbm.h", inc_dirs, []) is not None: + exts.append( Extension( + 'dbm', ['dbmmodule.c'], + define_macros=[('HAVE_GDBM_NDBM_H',None)], + libraries = gdbm_libs ) ) + elif find_file("gdbm-ndbm.h", inc_dirs, []) is not None: + exts.append( Extension( + 'dbm', ['dbmmodule.c'], + define_macros=[('HAVE_GDBM_DASH_NDBM_H',None)], + libraries = gdbm_libs ) ) exts.append( Extension('dbm', ['dbmmodule.c'], define_macros=[('HAVE_GDBM_NDBM_H',None)], libraries = ['gdbm'] ) )