*(foo.get()) -> *foo
[xapian.git] / xapian-bindings / python3 / Makefile.am
blobccf147cf19e5c6a0b076e431487dcee318f2d8df
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)' ;\
9         srcdir='$(srcdir)' ;\
10         PYTHON3='$(PYTHON3)' ;\
11         export abs_builddir ;\
12         export srcdir ;\
13         export PYTHON3 ;
14 LOG_COMPILER = '$(srcdir)'/run-python-test
16 installcheck-local:
17         $(MAKE) check  LOG_COMPILER='$(PYTHON3)' AM_TESTS_ENVIRONMENT= \
18             PYTHONDONTWRITEBYTECODE=1
20 RST_DOCS = \
21         docs/examples.rst \
22         docs/index.rst \
23         docs/introduction.rst \
24         docs/xapian.rst
26 # FIXME: replicationtest.py attempts to test performing replication whilst
27 # modifications are in progress.  However, it sometimes fails due to a race
28 # condition in it.  It also contains hard-coded paths to the replication
29 # server and client, which assume the file layout in a repo checkout.
30 # Therefore, we don't run it by default currently.
31 # replicationtest.py
33 BUILT_SOURCES = xapian_wrap.cc xapian_wrap.h xapian.py
35 EXTRA_DIST = python.i util.i extra.i extracomments.i except.i \
36         doxy2swig.py \
37         fixup-swig-py3-wrapper \
38         generate-python-exceptions \
39         run-python-test \
40         testsuite.py \
41         test_xapian_star.py \
42         $(TESTS) $(BUILT_SOURCES) $(RST_DOCS)
44 pkgpylibdir = @PYTHON3_LIB@/xapian
46 # Install as _DATA rather than _SCRIPTS because we don't want to make these
47 # executable (they don't have a #! line).
48 pkgpylib_DATA = xapian/__init__.py \
49                 xapian/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc \
50                 xapian/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@
52 pkgpylib_LTLIBRARIES = _xapian.la
54 # Remove the .la file - _xapian.la is never linked against (it's a module)
55 # and Python doesn't use libltdl.  Note that the library gets installed by
56 # install-data, so that's where we need to hook.
57 install-data-hook:
58         rm -f $(DESTDIR)$(pkgpylibdir)/_xapian.la
60 # Because we don't install the .la file, "make uninstall" doesn't work and
61 # we need to remove the file ourselves.
62 uninstall-local:
63         rm -f $(DESTDIR)$(pkgpylibdir)/_xapian$(PYTHON3_SO)
65 AM_CPPFLAGS = -I$(PYTHON3_INC)
66 AM_CXXFLAGS = $(SWIG_CXXFLAGS) $(XAPIAN_CXXFLAGS)
67 _xapian_la_LDFLAGS = -avoid-version -module -shrext "$(PYTHON3_SO)" $(NO_UNDEFINED)
68 _xapian_la_SOURCES = xapian_wrap.cc
69 _xapian_la_LIBADD = $(XAPIAN_LIBS) $(PYTHON3_LIBS)
71 # We want `xapian/__init__.py` rather than xapian.py so the module is treated
72 # as a package.
73 xapian/__init__.py: xapian.py
74         $(MKDIR_P) xapian
75         cp `test -f xapian.py || echo '$(srcdir)/'`xapian.py xapian/__init__.py
77 # We "import _xapian" first so that if we fail to import the glue library
78 # we don't generate a broken .pyc or .pyo, and we do it with the current
79 # directory set to where the module is as Python with -c always searches the
80 # current directory first.
82 # We then "import xapian" as a separate command, as that's more like how things
83 # are once installed - in particular this will fail if the SWIG shadow wrapper
84 # doesn't cope with being xapian/__init__.py (currently it needs fixing
85 # up, which is done by fixup-swig-py3-wrapper).
86 xapian/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc: xapian/__init__.py xapian/_xapian$(PYTHON3_SO)
87         $(OSX_SIP_HACK_ENV) $(PYTHON3) -c 'import os;os.chdir("xapian");import _xapian'
88         $(OSX_SIP_HACK_ENV) $(PYTHON3) -c 'import xapian'
90 xapian/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@: xapian/__init__.py xapian/_xapian$(PYTHON3_SO)
91         $(OSX_SIP_HACK_ENV) $(PYTHON3) -O -c 'import os;os.chdir("xapian");import _xapian'
92         $(OSX_SIP_HACK_ENV) $(PYTHON3) -O -c 'import xapian'
94 xapian/_xapian$(PYTHON3_SO): _xapian.la
95         $(MKDIR_P) xapian
96         $(LIBTOOL) --config > libtoolconfig.tmp
97 ## ksh requires a path on the sourced file.
98         . ./libtoolconfig.tmp; cp $$objdir/_xapian$(PYTHON3_SO) xapian
99         rm -f libtoolconfig.tmp
101 CLEANFILES = \
102     xapian/_xapian$(PYTHON3_SO) \
103     xapian/__init__.py \
104     xapian/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc \
105     xapian/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@ \
106     $(srcdir)/*.pyc
108 # Clean the xapian directory which we created, if it's empty, and any
109 # databases created by test cases.
110 clean-local:
111         -rmdir xapian
112         rm -rf db_test_* dbs_replication
114 if MAINTAINER_MODE
115 BUILT_SOURCES += except.i doccomments.i
116 except.i: $(srcdir)/generate-python-exceptions ../../xapian-core/exception_data.pm
117         $(PERL) -w -I$(srcdir)/../../xapian-core $(srcdir)/generate-python-exceptions
119 if MAINTAINER_NO_DOCS
120 doccomments.i:
121         : > doccomments.i
122 else
123 doccomments.i: doxy2swig.py ../../xapian-core/exception_data.pm ../doxygen-xml/index.xml
124         $(PYTHON) $(srcdir)/doxy2swig.py ../doxygen-xml/index.xml doccomments.i
125 endif
127 # Update the Python 3 versions from the Python 2 ones.
128 2to3:
129         for a in pythontest replicationtest smoketest testsuite ; do cp ../python/$${a}.py $${a}.py ; 2to3 -w --no-diffs $${a}.py ; done
131 # We need to explicitly set -outdir because on Windows, SWIG splits paths at
132 # "\" when extracting the output directory from the value passed to the -o
133 # option.
135 stamp = xapian_wrap.stamp
136 RUN_SWIG = stamp='$(stamp)' $(PERL) '$(top_srcdir)'/swig-depcomp $(SWIG)
137 SWIG_FLAGS += -DSWIG_PYTHON_LEGACY_BOOL
139 xapian_wrap.cc xapian_wrap.h xapian.py xapian_wrap.d: $(stamp)
140         $(make_many_locked)
141 $(stamp): except.i doccomments.i fixup-swig-py3-wrapper
142         $(multitarget_begin)
143         $(RUN_SWIG) $(SWIG_WERROR) -I. -I'$(srcdir)' $(SWIG_FLAGS) -c++ \
144             -python -threads -shadow -modern -O \
145             -o xapian_wrap.cc '$(srcdir)/'python.i
146         $(PERL) -i $(srcdir)/fixup-swig-py3-wrapper xapian.py
147         $(multitarget_end)
149 -include xapian_wrap.d
151 CLEANFILES += xapian_wrap.d $(stamp)
152 endif
153 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
155 exampledatadir = $(docdir)/python3/examples
156 dist_exampledata_DATA = \
157         docs/examples/simpleindex.py \
158         docs/examples/simpleexpand.py \
159         docs/examples/simplematchdecider.py \
160         docs/examples/simplesearch.py
162 sphinxdocs = docs/html/index.html
164 install-data-local:
165         $(mkinstalldirs) '$(DESTDIR)$(docdir)/python3'
166         cp -R -p `test -r docs/html || echo '$(srcdir)/'`docs/html '$(DESTDIR)$(docdir)/python3'
168 all-local: $(sphinxdocs)
170 $(sphinxdocs): xapian/__init__.py xapian/_xapian$(PYTHON3_SO) docs/conf.py $(RST_DOCS) $(dist_exampledata_DATA)
171 ## We need to run Sphinx for the right version of Python here, so we can't
172 ## just run sphinx-build as that might be for a different version.
173         PYTHONPATH=..:$$PYTHONPATH $(OSX_SIP_HACK_ENV) $(PYTHON3) \
174                 -c 'import sphinx,sys;sys.exit(sphinx.main(sys.argv))' \
175                 -b html -d doctrees -c docs $(srcdir)/docs docs/html