Factor out function to decode 2 hex digits
[xapian.git] / xapian-bindings / python3 / Makefile.am
blobfbf98ec28f66f714d7429dfc8c548e868966900e
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 BUILT_SOURCES = xapian_wrap.cc xapian_wrap.h xapian.py
28 EXTRA_DIST = python.i util.i extra.i extracomments.i except.i \
29         doccomments.i \
30         doxy2swig.py \
31         fixup-swig-py3-wrapper \
32         generate-python-exceptions \
33         run-python-test \
34         sphinx-build \
35         testsuite.py \
36         test_xapian_star.py \
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.
52 install-data-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.
57 uninstall-local:
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
67 # as a package.
68 xapian/__init__.py: xapian.py
69         $(MKDIR_P) xapian
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
90         $(MKDIR_P) xapian
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
96 CLEANFILES = \
97     xapian/_xapian$(PYTHON3_EXT_SUFFIX) \
98     xapian/__init__.py \
99     xapian/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc \
100     xapian/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@ \
101     $(srcdir)/*.pyc
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
105 # cases.
106 clean-local:
107         -rmdir xapian/__pycache__
108         -rmdir xapian
109         rm -rf doctrees docs/html db_test_* dbs_replication
111 if MAINTAINER_MODE
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
117 doccomments.i:
118         : > doccomments.i
119 else
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
122 endif
124 # Update the Python 3 versions from the Python 2 ones.
125 2to3:
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
130 # option.
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)
137         $(make_many_locked)
138 $(stamp): except.i doccomments.i fixup-swig-py3-wrapper
139         $(multitarget_begin)
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
144         $(multitarget_end)
146 -include xapian_wrap.d
148 CLEANFILES += xapian_wrap.d $(stamp)
149 endif
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
161 install-data-local:
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