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 abs_builddir='$(abs_builddir)' ;\
10 PYTHON3='$(PYTHON3)' ;\
11 export abs_builddir ;\
14 LOG_COMPILER = '$(srcdir)'/run-python-test
17 $(MAKE) check LOG_COMPILER='$(PYTHON3)' AM_TESTS_ENVIRONMENT= \
18 PYTHONDONTWRITEBYTECODE=1
23 docs/introduction.rst \
26 BUILT_SOURCES = xapian_wrap.cc xapian_wrap.h xapian.py
28 EXTRA_DIST = python.i util.i extra.i extracomments.i except.i \
31 fixup-swig-py3-wrapper \
32 generate-python-exceptions \
37 $(TESTS) $(BUILT_SOURCES) $(RST_DOCS)
39 pkgpylibdir = @PYTHON3_LIB@/xapian
41 # Install as _DATA rather than _SCRIPTS because we don't want to make these
42 # executable (they don't have a #! line).
43 pkgpylib_DATA = xapian/__init__.py \
44 xapian/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc \
45 xapian/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@
47 pkgpylib_LTLIBRARIES = _xapian.la
49 # Remove the .la file - _xapian.la is never linked against (it's a module)
50 # and Python doesn't use libltdl. Note that the library gets installed by
51 # install-data, so that's where we need to hook.
53 rm -f $(DESTDIR)$(pkgpylibdir)/_xapian.la
55 # Because we don't install the .la file, "make uninstall" doesn't work and
56 # we need to remove the file ourselves.
58 rm -f $(DESTDIR)$(pkgpylibdir)/_xapian$(PYTHON3_EXT_SUFFIX)
60 AM_CPPFLAGS = -I$(PYTHON3_INC)
61 AM_CXXFLAGS = $(SWIG_CXXFLAGS) $(XAPIAN_CXXFLAGS)
62 _xapian_la_LDFLAGS = -avoid-version -module -shrext "$(PYTHON3_EXT_SUFFIX)" $(NO_UNDEFINED)
63 _xapian_la_SOURCES = xapian_wrap.cc
64 _xapian_la_LIBADD = $(XAPIAN_LIBS) $(PYTHON3_LIBS)
66 # We want `xapian/__init__.py` rather than xapian.py so the module is treated
68 xapian/__init__.py: xapian.py
70 cp `test -f xapian.py || echo '$(srcdir)/'`xapian.py xapian/__init__.py
72 # We "import _xapian" first so that if we fail to import the glue library
73 # we don't generate a broken .pyc or .pyo, and we do it with the current
74 # directory set to where the module is as Python with -c always searches the
75 # current directory first.
77 # We then "import xapian" as a separate command, as that's more like how things
78 # are once installed - in particular this will fail if the SWIG shadow wrapper
79 # doesn't cope with being xapian/__init__.py (currently it needs fixing
80 # up, which is done by fixup-swig-py3-wrapper).
81 xapian/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc: xapian/__init__.py xapian/_xapian$(PYTHON3_EXT_SUFFIX)
82 $(OSX_SIP_HACK_ENV) $(PYTHON3) -c 'import os;os.chdir("xapian");import _xapian'
83 $(OSX_SIP_HACK_ENV) $(PYTHON3) -c 'import xapian'
85 xapian/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@: xapian/__init__.py xapian/_xapian$(PYTHON3_EXT_SUFFIX)
86 $(OSX_SIP_HACK_ENV) $(PYTHON3) -O -c 'import os;os.chdir("xapian");import _xapian'
87 $(OSX_SIP_HACK_ENV) $(PYTHON3) -O -c 'import xapian'
89 xapian/_xapian$(PYTHON3_EXT_SUFFIX): _xapian.la
91 $(LIBTOOL) --config > libtoolconfig.tmp
92 ## ksh requires a path on the sourced file.
93 . ./libtoolconfig.tmp; cp $$objdir/_xapian$(PYTHON3_EXT_SUFFIX) xapian
94 rm -f libtoolconfig.tmp
97 xapian/_xapian$(PYTHON3_EXT_SUFFIX) \
99 xapian/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc \
100 xapian/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@ \
103 # Clean the xapian directory which we created and its __pycache__ subdirectory
104 # (if they're empty), output from sphinx, and any databases created by test
107 -rmdir xapian/__pycache__
109 rm -rf doctrees docs/html db_test_* dbs_replication
112 BUILT_SOURCES += except.i doccomments.i
113 except.i: $(srcdir)/generate-python-exceptions ../../xapian-core/exception_data.pm
114 $(PERL) -w -I$(srcdir)/../../xapian-core $(srcdir)/generate-python-exceptions
116 if MAINTAINER_NO_DOCS
120 doccomments.i: doxy2swig.py ../../xapian-core/exception_data.pm ../doxygen-xml/index.xml
121 $(PYTHON) $(srcdir)/doxy2swig.py ../doxygen-xml/index.xml doccomments.i
124 # Update the Python 3 versions from the Python 2 ones.
126 for a in pythontest smoketest testsuite ; do cp ../python/$${a}.py $${a}.py ; 2to3 -w --no-diffs $${a}.py ; done
128 # We need to explicitly set -outdir because on Windows, SWIG splits paths at
129 # "\" when extracting the output directory from the value passed to the -o
132 stamp = xapian_wrap.stamp
133 RUN_SWIG = stamp='$(stamp)' $(PERL) '$(top_srcdir)'/swig-depcomp $(SWIG)
134 SWIG_FLAGS += -DSWIG_PYTHON_LEGACY_BOOL
136 xapian_wrap.cc xapian_wrap.h xapian.py xapian_wrap.d: $(stamp)
138 $(stamp): except.i doccomments.i fixup-swig-py3-wrapper
140 $(RUN_SWIG) $(SWIG_WERROR) -I. -I'$(srcdir)' $(SWIG_FLAGS) -c++ \
141 -python -threads -shadow -modern -O \
142 -o xapian_wrap.cc '$(srcdir)/'python.i
143 $(PERL) -i $(srcdir)/fixup-swig-py3-wrapper xapian.py
146 -include xapian_wrap.d
148 CLEANFILES += xapian_wrap.d $(stamp)
150 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
152 exampledatadir = $(docdir)/python3/examples
153 dist_exampledata_DATA = \
154 docs/examples/simpleindex.py \
155 docs/examples/simpleexpand.py \
156 docs/examples/simplematchdecider.py \
157 docs/examples/simplesearch.py
159 sphinxdocs = docs/html/index.html
162 $(mkinstalldirs) '$(DESTDIR)$(docdir)/python3'
163 cp -R -p `test -r docs/html || echo '$(srcdir)/'`docs/html '$(DESTDIR)$(docdir)/python3'
165 all-local: $(sphinxdocs)
167 $(sphinxdocs): xapian/__init__.py xapian/_xapian$(PYTHON3_EXT_SUFFIX) docs/conf.py $(RST_DOCS) $(dist_exampledata_DATA)
168 PYTHONPATH=..:$$PYTHONPATH $(OSX_SIP_HACK_ENV) $(PYTHON3) \
169 $(srcdir)/sphinx-build \
170 -b html -d doctrees -c docs $(srcdir)/docs docs/html