[PATCH] Modify python-config.py or replace it with official one to support python3

傅继晗 fjhhz1997@gmail.com
Wed Jan 22 06:12:00 GMT 2020


add warning to explain that if no python-config found,fall back to
internal copy "gdb/python/python-config.py"


--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -834,29 +834,36 @@ else
     esac
   esac

+  python_config=
   if test "${python_prog}" != missing; then
+    AC_CHECK_FILE([${python_prog}-config],[python_config="${python_prog}-config"],[python_config="${python_prog}
${srcdir}/python/python-config.py"
+AC_MSG_WARN(python-config not found! Fall back to internal copy.)])
     # We have a python program to use, but it may be too old.
     # Don't flag an error for --with-python=auto (the default).
     have_python_config=yes
-    python_includes=`${python_prog} ${srcdir}/python/python-config.py
--includes`
+    python_includes=`${python_config} --includes`
     if test $? != 0; then
       have_python_config=failed
       if test "${with_python}" != auto; then
-        AC_ERROR(failure running python-config --includes)
+        AC_ERROR(failure running ${python_config} --includes)
       fi
     fi
-    python_libs=`${python_prog} ${srcdir}/python/python-config.py --ldflags`
+# For python 3.8+ there must be a "--embed" flag to show lib version.
+    python_libs=`${python_config} --ldflags --embed`
     if test $? != 0; then
-      have_python_config=failed
-      if test "${with_python}" != auto; then
-        AC_ERROR(failure running python-config --ldflags)
+      python_libs=`${python_config} --ldflags`
+      if test $? != 0; then
+        have_python_config=failed
+        if test "${with_python}" != auto; then
+          AC_ERROR(failure running ${python_config} --ldflags)
+        fi
       fi
     fi
-    python_prefix=`${python_prog} ${srcdir}/python/python-config.py
--exec-prefix`
+    python_prefix=`${python_config} --exec-prefix`
     if test $? != 0; then
       have_python_config=failed
       if test "${with_python}" != auto; then
-        AC_ERROR(failure running python-config --exec-prefix)
+        AC_ERROR(failure running ${python_config} --exec-prefix)
       fi
     fi
   else
-------------- next part --------------
A non-text attachment was scrubbed...
Name: python-config.patch
Type: application/octet-stream
Size: 1930 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20200122/2dc7acd9/attachment.obj>


More information about the Gdb-patches mailing list