diff options
author | Joel Brobecker <brobecker@gnat.com> | 2011-01-31 04:41:27 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2011-01-31 04:41:27 +0000 |
commit | ac534cba292dd37e6c0e2a6e30e455a92018cf66 (patch) | |
tree | b4d315f2bc935a85dc019f9a2072fb272e51f95a /gdb/configure.ac | |
parent | c2f0d045af0d6add5f901d7d2f5175f289054978 (diff) | |
download | gdb-ac534cba292dd37e6c0e2a6e30e455a92018cf66.zip gdb-ac534cba292dd37e6c0e2a6e30e455a92018cf66.tar.gz gdb-ac534cba292dd37e6c0e2a6e30e455a92018cf66.tar.bz2 |
do not use python<version> subdir when including Python .h file
This is preparation work for being able to build GDB with Python
support on MinGW.
So far, the "python<version>" subdirectory needs to be specified
when including a Python header file. In order to do that, we have
some special configury that tweaks the include path returned by
python-config.py such that the use of the subdirectory in the include
is necessary. This was done in order to protect ourselves from
possible filename conflicts, since some of the filenames chosen by
Python were a little generic.
The problem is that this cannot work with a standard Python install
on MinGW systems. On such systems, the .h files are located in
<python_prefix>/include. So, in preparation for allowing us to build
GDB on MinGW with Python support enabled, this patch changes the
requirement to provide the "python<version>" subdirectory in the
include directive.
The positive consequence is that we no longer need to have a set
of #include directives for each version of Python, since the include
directive is now the same for all versions of Python. However, the
downside is that we are losing the level of protection we were trying
to achieve by forcing the subdirectory in the include directive.
In order to reduce a bit the consequences of a possible conflict,
this patch also changes the location where the -I/path/to/python
switch goes, to be last in the list (suggested by Doug Evans).
One last change is the fact that we are now including Python.h
and all other Python include headers using angle brackets rather
than double-quotes. This fixes a problem on case-insensitive
systems where #include "Python.h" causes our gdb/python/python.h
header to be included instead of Python's <Python.h> header.
gdb/ChangeLog:
* configure.ac: Remove fallback behavior for building
against Python. Remove tweaking of Python include path.
Add PYTHON_CPPFLAGS and PYTHON_LIBS substitution.
(AC_TRY_LIBPYTHON): Adjust program used in linking test.
If link is successful, set PYTHON_CPPFLAGS and PYTHON_LIBS.
Always restore CPPFLAGS and LIBS after linking test.
* configure: Regenerated.
* Makefile.in (INTERNAL_CPPFLAGS): Add @PYTHON_CPPFLAGS@.
(INSTALLED_LIBS, CLIBS): Add @PYTHON_LIBS@.
* python/python-internal.h: Adjust includes of Python .h files.
Diffstat (limited to 'gdb/configure.ac')
-rw-r--r-- | gdb/configure.ac | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/gdb/configure.ac b/gdb/configure.ac index 4be35bc..afb7314 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -610,12 +610,14 @@ AC_DEFUN([AC_TRY_LIBPYTHON], CPPFLAGS="$CPPFLAGS $new_CPPFLAGS" LIBS="$LIBS $new_LIBS" found_usable_python=no - AC_LINK_IFELSE(AC_LANG_PROGRAM([[#include "${version}/Python.h"]], + AC_LINK_IFELSE(AC_LANG_PROGRAM([[#include "Python.h"]], [[Py_Initialize ();]]), [have_libpython_var=${version} - found_usable_python=yes], - [CPPFLAGS=$save_CPPFLAGS - LIBS=$save_LIBS]) + found_usable_python=yes + PYTHON_CPPFLAGS=$new_CPPFLAGS + PYTHON_LIBS=$new_LIBS]) + CPPFLAGS=$save_CPPFLAGS + LIBS=$save_LIBS AC_MSG_RESULT([${found_usable_python}]) ]) @@ -744,26 +746,16 @@ else fi fi else - # Fall back to gdb 7.0/7.1 behaviour. - if test -z ${python_prefix}; then - python_includes= - python_libs= - else - python_includes="-I${python_prefix}/include" - python_libs="-L${python_prefix}/lib" - fi + # We do not have a python executable we can use to determine where + # to find the Python headers and libs. We cannot guess the include + # 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 fi - # Having "/pythonX.Y" in the include path is awkward. - # All those python headers get bubbled up to the top inviting lots - # of random collisions. GDB originally didn't use python-config to - # find the compilation parameters and includes "pythonX.Y/" in the - # path of the, umm, include file. So strip away this part of the - # output of python-config --includes. - python_includes=`echo "${python_includes} " \ - | sed -e 's,/python[[0-9]]*[[.]][[0-9]]* , ,g'` - # If we have python-config, only try the configuration it provides. # Otherwise fallback on the old way of trying different versions of # python in turn. @@ -881,6 +873,8 @@ else python/py-prettyprint.c python/py-auto-load.c" fi AC_SUBST(PYTHON_CFLAGS) +AC_SUBST(PYTHON_CPPFLAGS) +AC_SUBST(PYTHON_LIBS) # ------------------------- # # Checks for header files. # |