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