xref: /OK3568_Linux_fs/buildroot/package/gdb/gdb-python-config (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/sh
2
3# This shell script is used to fake Python. Gdb wants to be passed a
4# Python interpreter, to run its own python-config.py program, which
5# uses sysconfig. However, when cross-compiling, this doesn't work
6# well since we would have to use the host Python, whose sysconfig
7# module would return host values.
8#
9# As recommended at
10# https://sourceware.org/gdb/wiki/CrossCompilingWithPythonSupport,
11# this wrapper shell script can be used as a replacement. It ignores
12# the python-config.py script passed as first arguments, and
13# "emulates" its behavior.
14
15if [ $# -ne 2 ] ; then
16    echo "Bad # args." >&2
17    exit 1
18fi
19
20if [ -z "${BR_PYTHON_VERSION}" ]; then
21    echo "Environment variable BR_PYTHON_VERSION not set." >&2
22    exit 1
23fi
24
25# The first argument is the path to python-config.py, ignore it.
26
27case "$2" in
28    --includes)
29        echo "-I${STAGING_DIR}/usr/include/python${BR_PYTHON_VERSION}"
30        ;;
31    --ldflags)
32        echo "-lpthread -ldl -lutil -lm -lpython${BR_PYTHON_VERSION}"
33        ;;
34    --exec-prefix)
35        echo "/usr"
36        ;;
37    *)
38        echo "Bad arg $2." >&2
39        exit 1
40        ;;
41esac
42