gdb: add python-config override options

https://sourceware.org/pipermail/gdb-patches/2021-October/182911.html
This commit is contained in:
Alexey Lapshin
2021-11-17 14:51:13 +03:00
parent 1eba16c2b1
commit 8b1ed4d93d
2 changed files with 109 additions and 45 deletions

75
gdb/configure vendored
View File

@ -936,6 +936,8 @@ with_libexpat_prefix
with_libexpat_type
with_python
with_python_libdir
with_python_includes
with_python_ldflags
with_guile
enable_source_highlight
enable_threading
@ -1703,6 +1705,8 @@ Optional Packages:
(auto/yes/no/<python-program>)
--with-python-libdir[=DIR]
search for python's libraries in DIR
--with-python-includes override python-config --includes
--with-python-ldflags override python-config --ldflags
--with-guile[=GUILE] include guile support
(auto/yes/no/<guile-version>/<pkg-config-program>)
--with-intel-pt include Intel Processor Trace support (auto/yes/no)
@ -21665,6 +21669,31 @@ $as_echo_n "checking whether to use python... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_python" >&5
$as_echo "$with_python" >&6; }
# Check whether --with-python-libdir was given.
if test "${with_python_libdir+set}" = set; then :
withval=$with_python_libdir;
fi
# Check whether --with-python-includes was given.
if test "${with_python_includes+set}" = set; then :
withval=$with_python_includes;
python_includes="${with_python_includes}"
fi
# Check whether --with-python-ldflags was given.
if test "${with_python_ldflags+set}" = set; then :
withval=$with_python_ldflags;
python_libs="${with_python_ldflags}"
fi
if test "${with_python}" = no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: python support disabled; some features may be unavailable." >&5
$as_echo "$as_me: WARNING: python support disabled; some features may be unavailable." >&2;}
@ -21824,21 +21853,33 @@ fi
# 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`
if test -z "${python_includes}"; then
python_includes=`${python_prog} ${srcdir}/python/python-config.py --includes`
else
true
fi
if test $? != 0; then
have_python_config=failed
if test "${with_python}" != auto; then
as_fn_error $? "failure running python-config --includes" "$LINENO" 5
fi
fi
python_libs=`${python_prog} ${srcdir}/python/python-config.py --ldflags`
if test -z "${python_libs}"; then
python_libs=`${python_prog} ${srcdir}/python/python-config.py --ldflags`
else
true
fi
if test $? != 0; then
have_python_config=failed
if test "${with_python}" != auto; then
as_fn_error $? "failure running python-config --ldflags" "$LINENO" 5
fi
fi
python_prefix=`${python_prog} ${srcdir}/python/python-config.py --exec-prefix`
if test -z "${with_python_libdir}"; then
python_prefix=`${python_prog} ${srcdir}/python/python-config.py --exec-prefix`
else
true
fi
if test $? != 0; then
have_python_config=failed
if test "${with_python}" != auto; then
@ -21851,9 +21892,11 @@ fi
# path from the python_prefix either, because that include path
# depends on the Python version. So, there is nothing much we can
# do except assume that the compiler will be able to find those files.
python_includes=
python_libs=
have_python_config=no
if test -n "${python_includes}" && test -n "${python_libs}" ; then
have_python_config=yes
else
have_python_config=no
fi
fi
# If we have python-config, only try the configuration it provides.
@ -21951,21 +21994,6 @@ _ACEOF
fi
fi
# Check whether --with-python-libdir was given.
if test "${with_python_libdir+set}" = set; then :
withval=$with_python_libdir;
else
# If no python libdir is specified then select one based on
# python's prefix path.
if test -n "${python_prefix}"; then
with_python_libdir=${python_prefix}/lib
fi
fi
if test "${have_libpython}" != no; then
$as_echo "#define HAVE_PYTHON 1" >>confdefs.h
@ -21976,6 +22004,11 @@ $as_echo "#define HAVE_PYTHON 1" >>confdefs.h
CONFIG_INSTALL="$CONFIG_INSTALL install-python"
ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_PYTHON_CFLAGS)"
# If no python libdir is specified then select one based on
# python's prefix path.
if -z "${with_python_libdir}" && test -n "${python_prefix}" ; then
with_python_libdir=${python_prefix}/lib
fi
if test -n "${with_python_libdir}"; then
cat >>confdefs.h <<_ACEOF

View File

@ -777,6 +777,36 @@ AC_ARG_WITH(python,
AC_MSG_CHECKING([whether to use python])
AC_MSG_RESULT([$with_python])
dnl Use --with-python-libdir to control where GDB looks for the Python
dnl libraries.
dnl
dnl If this is not given then the default will be based on the value
dnl passed to --with-python, which is in the python_prefix variable.
dnl If the --with-python option wasn't given then the default value in
dnl python_prefix is based on running the 'gdb/python/python-config
dnl --exec-prefix' script.
AC_ARG_WITH(python-libdir,
AS_HELP_STRING([--with-python-libdir@<:@=DIR@:>@], [search for python's libraries in DIR]),
[],[])
dnl Use --with-python-includes to override python-config values
dnl
dnl If this is given then using instead of python-config --includes
AC_ARG_WITH(python-includes,
AS_HELP_STRING([--with-python-includes], [override python-config --includes]),
[
python_includes="${with_python_includes}"
],[])
dnl Use --with-python-ldflags to override python-config values
dnl
dnl If this is given then using instead of python-config --ldflags
AC_ARG_WITH(python-ldflags,
AS_HELP_STRING([--with-python-ldflags], [override python-config --ldflags]),
[
python_libs="${with_python_ldflags}"
],[])
if test "${with_python}" = no; then
AC_MSG_WARN([python support disabled; some features may be unavailable.])
have_libpython=no
@ -850,21 +880,33 @@ else
# 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`
if test -z "${python_includes}"; then
python_includes=`${python_prog} ${srcdir}/python/python-config.py --includes`
else
true
fi
if test $? != 0; then
have_python_config=failed
if test "${with_python}" != auto; then
AC_MSG_ERROR(failure running python-config --includes)
fi
fi
python_libs=`${python_prog} ${srcdir}/python/python-config.py --ldflags`
if test -z "${python_libs}"; then
python_libs=`${python_prog} ${srcdir}/python/python-config.py --ldflags`
else
true
fi
if test $? != 0; then
have_python_config=failed
if test "${with_python}" != auto; then
AC_MSG_ERROR(failure running python-config --ldflags)
fi
fi
python_prefix=`${python_prog} ${srcdir}/python/python-config.py --exec-prefix`
if test -z "${with_python_libdir}"; then
python_prefix=`${python_prog} ${srcdir}/python/python-config.py --exec-prefix`
else
true
fi
if test $? != 0; then
have_python_config=failed
if test "${with_python}" != auto; then
@ -877,9 +919,11 @@ else
# path from the python_prefix either, because that include path
# depends on the Python version. So, there is nothing much we can
# do except assume that the compiler will be able to find those files.
python_includes=
python_libs=
have_python_config=no
if [ test -n "${python_includes}" ] && [ test -n "${python_libs}" ]; then
have_python_config=yes
else
have_python_config=no
fi
fi
# If we have python-config, only try the configuration it provides.
@ -913,24 +957,6 @@ else
fi
fi
dnl Use --with-python-libdir to control where GDB looks for the Python
dnl libraries.
dnl
dnl If this is not given then the default will be based on the value
dnl passed to --with-python, which is in the python_prefix variable.
dnl If the --with-python option wasn't given then the default value in
dnl python_prefix is based on running the 'gdb/python/python-config
dnl --exec-prefix' script.
AC_ARG_WITH(python-libdir,
AS_HELP_STRING([--with-python-libdir@<:@=DIR@:>@], [search for python's libraries in DIR]),
[],[
# If no python libdir is specified then select one based on
# python's prefix path.
if test -n "${python_prefix}"; then
with_python_libdir=${python_prefix}/lib
fi
])
if test "${have_libpython}" != no; then
AC_DEFINE(HAVE_PYTHON, 1, [Define if Python interpreter is being linked in.])
CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_PYTHON_OBS)"
@ -939,6 +965,11 @@ if test "${have_libpython}" != no; then
CONFIG_INSTALL="$CONFIG_INSTALL install-python"
ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_PYTHON_CFLAGS)"
# If no python libdir is specified then select one based on
# python's prefix path.
if [ -z "${with_python_libdir}" ] && [ test -n "${python_prefix}" ]; then
with_python_libdir=${python_prefix}/lib
fi
if test -n "${with_python_libdir}"; then
AC_DEFINE_UNQUOTED(WITH_PYTHON_LIBDIR, "${with_python_libdir}",
[Directory containing Python's standard libraries from --with-python-libdir.])