Document where to install .jar on macOS
[xapian.git] / xapian-bindings / python / Makefile.am
blob262dee3a387fe097ce94aa8f69f0d8d21a3d2bcd
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         PYTHON='$(PYTHON2)' ;\
11         export abs_builddir ;\
12         export srcdir ;\
13         export PYTHON ;
14 LOG_COMPILER = '$(srcdir)'/run-python-test
16 installcheck-local:
17         $(MAKE) check LOG_COMPILER='$(PYTHON2)' 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-py2-wrapper \
32         generate-python-exceptions \
33         run-python-test \
34         testsuite.py \
35         test_xapian_star.py \
36         $(TESTS) $(BUILT_SOURCES) $(RST_DOCS)
38 pkgpylibdir = @PYTHON2_LIB@/xapian
40 # Install as _DATA rather than _SCRIPTS because we don't want to make these
41 # executable (they don't have a #! line).
42 pkgpylib_DATA = xapian/__init__.py \
43                 xapian/__init__.pyc \
44                 xapian/__init__.pyo
46 pkgpylib_LTLIBRARIES = _xapian.la
48 # Remove the .la file - _xapian.la is never linked against (it's a module)
49 # and Python doesn't use libltdl.  Note that the library gets installed by
50 # install-data, so that's where we need to hook.
51 install-data-hook:
52         rm -f $(DESTDIR)$(pkgpylibdir)/_xapian.la
54 # Because we don't install the .la file, "make uninstall" doesn't work and
55 # we need to remove the file ourselves.
56 uninstall-local:
57         rm -f $(DESTDIR)$(pkgpylibdir)/_xapian$(PYTHON2_SO)
59 AM_CPPFLAGS = -I$(PYTHON2_INC)
60 AM_CXXFLAGS = $(SWIG_CXXFLAGS) $(XAPIAN_CXXFLAGS)
61 _xapian_la_LDFLAGS = -avoid-version -module -shrext "$(PYTHON2_SO)" $(NO_UNDEFINED)
62 _xapian_la_SOURCES = xapian_wrap.cc
63 _xapian_la_LIBADD = $(XAPIAN_LIBS) $(PYTHON2_LIBS)
65 # We want `xapian/__init__.py` rather than xapian.py so the module is treated
66 # as a package.
67 xapian/__init__.py: xapian.py
68         $(MKDIR_P) xapian
69         cp `test -f xapian.py || echo '$(srcdir)/'`xapian.py xapian/__init__.py
71 # We "import _xapian" first so that if we fail to import the glue library
72 # we don't generate a broken .pyc or .pyo, and we do it with the current
73 # directory set to where the module is as Python with -c always searches the
74 # current directory first.
76 # We then "import xapian" as a separate command, as that's more like how things
77 # are once installed - in particular this will fail if the SWIG shadow wrapper
78 # doesn't cope with being xapian/__init__.py (currently it needs fixing
79 # up, which is done by fixup-swig-py2-wrapper).
80 xapian/__init__.pyc: xapian/__init__.py xapian/_xapian$(PYTHON2_SO)
81         $(OSX_SIP_HACK_ENV) $(PYTHON2) -c 'import os;os.chdir("xapian");import _xapian'
82         $(OSX_SIP_HACK_ENV) $(PYTHON2) -c 'import xapian'
84 xapian/__init__.pyo: xapian/__init__.py xapian/_xapian$(PYTHON2_SO)
85         $(OSX_SIP_HACK_ENV) $(PYTHON2) -O -c 'import os;os.chdir("xapian");import _xapian'
86         $(OSX_SIP_HACK_ENV) $(PYTHON2) -O -c 'import xapian'
88 xapian/_xapian$(PYTHON2_SO): _xapian.la
89         $(MKDIR_P) xapian
90         $(LIBTOOL) --config > libtoolconfig.tmp
91 ## ksh requires a path on the sourced file.
92         . ./libtoolconfig.tmp; cp $$objdir/_xapian$(PYTHON2_SO) xapian
93         rm -f libtoolconfig.tmp
95 CLEANFILES = \
96     xapian/_xapian$(PYTHON2_SO) \
97     xapian/__init__.py xapian/__init__.pyc xapian/__init__.pyo \
98     $(srcdir)/*.pyc
100 # Clean the xapian directory which we created, if it's empty, and any
101 # databases created by test cases.
102 clean-local:
103         -rmdir xapian
104         rm -rf db_test_* dbs_replication
106 if MAINTAINER_MODE
107 BUILT_SOURCES += except.i doccomments.i
108 except.i: $(srcdir)/generate-python-exceptions ../../xapian-core/exception_data.pm
109         $(PERL) -w -I$(srcdir)/../../xapian-core $(srcdir)/generate-python-exceptions
111 if MAINTAINER_NO_DOCS
112 doccomments.i:
113         : > doccomments.i
114 else
115 doccomments.i: doxy2swig.py ../../xapian-core/exception_data.pm ../doxygen-xml/index.xml
116         $(PYTHON) $(srcdir)/doxy2swig.py ../doxygen-xml/index.xml doccomments.i
117 endif
119 # We need to explicitly set -outdir because on Windows, SWIG splits paths at
120 # "\" when extracting the output directory from the value passed to the -o
121 # option.
123 stamp = xapian_wrap.stamp
124 RUN_SWIG = stamp='$(stamp)' $(PERL) '$(top_srcdir)'/swig-depcomp $(SWIG)
125 SWIG_FLAGS += -DSWIG_PYTHON_LEGACY_BOOL
127 xapian_wrap.cc xapian_wrap.h xapian.py xapian_wrap.d: $(stamp)
128         $(make_many_locked)
129 $(stamp): except.i doccomments.i fixup-swig-py2-wrapper
130         $(multitarget_begin)
131         $(RUN_SWIG) $(SWIG_WERROR) -I. -I'$(srcdir)' $(SWIG_FLAGS) -c++ \
132             -python -threads -shadow -modern -O \
133             -o xapian_wrap.cc '$(srcdir)/'python.i
134         $(PERL) -i $(srcdir)/fixup-swig-py2-wrapper xapian.py
135         $(multitarget_end)
137 -include xapian_wrap.d
139 CLEANFILES += xapian_wrap.d $(stamp)
140 endif
141 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
143 exampledatadir = $(docdir)/python/examples
144 dist_exampledata_DATA = \
145         docs/examples/simpleindex.py \
146         docs/examples/simpleexpand.py \
147         docs/examples/simplematchdecider.py \
148         docs/examples/simplesearch.py
150 sphinxdocs = docs/html/index.html
152 install-data-local:
153         $(mkinstalldirs) '$(DESTDIR)$(docdir)/python'
154         cp -R -p `test -r docs/html || echo '$(srcdir)/'`docs/html '$(DESTDIR)$(docdir)/python'
156 all-local: $(sphinxdocs)
158 $(sphinxdocs): xapian/__init__.py xapian/_xapian$(PYTHON2_SO) docs/conf.py $(RST_DOCS) $(dist_exampledata_DATA)
159 ## We need to run Sphinx for the right version of Python here, so we can't
160 ## just run sphinx-build as that might be for a different version.
162 ## sphinx >= 1.7.0 no longer skips the first argument passed to
163 ## sphinx.main(). Therefore we have to skip it ourselves (by
164 ## taking a slice of sys.argv), and then have a skippable first
165 ## argument for sphinx < 1.7.0. -bhtml duplicates the subsequent
166 ## -b html, and so apparently is safe.
168 ## Change was merged here: https://github.com/sphinx-doc/sphinx/pull/3668
169         PYTHONPATH=..:$$PYTHONPATH $(OSX_SIP_HACK_ENV) $(PYTHON2) \
170                 -c 'import sphinx,sys;sys.exit(sphinx.main(sys.argv[1:]))' \
171                 -bhtml -b html -d doctrees -c docs $(srcdir)/docs docs/html