[xml] Out of tree builds fail when configuring with --without-python

I've hit a problem when trying to do an out-of-tree build of libxml2-2.9.1
with the --without-python configuration option.  I've worked around it for
now, but it would be nice to have it fixed properly and I'm willing to make
the patch and submit it myself (although Bugzilla doesn't appear to have the
recent version numbers in the list of version numbers).  However, I am
unsure what the correct fix actually is and wondered if anybody else had
found this problem.

I'm cross-compiling for an embedded device that has no python support on it,
but that's not relevant to this issue, as it fails for native builds as too.
For example, if you have the libxml2 directory in your current directory and

  $ mkdir build
  $ cd build
  $ ../libxml2/configure --without-python
  $ make

then it will fail eventually because it cannot find testapi.c:

     CC     testapi.o
  gcc: error: testapi.c: No such file or directory

The cause is that, indeed, there is no testapi.c file in $(top_builddir),
because it's in $(srcdir).  I think it would find it OK if it wasn't listed
in BUILT_SOURCES, however, there is a rule in Makefile.am that should
regenerate it anyway, which does try to rebuild it in the correct place:

  # that one is just to make sure it is rebuilt if missing
  # but adding the dependances generate mess
  testapi.c: $(srcdir)/gentest.py
          -@(if [ "$(PYTHON)" != "" ] ; then \
              $(PYTHON) $(srcdir)/gentest.py $(srcdir) ; fi )

This rule would work, except $(PYTHON) is empty, because --without-python
stops the configure script from looking for it.  Therefore, attempts to
rebuild testapi.c do nothing and compilation fails.

My ugly workaround at the moment is to add PYTHON=python to the make command
which overrides the Makefile's definition to allow this recipe to rebuild
the file without accidentally enabling the build of the python bindings. The
good news is that this works and doesn't (appear to) have any other
side-effects, but it's just wrong to do this.

I'm not sure what the correct fix is.  There are several possible options:

1) just continue doing it this way if it only affects me - seems wrong

2) similarly, configure with --with-python but use PYTHON_SUBDIR= for make -
seems equally wrong

3) modify configure.in to check for python as a required tool (i.e. ignore
--with/--without-python here) and handle the setting of PYTHON_SUBDIR to be
dependent on *both* --with-python and finding a suitable python binary at
the end of that block of the configure.in

4) modify Makefile.am so that if PYTHON is empty, it tries to copy testapi.c
from $(srcdir) to $(top_builddir), and if that fails, output an error
message and stop.

5) something else?

Thoughts and suggestions on this, anybody?

I'm building it for multiple targets, so out-of-tree building is a
requirement.  I suppose I could just duplicate the entire source tree into
my build directory, but this seems to be silly way to go and I'd rather not.

I have to disable python support in libxml2, otherwise it fails to build on
my build machine.  I have investigated configuring libxml2 --with-python,
but things start going wrong when it tries to build libxml.lo and finds it
can't because it's missing some python headers on the build machine:

    CC     libxml.lo
  In file included from /usr/include/python2.7/Python.h:8:0,
                 from ../../../../../../libxml2/python/libxml.c:14:
  /usr/include/python2.7/pyconfig.h:4:25: fatal error: pyconfig-32.h: No
such file or directory

This is almost certainly down to my build machine being 64-bit and the build
target being 32-bit, but ultimately that's not the issue here either.  I do
worry about what might happen if my build machine were to be 32-bit too -
perhaps it would silently do something weird or perhaps even "work", but I
don't know enough about python bindings to want to trust that.

Stewart Brodie
Senior Software Engineer
Team Leader ANT Galio Browser
Espial UK

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]