Index: setup.py =================================================================== --- setup.py (revision 67489) +++ setup.py (working copy) @@ -783,11 +783,31 @@ 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): - exts.append( Extension('_dbm', ['_dbmmodule.c'], - define_macros=[('HAVE_GDBM_NDBM_H',None)], - libraries = ['gdbm'] ) ) + elif self.compiler.find_library_file(lib_dirs, 'gdbm'): + gdbm_libs = ['gdbm'] + if not self.compiler.has_function("dbm_firstkey", + include_dirs=inc_dirs, + libraries=gdbm_libs, + library_dirs=lib_dirs): + # gdbm seems to be putting old dbm symbols in + # gdbm_compat library now, at least on some platforms + if (self.compiler.find_library_file(lib_dirs, + 'gdbm_compat') and + self.compiler.has_function("dbm_firstkey", + include_dirs=inc_dirs, + libraries=["gdbm_compat"], + library_dirs=lib_dirs)): + 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 ) ) elif db_incs is not None: exts.append( Extension('_dbm', ['_dbmmodule.c'], library_dirs=dblib_dir, Index: Modules/_dbmmodule.c =================================================================== --- Modules/_dbmmodule.c (revision 67489) +++ Modules/_dbmmodule.c (working copy) @@ -21,6 +21,9 @@ #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";