Merged revisions 77212-77215 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77212 | benjamin.peterson | 2010-01-01 09:16:29 -0600 (Fri, 01 Jan 2010) | 1 line

  use pkg-config to find the libffi headers when --with-system-ffi is used #6943
........
  r77213 | benjamin.peterson | 2010-01-01 09:18:38 -0600 (Fri, 01 Jan 2010) | 1 line

  add note
........
  r77214 | benjamin.peterson | 2010-01-01 09:20:06 -0600 (Fri, 01 Jan 2010) | 1 line

  fix indentation
........
  r77215 | benjamin.peterson | 2010-01-01 09:21:13 -0600 (Fri, 01 Jan 2010) | 1 line

  allow --with-dbmliborder to specify that no dbm modules will be built #6491
........
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 82264e5..86d077c 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -214,6 +214,8 @@
 GRAMMAR_INPUT=	$(srcdir)/Grammar/Grammar
 
 
+LIBFFI_INCLUDEDIR=	@LIBFFI_INCLUDEDIR@
+
 ##########################################################################
 # Parser
 PGEN=		Parser/pgen$(EXE)
diff --git a/Misc/NEWS b/Misc/NEWS
index ba555ee..daee69c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -517,6 +517,11 @@
 Build
 -----
 
+- Issue #6491: Allow --with-dbmliborder to specify that no dbms will be built.
+
+- Issue #6943: Use pkg-config to find the libffi headers when the
+  --with-system-ffi flag is used.
+
 - Issue #7609: Add a --with-system-expat option that causes the system's expat
   library to be used for the pyexpat module instead of the one included with
   Python.
diff --git a/configure b/configure
index 1468ea7..cbd1c16 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 77190 .
+# From configure.in Revision: 77196 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for python 3.2.
 #
@@ -715,6 +715,8 @@
 LINKFORSHARED
 CFLAGSFORSHARED
 SHLIBS
+PKG_CONFIG
+LIBFFI_INCLUDEDIR
 USE_SIGNAL_MODULE
 SIGNAL_OBJS
 USE_THREAD_MODULE
@@ -15350,6 +15352,115 @@
 fi
 
 
+if test "$with_system_ffi" = "yes"; then
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { echo "$as_me:$LINENO: result: $ac_pt_PKG_CONFIG" >&5
+echo "${ECHO_T}$ac_pt_PKG_CONFIG" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+    LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
+else
+    LIBFFI_INCLUDEDIR=""
+fi
+
+
 { echo "$as_me:$LINENO: result: $with_system_ffi" >&5
 echo "${ECHO_T}$with_system_ffi" >&6; }
 
@@ -27732,6 +27843,8 @@
   cat >conf$$subs.sed <<_ACEOF
 CFLAGSFORSHARED!$CFLAGSFORSHARED$ac_delim
 SHLIBS!$SHLIBS$ac_delim
+PKG_CONFIG!$PKG_CONFIG$ac_delim
+LIBFFI_INCLUDEDIR!$LIBFFI_INCLUDEDIR$ac_delim
 USE_SIGNAL_MODULE!$USE_SIGNAL_MODULE$ac_delim
 SIGNAL_OBJS!$SIGNAL_OBJS$ac_delim
 USE_THREAD_MODULE!$USE_THREAD_MODULE$ac_delim
@@ -27754,7 +27867,7 @@
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 22; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 24; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/configure.in b/configure.in
index 0abb2ba..6635208 100644
--- a/configure.in
+++ b/configure.in
@@ -1872,6 +1872,14 @@
 AC_ARG_WITH(system_ffi,
             AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
 
+if test "$with_system_ffi" = "yes"; then
+    AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+    LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
+else
+    LIBFFI_INCLUDEDIR=""
+fi
+AC_SUBST(LIBFFI_INCLUDEDIR)
+
 AC_MSG_RESULT($with_system_ffi)
 
 # Check for --with-dbmliborder
diff --git a/setup.py b/setup.py
index 64201f3..c550962 100644
--- a/setup.py
+++ b/setup.py
@@ -887,14 +887,15 @@
         else:
             missing.append('_sqlite3')
 
+        dbm_order = ['gdbm']
         # The standard Unix dbm module:
         if platform not in ['cygwin']:
             config_args = [arg.strip("'")
                            for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
-            dbm_args = [arg.split('=')[-1] for arg in config_args
+            dbm_args = [arg for arg in config_args
                         if arg.startswith('--with-dbmliborder=')]
             if dbm_args:
-                dbm_order = dbm_args[-1].split(":")
+                dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(":")
             else:
                 dbm_order = "ndbm:gdbm:bdb".split(":")
             dbmext = None
@@ -958,7 +959,8 @@
                 missing.append('_dbm')
 
         # Anthony Baxter's gdbm module.  GNU dbm(3) will require -lgdbm:
-        if (self.compiler_obj.find_library_file(lib_dirs, 'gdbm')):
+        if ('gdbm' in dbm_order and
+            self.compiler_obj.find_library_file(lib_dirs, 'gdbm')):
             exts.append( Extension('_gdbm', ['_gdbmmodule.c'],
                                    libraries = ['gdbm'] ) )
         else:
@@ -1558,7 +1560,9 @@
             # in /usr/include/ffi
             inc_dirs.append('/usr/include/ffi')
 
-        ffi_inc = find_file('ffi.h', [], inc_dirs)
+        ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")]
+        if not ffi_inc:
+            ffi_inc = find_file('ffi.h', [], inc_dirs)
         if ffi_inc is not None:
             ffi_h = ffi_inc[0] + '/ffi.h'
             fp = open(ffi_h)