aboutsummaryrefslogtreecommitdiff
path: root/gdb/configure.ac
diff options
context:
space:
mode:
authorThiago Jung Bauermann <bauerman@br.ibm.com>2008-08-06 19:41:33 +0000
committerThiago Jung Bauermann <bauerman@br.ibm.com>2008-08-06 19:41:33 +0000
commitd57a3c85f6eee87b04852e98cce75af080969951 (patch)
tree6758be339bdf45930c2d61e4d447ce308bb82ec5 /gdb/configure.ac
parent5141027dd033490b4866bea973206985b8a0cab4 (diff)
downloadgdb-d57a3c85f6eee87b04852e98cce75af080969951.zip
gdb-d57a3c85f6eee87b04852e98cce75af080969951.tar.gz
gdb-d57a3c85f6eee87b04852e98cce75af080969951.tar.bz2
Initial python support.
gdb/ 2008-08-06 Vladimir Prus <vladimir@codesourcery.com> Tom Tromey <tromey@redhat.com> Thiago Jung Bauermann <bauerman@br.ibm.com> Doug Evans <dje@google.com> * Makefile.in (SUBDIR_PYTHON_OBS, SUBDIR_PYTHON_SRCS, SUBDIR_PYTHON_DEPS, SUBDIR_PYTHON_LDFLAGS, SUBDIR_PYTHON_CFLAGS, PYTHON_CFLAGS): New. (python_h, python_internal_h): New. (cli-script.o): Depend on python.h (python.o, python-utils.o): New. * cli/cli-script.c (print_command_lines): Handle python_control. (execute_control_command): Handle python_control. (execute_control_command_untraced): New function. (while_command): Call execute_control_command_untraced. (if_command): Likewise. (get_command_line): Remove static attribute. (read_next_line): Handle "python". (recurse_read_control_structure): Handle python_control. (read_command_lines): Handle python_control. Include python.h. * cli/cli-script.h (get_command_line): Add prototype. (execute_control_command_untraced): Likewise. * configure.ac: Add --with-python. * defs.h (enum command_control_type) <python_control>: New constant. * python/python-internal.h: New file. * python/python.c: New file. * python/python.h: New file. * python/python-utils.c: New file. * NEWS: Mention Python scripting support and its new commands. gdb/doc/ 2008-08-06 Tom Tromey <tromey@redhat.com> * gdb.texinfo (Extending GDB): New chapter. (Sequences): Demoted chapter, now a section under the new Extending GDB chapter. (Python): New section. gdb/testsuite/ 2008-08-06 Tom Tromey <tromey@redhat.com> * gdb.python/python.exp: New file.
Diffstat (limited to 'gdb/configure.ac')
-rw-r--r--gdb/configure.ac119
1 files changed, 119 insertions, 0 deletions
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 3a55218..74b7d6a 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -497,6 +497,125 @@ else
fi
fi
+dnl Utility to simplify finding libpython.
+AC_DEFUN([AC_TRY_LIBPYTHON],
+[
+ version=$1
+ define([have_libpython_var],$2)
+ define([VERSION],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+ [HAVE_LIB]VERSION=no
+ AC_MSG_CHECKING([for ${version}])
+ save_LIBS=$LIBS
+ LIBS="$LIBS -l${version}"
+ AC_LINK_IFELSE(AC_LANG_PROGRAM([[#include "${version}/Python.h"]],
+ [[Py_Initialize ();]]),
+ [[HAVE_LIB]VERSION=yes
+ have_libpython_var=yes],
+ [LIBS=$save_LIBS])
+ AC_MSG_RESULT([$[HAVE_LIB]VERSION])
+])
+
+AC_ARG_WITH(python,
+ AS_HELP_STRING([--with-python], [include python support (auto/yes/no/<path>)]),
+ [], [with_python=auto])
+AC_MSG_CHECKING([whether to use python])
+AC_MSG_RESULT([$with_python])
+
+if test "${with_python}" = no; then
+ AC_MSG_WARN([python support disabled; some features may be unavailable.])
+ have_libpython=no
+else
+ case "${with_python}" in
+ yes | auto)
+ # Leave as empty, use defaults.
+ python_includes=
+ python_libs=
+ ;;
+ /*)
+ python_includes="-I${with_python}/include"
+ python_libs="-L${with_python}/lib"
+ ;;
+ *)
+ AC_ERROR(invalid value for --with-python)
+ ;;
+ esac
+
+ save_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS="$CPPFLAGS ${python_includes}"
+ save_LIBS=$LIBS
+ LIBS="$LIBS ${python_libs}"
+ have_libpython=no
+ if test "${have_libpython}" = no; then
+ AC_TRY_LIBPYTHON(python2.6, have_libpython)
+ if test "${HAVE_LIBPYTHON2_6}" = yes; then
+ AC_DEFINE(HAVE_LIBPYTHON2_6, 1, [Define if Python 2.6 is being used.])
+ fi
+ fi
+ if test ${have_libpython} = no; then
+ AC_TRY_LIBPYTHON(python2.5, have_libpython)
+ if test "${HAVE_LIBPYTHON2_5}" = yes; then
+ AC_DEFINE(HAVE_LIBPYTHON2_5, 1, [Define if Python 2.5 is being used.])
+ fi
+ fi
+ if test ${have_libpython} = no; then
+ AC_TRY_LIBPYTHON(python2.4, have_libpython)
+ if test "${HAVE_LIBPYTHON2_4}" = yes; then
+ AC_DEFINE(HAVE_LIBPYTHON2_4, 1, [Define if Python 2.4 is being used.])
+ fi
+ fi
+ if test ${have_libpython} = no; then
+ case "${with_python}" in
+ yes)
+ AC_MSG_ERROR([python is missing or unusable])
+ ;;
+ auto)
+ AC_MSG_WARN([python is missing or unusable; some features may be unavailable.])
+ ;;
+ *)
+ AC_MSG_ERROR([no usable python found at ${with_python}])
+ ;;
+ esac
+ CPPFLAGS=$save_CPPFLAGS
+ LIBS=$save_LIBS
+ fi
+fi
+
+if test "${have_libpython}" = yes; then
+ AC_DEFINE(HAVE_PYTHON, 1, [Define if Python interpreter is being linked in.])
+ CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_PYTHON_OBS)"
+ CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_PYTHON_DEPS)"
+ CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_PYTHON_SRCS)"
+ ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_PYTHON_CFLAGS)"
+
+ # Flags needed to compile Python code (taken from python-config --cflags).
+ # We cannot call python-config directly because it will output whatever was
+ # used when compiling the Python interpreter itself, including flags which
+ # would make the python-related objects be compiled differently from the
+ # rest of GDB (e.g., -O2 and -fPIC).
+ if test "${GCC}" = yes; then
+ tentative_python_cflags="-fno-strict-aliasing -DNDEBUG -fwrapv"
+ fi
+
+ if test "x${tentative_python_cflags}" != x; then
+ AC_MSG_CHECKING(compiler flags for python code)
+ for flag in ${tentative_python_cflags}; do
+ # Check that the compiler accepts it
+ saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $flag"
+ AC_TRY_COMPILE([],[],PYTHON_CFLAGS="${PYTHON_CFLAGS} $flag",)
+ CFLAGS="$saved_CFLAGS"
+ done
+ AC_MSG_RESULT(${PYTHON_CFLAGS})
+ fi
+else
+ # Even if Python support is not compiled in, we need to have this file
+ # included in order to recognize the GDB command "python".
+ CONFIG_OBS="$CONFIG_OBS python.o"
+ CONFIG_SRCS="$CONFIG_SRCS python/python.c"
+fi
+AC_SUBST(PYTHON_CFLAGS)
+
# ------------------------- #
# Checks for header files. #
# ------------------------- #