[RFA] Build failure fix: Python troubles on non-python targets...

Pierre Muller
2009-05-28T10:03:38Z

On DJGPP,
I now get this failure:
gcc -gstabs+ -O0 -I../../purecvs/gdb/config/djgpp \
-o gdb.exe gdb.o libgdb.a \
../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a
..
/libiberty/libiberty.a ../libdecnumber/libdecnumber.a -ldbg -lm
../libiberty/
libiberty.a gnulib/libgnu.a
libgdb.a(valprint.o): In function `val_print':
e:/cygwin/usr/local/src/gdbcvs/djcvsbuild2/gdb/../../purecvs/gdb/valprint.c:
292:
undefined reference to `_apply_val_pretty_printer'
libgdb.a(valprint.o): In function `value_print':
e:/cygwin/usr/local/src/gdbcvs/djcvsbuild2/gdb/../../purecvs/gdb/valprint.c:
383:
undefined reference to `_apply_val_pretty_printer'
libgdb.a(cp-valprint.o): In function `cp_print_value':
e:/cygwin/usr/local/src/gdbcvs/djcvsbuild2/gdb/../../purecvs/gdb/cp-valprint
.c:4
28: undefined reference to `_apply_val_pretty_printer'
collect2: ld returned 1 exit status

python-prettyprint.o does not seem to be added to libgdb.a...
But if I try to compile it by hand I get this:

In file included from ../../purecvs/gdb/python/python-prettyprint.c:27:
../../purecvs/gdb/python/python-internal.h:49:2: #error "Unable to find
usable Python.h"
In file included from ../../purecvs/gdb/python/python-prettyprint.c:27:
../../purecvs/gdb/python/python-internal.h:66: error: parse error before '*'
token

The HAVE_PYTHON conditional is not at the right position.

It seems like python-prettyprint.o should be added
to CONFIG_OBS if no python is found or

The following two changes fixes compilation for me:
Is this patch OK?

Pierre

2009-05-28 Pierre Muller <muller@ics.u-strasbg.fr>

* configure.ac (!have_libpython): Add python-prettyprint source
and object files.
* configure: Regenerate.
* python/python-prettyprint.c: Move "#ifdef HAVE_PYTHON" before
python headers.

Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.101
diff -u -p -r1.101 configure.ac
--- configure.ac 23 Apr 2009 21:28:19 -0000 1.101
+++ configure.ac 28 May 2009 09:57:53 -0000
@@ -685,8 +685,8 @@ if test "${have_libpython}" = yes; then
else
# Even if Python support is not compiled in, we need to have these files
# included in order to recognize the GDB command "python".
- CONFIG_OBS="$CONFIG_OBS python.o python-value.o"
- CONFIG_SRCS="$CONFIG_SRCS python/python.c python/python-value.c"
+ CONFIG_OBS="$CONFIG_OBS python.o python-value.o python-prettyprint.o"
+ CONFIG_SRCS="$CONFIG_SRCS python/python.c python/python-value.c
python/python-prettyprint.c"
fi
AC_SUBST(PYTHON_CFLAGS)

Index: python/python-prettyprint.c
===================================================================
RCS file: /cvs/src/src/gdb/python/python-prettyprint.c,v
retrieving revision 1.2
diff -u -p -r1.2 python-prettyprint.c
--- python/python-prettyprint.c 28 May 2009 01:09:20 -0000 1.2
+++ python/python-prettyprint.c 28 May 2009 09:57:53 -0000
@@ -23,10 +23,12 @@
#include "symtab.h"
#include "language.h"
#include "valprint.h"
+
+#ifdef HAVE_PYTHON
+
#include "python.h"
#include "python-internal.h"

-#ifdef HAVE_PYTHON

/* Helper function for find_pretty_printer which iterates over a list,
calls each function and inspects output. This will return a