summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Klose <doko@ubuntu.com>2009-04-30 08:06:49 (GMT)
committerMatthias Klose <doko@ubuntu.com>2009-04-30 08:06:49 (GMT)
commit55708cce31442d13768843d85f424208e9fd0f42 (patch)
treed026dbd0166ca0943634679ce3324e43b4d5420f
parent58a42244cfefc96b7adada5344b231ff2f32a86a (diff)
downloadcpython-55708cce31442d13768843d85f424208e9fd0f42.zip
cpython-55708cce31442d13768843d85f424208e9fd0f42.tar.gz
cpython-55708cce31442d13768843d85f424208e9fd0f42.tar.bz2
- Issue #4587: Add configure option --with-dbmliborder=db1:db2:... to specify
the order that backends for the dbm extension are checked.
-rw-r--r--Misc/NEWS3
-rwxr-xr-xconfigure33
-rw-r--r--configure.in18
-rw-r--r--setup.py94
4 files changed, 116 insertions, 32 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index a14682a..257762b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -880,6 +880,9 @@ Tools/Demos
Build
-----
+- Issue #4587: Add configure option --with-dbmliborder=db1:db2:... to specify
+ the order that backends for the dbm extension are checked.
+
- Link the shared python library with $(MODLIBS).
- Issue #5134: Silence compiler warnings when compiling sqlite with VC++.
diff --git a/configure b/configure
index 6d0b8e8..d1da285 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Revision: 71723 .
+# From configure.in Revision: 71731 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for python 3.1.
#
@@ -1340,6 +1340,10 @@ Optional Packages:
--with-pydebug build with Py_DEBUG defined
--with-libs='lib1 ...' link against additional libs
--with-system-ffi build _ctypes module using an installed ffi library
+ --with-dbmliborder=db1:db2:...
+ order to check db backends for dbm. Valid value is a
+ colon separated string with the backend names
+ `ndbm', `gdbm' and `bdb'.
--with-signal-module disable/enable signal module
--with-dec-threads use DEC Alpha/OSF1 thread-safe libraries
--with(out)-threads[=DIRECTORY]
@@ -14087,6 +14091,33 @@ fi
{ echo "$as_me:$LINENO: result: $with_system_ffi" >&5
echo "${ECHO_T}$with_system_ffi" >&6; }
+# Check for --with-dbmliborder
+{ echo "$as_me:$LINENO: checking for --with-dbmliborder" >&5
+echo $ECHO_N "checking for --with-dbmliborder... $ECHO_C" >&6; }
+
+# Check whether --with-dbmliborder was given.
+if test "${with_dbmliborder+set}" = set; then
+ withval=$with_dbmliborder;
+if test x$with_dbmliborder = xyes
+then
+{ { echo "$as_me:$LINENO: error: proper usage is --with-dbmliborder=db1:db2:..." >&5
+echo "$as_me: error: proper usage is --with-dbmliborder=db1:db2:..." >&2;}
+ { (exit 1); exit 1; }; }
+else
+ for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
+ if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
+ then
+ { { echo "$as_me:$LINENO: error: proper usage is --with-dbmliborder=db1:db2:..." >&5
+echo "$as_me: error: proper usage is --with-dbmliborder=db1:db2:..." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ done
+fi
+fi
+
+{ echo "$as_me:$LINENO: result: $with_dbmliborder" >&5
+echo "${ECHO_T}$with_dbmliborder" >&6; }
+
# Determine if signalmodule should be used.
diff --git a/configure.in b/configure.in
index 9bd2790..6a1e231 100644
--- a/configure.in
+++ b/configure.in
@@ -1837,6 +1837,24 @@ AC_ARG_WITH(system_ffi,
AC_MSG_RESULT($with_system_ffi)
+# Check for --with-dbmliborder
+AC_MSG_CHECKING(for --with-dbmliborder)
+AC_ARG_WITH(dbmliborder,
+ AC_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]),
+[
+if test x$with_dbmliborder = xyes
+then
+AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
+else
+ for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
+ if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
+ then
+ AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
+ fi
+ done
+fi])
+AC_MSG_RESULT($with_dbmliborder)
+
# Determine if signalmodule should be used.
AC_SUBST(USE_SIGNAL_MODULE)
AC_SUBST(SIGNAL_OBJS)
diff --git a/setup.py b/setup.py
index 03994de..ddd5452 100644
--- a/setup.py
+++ b/setup.py
@@ -913,37 +913,69 @@ class PyBuildExt(build_ext):
# The standard Unix dbm module:
if platform not in ['cygwin']:
- if find_file("ndbm.h", inc_dirs, []) is not None:
- # Some systems have -lndbm, others don't
- if self.compiler.find_library_file(lib_dirs, 'ndbm'):
- ndbm_libs = ['ndbm']
- else:
- ndbm_libs = []
- exts.append( Extension('_dbm', ['_dbmmodule.c'],
- define_macros=[('HAVE_NDBM_H',None)],
- libraries = ndbm_libs ) )
- 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 ) )
- elif db_incs is not None:
- exts.append( Extension('_dbm', ['_dbmmodule.c'],
- library_dirs=dblib_dir,
- runtime_library_dirs=dblib_dir,
- include_dirs=db_incs,
- define_macros=[('HAVE_BERKDB_H',None),
- ('DB_DBM_HSEARCH',None)],
- libraries=dblibs))
+ config_args = [arg.strip("'")
+ for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
+ dbm_args = [arg.split('=')[-1] for arg in config_args
+ if arg.startswith('--with-dbmliborder=')]
+ if dbm_args:
+ dbm_order = dbm_args[-1].split(":")
+ else:
+ dbm_order = "ndbm:gdbm:bdb".split(":")
+ dbmext = None
+ for cand in dbm_order:
+ if cand == "ndbm":
+ if find_file("ndbm.h", inc_dirs, []) is not None:
+ # Some systems have -lndbm, others don't
+ if self.compiler.find_library_file(lib_dirs, 'ndbm'):
+ ndbm_libs = ['ndbm']
+ else:
+ ndbm_libs = []
+ print("building dbm using ndbm")
+ dbmext = Extension('_dbm', ['_dbmmodule.c'],
+ define_macros=[
+ ('HAVE_NDBM_H',None),
+ ],
+ libraries=ndbm_libs)
+ break
+
+ elif cand == "gdbm":
+ if 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:
+ print("building dbm using gdbm")
+ dbmext = Extension(
+ '_dbm', ['_dbmmodule.c'],
+ define_macros=[
+ ('HAVE_GDBM_NDBM_H', None),
+ ],
+ libraries = gdbm_libs)
+ break
+ if find_file("gdbm-ndbm.h", inc_dirs, []) is not None:
+ print("building dbm using gdbm")
+ dbmext = Extension(
+ '_dbm', ['_dbmmodule.c'],
+ define_macros=[
+ ('HAVE_GDBM_DASH_NDBM_H', None),
+ ],
+ libraries = gdbm_libs)
+ break
+ elif cand == "bdb":
+ if db_incs is not None:
+ print("building dbm using bdb")
+ dbmext = Extension('_dbm', ['_dbmmodule.c'],
+ library_dirs=dblib_dir,
+ runtime_library_dirs=dblib_dir,
+ include_dirs=db_incs,
+ define_macros=[
+ ('HAVE_BERKDB_H', None),
+ ('DB_DBM_HSEARCH', None),
+ ],
+ libraries=dblibs)
+ break
+ if dbmext is not None:
+ exts.append(dbmext)
else:
missing.append('_dbm')