package/gdb: do not hard-code python version in gdb-python-config
authorYann E. MORIN <yann.morin.1998@free.fr>
Thu, 31 Dec 2020 09:53:11 +0000 (10:53 +0100)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Thu, 31 Dec 2020 13:44:03 +0000 (14:44 +0100)
The gdb-python-config simulates a python-2.7, with a hard-coded 2.7
version.

gdb also supports running with python3 nowadays, so prepare the wrapper
to return appropriate values.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/gdb/gdb-python-config
package/gdb/gdb.mk

index 222f1cf6baef52bbd42e6698e7252ecdb7620241..640c3583053859a16968ee68c46f4ecc015b0cc9 100755 (executable)
@@ -17,14 +17,19 @@ if [ $# -ne 2 ] ; then
     exit 1
 fi
 
+if [ -z "${BR_PYTHON_VERSION}" ]; then
+    echo "Environment variable BR_PYTHON_VERSION not set." >&2
+    exit 1
+fi
+
 # The first argument is the path to python-config.py, ignore it.
 
 case "$2" in
     --includes)
-        echo "-I${STAGING_DIR}/usr/include/python2.7"
+        echo "-I${STAGING_DIR}/usr/include/python${BR_PYTHON_VERSION}"
         ;;
     --ldflags)
-        echo "-lpthread -ldl -lutil -lm -lpython2.7"
+        echo "-lpthread -ldl -lutil -lm -lpython${BR_PYTHON_VERSION}"
         ;;
     --exec-prefix)
         echo "/usr"
index c74279a43e160b5f90a2c599c8cce40bf951d1e2..e35ece01536e99b0a0c0cd14b08d3235870f0f79 100644 (file)
@@ -194,6 +194,9 @@ GDB_CONF_OPTS += --disable-tui
 endif
 
 ifeq ($(BR2_PACKAGE_GDB_PYTHON),y)
+# CONF_ENV: for top-level configure; MAKE_ENV: for sub-projects' configure.
+GDB_CONF_ENV += BR_PYTHON_VERSION=$(PYTHON_VERSION_MAJOR)
+GDB_MAKE_ENV += BR_PYTHON_VERSION=$(PYTHON_VERSION_MAJOR)
 GDB_CONF_OPTS += --with-python=$(TOPDIR)/package/gdb/gdb-python-config
 GDB_DEPENDENCIES += python
 else