1 ## Process this file with automake to produce Makefile.in
3 include ../generic/generic.mk
5 ## Test programs to be run
6 TESTS = smoketest.py pythontest.py
7 AM_TESTS_ENVIRONMENT = \
8 PYTHON3='$(PYTHON3)' ;\
10 LOG_COMPILER = '$(srcdir)'/run-python-test
13 $(MAKE) check LOG_COMPILER='$(PYTHON3)' AM_TESTS_ENVIRONMENT= \
14 PYTHONDONTWRITEBYTECODE=1
19 docs/introduction.rst \
22 BUILT_SOURCES = xapian_wrap.cc xapian_wrap.h xapian.py
24 EXTRA_DIST = python.i util.i extra.i extracomments.i except.i \
27 fixup-swig-py3-wrapper \
28 generate-python-exceptions \
33 $(TESTS) $(BUILT_SOURCES) $(RST_DOCS)
35 pkgpylibdir = @PYTHON3_LIB@/xapian
37 # Install as _DATA rather than _SCRIPTS because we don't want to make these
38 # executable (they don't have a #! line).
39 pkgpylib_DATA = xapian/__init__.py \
40 xapian/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc \
41 xapian/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@
43 pkgpylib_LTLIBRARIES = _xapian.la
45 # Remove the .la file - _xapian.la is never linked against (it's a module)
46 # and Python doesn't use libltdl. Note that the library gets installed by
47 # install-data, so that's where we need to hook.
49 rm -f $(DESTDIR)$(pkgpylibdir)/_xapian.la
51 # Because we don't install the .la file, "make uninstall" doesn't work and
52 # we need to remove the file ourselves.
54 rm -f $(DESTDIR)$(pkgpylibdir)/_xapian$(PYTHON3_EXT_SUFFIX)
56 AM_CPPFLAGS = -I$(PYTHON3_INC)
57 AM_CXXFLAGS = $(SWIG_CXXFLAGS) $(XAPIAN_CXXFLAGS)
58 _xapian_la_LDFLAGS = -avoid-version -module -shrext "$(PYTHON3_EXT_SUFFIX)" $(NO_UNDEFINED)
59 _xapian_la_SOURCES = xapian_wrap.cc
60 _xapian_la_LIBADD = $(XAPIAN_LIBS) $(PYTHON3_LIBS)
62 # We want `xapian/__init__.py` rather than xapian.py so the module is treated
64 xapian/__init__.py: xapian.py
66 cp `test -f xapian.py || echo '$(srcdir)/'`xapian.py xapian/__init__.py
68 # We "import _xapian" first so that if we fail to import the glue library
69 # we don't generate a broken .pyc or .pyo, and we do it with the current
70 # directory set to where the module is as Python with -c always searches the
71 # current directory first.
73 # We then "import xapian" as a separate command, as that's more like how things
74 # are once installed - in particular this will fail if the SWIG shadow wrapper
75 # doesn't cope with being xapian/__init__.py (currently it needs fixing
76 # up, which is done by fixup-swig-py3-wrapper).
77 xapian/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc: xapian/__init__.py xapian/_xapian$(PYTHON3_EXT_SUFFIX)
78 $(MACOS_SIP_HACK_ENV) $(PYTHON3) -c 'import os;os.chdir("xapian");import _xapian'
79 $(MACOS_SIP_HACK_ENV) $(PYTHON3) -c 'import xapian'
81 xapian/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@: xapian/__init__.py xapian/_xapian$(PYTHON3_EXT_SUFFIX)
82 $(MACOS_SIP_HACK_ENV) $(PYTHON3) -O -c 'import os;os.chdir("xapian");import _xapian'
83 $(MACOS_SIP_HACK_ENV) $(PYTHON3) -O -c 'import xapian'
85 xapian/_xapian$(PYTHON3_EXT_SUFFIX): _xapian.la
87 cp $(_libs)/_xapian$(PYTHON3_EXT_SUFFIX) xapian
90 xapian/_xapian$(PYTHON3_EXT_SUFFIX) \
92 xapian/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc \
93 xapian/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@ \
96 # Clean the xapian directory which we created and its __pycache__ subdirectory
97 # (if they're empty), output from sphinx, and any databases created by test
100 -rmdir xapian/__pycache__
102 rm -rf doctrees docs/html db_test_* dbs_replication
105 BUILT_SOURCES += except.i doccomments.i
106 except.i: $(srcdir)/generate-python-exceptions ../../xapian-core/exception_data.pm
107 $(PERL) -w -I$(srcdir)/../../xapian-core $(srcdir)/generate-python-exceptions
109 if MAINTAINER_NO_DOCS
113 doccomments.i: doxy2swig.py ../../xapian-core/exception_data.pm ../doxygen-xml/index.xml
114 $(PYTHON) $(srcdir)/doxy2swig.py ../doxygen-xml/index.xml doccomments.i
117 # Update the Python 3 versions from the Python 2 ones.
119 for a in pythontest smoketest testsuite ; do cp ../python/$${a}.py $${a}.py ; 2to3 -w --no-diffs $${a}.py ; done
121 # We need to explicitly set -outdir because on Windows, SWIG splits paths at
122 # "\" when extracting the output directory from the value passed to the -o
125 stamp = xapian_wrap.stamp
126 RUN_SWIG = stamp='$(stamp)' $(PERL) '$(top_srcdir)'/swig-depcomp $(SWIG)
127 SWIG_FLAGS += -DSWIG_PYTHON_LEGACY_BOOL
129 xapian_wrap.cc xapian_wrap.h xapian.py xapian_wrap.d: $(stamp)
131 $(stamp): except.i doccomments.i fixup-swig-py3-wrapper
133 $(RUN_SWIG) $(SWIG_WERROR) -I. -I'$(srcdir)' $(SWIG_FLAGS) -c++ \
134 -python -threads -shadow -O \
135 -o xapian_wrap.cc '$(srcdir)/'python.i
136 $(PERL) -i $(srcdir)/fixup-swig-py3-wrapper xapian.py
139 -include xapian_wrap.d
141 CLEANFILES += xapian_wrap.d $(stamp)
143 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
145 exampledatadir = $(docdir)/python3/examples
146 dist_exampledata_DATA = \
147 docs/examples/simpleindex.py \
148 docs/examples/simpleexpand.py \
149 docs/examples/simplematchdecider.py \
150 docs/examples/simplesearch.py
152 sphinxdocs = docs/html/index.html
155 $(mkinstalldirs) '$(DESTDIR)$(docdir)/python3'
156 cp -R -p `test -r docs/html || echo '$(srcdir)/'`docs/html '$(DESTDIR)$(docdir)/python3'
158 all-local: $(sphinxdocs)
160 $(sphinxdocs): xapian/__init__.py xapian/_xapian$(PYTHON3_EXT_SUFFIX) docs/conf.py $(RST_DOCS) $(dist_exampledata_DATA)
161 PYTHONPATH=..:$$PYTHONPATH $(MACOS_SIP_HACK_ENV) $(PYTHON3) \
162 $(srcdir)/sphinx-build \
163 -b html -d doctrees -c docs $(srcdir)/docs docs/html