-all-local: __init__.py
+NATIVEBT_PY = nativebt.py
+NATIVEBT_WRAP_C = nativebt_wrap.c
+INIT_PY = __init__.py
+INIT_PY_IN = $(srcdir)/$(INIT_PY).in
+NATIVEBT_I = $(srcdir)/nativebt.i
-__init__.py: __init__.py.in
+all-local: $(INIT_PY)
+
+$(INIT_PY): $(INIT_PY_IN)
sed "s/BABELTRACE_VERSION_STR/$(PACKAGE_VERSION)/g" < $< > $@
AM_CFLAGS = $(PYTHON_INCLUDE) -I$(top_srcdir)/include/
-EXTRA_DIST = __init__.py.in nativebt.i common.py reader.py writer.py
-nodist_btpackage_PYTHON = __init__.py nativebt.py common.py reader.py writer.py
+EXTRA_DIST = common.py reader.py writer.py $(INIT_PY_IN) $(NATIVEBT_I)
+nodist_btpackage_PYTHON = $(INIT_PY) $(NATIVEBT_PY) common.py reader.py writer.py
nativebtlib_LTLIBRARIES = _nativebt.la
btpackagedir = $(pythondir)/babeltrace
nativebtlibdir = $(btpackagedir)
-MAINTAINERCLEANFILES = nativebt_wrap.c nativebt.py
+MAINTAINERCLEANFILES = $(NATIVEBT_PY) $(NATIVEBT_WRAP_C)
-nodist__nativebt_la_SOURCES = nativebt_wrap.c
+nodist__nativebt_la_SOURCES = $(NATIVEBT_WRAP_C)
_nativebt_la_SOURCES = python-complements.h python-complements.c
_nativebt_la_LDFLAGS = -module
-
_nativebt_la_CFLAGS = $(GLIB_CFLAGS) $(AM_CFLAGS)
-
_nativebt_la_LIBS = $(GLIB_LIBS)
-
_nativebt_la_LIBADD = $(top_builddir)/formats/ctf/libbabeltrace-ctf.la
# SWIG 'warning md variable unused' fixed after SWIG build:
-nativebt_wrap.c: nativebt.i
- $(SWIG) -python -Wall -I. -I$(top_srcdir)/include $<
+$(NATIVEBT_WRAP_C): $(NATIVEBT_I)
+ $(SWIG) -python -Wall -I$(srcdir) -I$(top_srcdir)/include -outcurrentdir $<
-CLEANFILES = nativebt.py nativebt_wrap.c __init__.py
+CLEANFILES = $(NATIVEBT_PY) $(NATIVEBT_WRAP_C) $(INIT_PY)
fi
if test "x${enable_python_bindings_doc:-yes}" = xyes; then
- AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build sphinx-build3 sphinx-build2], [no])
- AS_IF([test "x$SPHINXBUILD" = xno],
- AC_MSG_ERROR([sphinx-build is required to build Python bindings documentation])
+ AM_CHECK_PYTHON_SPHINX([PYTHON])
+ AS_IF([test "x$PYTHON_SPHINX_EXISTS" = xno],
+ AC_MSG_ERROR([The Sphinx package for Python 3 is required to build Python bindings documentation])
)
fi
-EXTRA_DIST = source
+SPHINX_SOURCE_DIR = $(srcdir)/source
+SPHINX_BUILD_DIR = build
+SPHINX_BUILD_HTML_DIR = $(SPHINX_BUILD_DIR)/html
+SPHINX_BUILD_DIRHTML_DIR = $(SPHINX_BUILD_DIR)/dirhtml
-SPHINX_HTML_TARGET = build/html/index.html
-SPHINX_DIRHTML_TARGET = build/dirhtml/index.html
+SPHINX_HTML_TARGET = $(SPHINX_BUILD_HTML_DIR)/index.html
+SPHINX_DIRHTML_TARGET = $(SPHINX_BUILD_DIRHTML_DIR)/index.html
+
+EXTRA_DIST = $(srcdir)/source
all-local: $(SPHINX_HTML_TARGET) $(SPHINX_DIRHTML_TARGET)
-PP = $(top_srcdir)/doc/bindings/python:$(top_srcdir)/doc/bindings/python/swig-libs
+PP = .:swig-libs
LLP = $(top_builddir)/formats/ctf/.libs:$(top_builddir)/lib/.libs
-LOCAL_SPHINXBUILD = PYTHONPATH="$(PP)" LD_LIBRARY_PATH="$(LLP)" $(SPHINXBUILD)
-
-SPHINX_SRC = $(wildcard source/*.rst)
+LOCAL_SPHINXBUILD = PYTHONPATH="$(PP)" LD_LIBRARY_PATH="$(LLP)" $(PYTHON) $(srcdir)/sphinx-build.py
-$(SPHINX_HTML_TARGET): $(SPHINX_SRC) babeltrace-python-deps
- $(LOCAL_SPHINXBUILD) -b dirhtml -E source build/dirhtml
+SPHINX_SRC = $(wildcard $(SPHINX_SOURCE_DIR)/*.rst)
-$(SPHINX_DIRHTML_TARGET): $(SPHINX_SRC) babeltrace-python-deps
- $(LOCAL_SPHINXBUILD) -b html -E source build/html
+BABELTRACE_PYTHON_DEPS = babeltrace swig-libs
-.PHONY: babeltrace-python-deps
+$(SPHINX_HTML_TARGET): $(SPHINX_SRC) $(BABELTRACE_PYTHON_DEPS)
+ $(LOCAL_SPHINXBUILD) -b html -E $(SPHINX_SOURCE_DIR) $(SPHINX_BUILD_HTML_DIR)
-babeltrace-python-deps: babeltrace swig-libs
+$(SPHINX_DIRHTML_TARGET): $(SPHINX_SRC) $(BABELTRACE_PYTHON_DEPS)
+ $(LOCAL_SPHINXBUILD) -b dirhtml -E $(SPHINX_SOURCE_DIR) $(SPHINX_BUILD_DIRHTML_DIR)
swig-libs:
- $(LN_S) $(top_builddir)/bindings/python/.libs $@
+ $(LN_S) $(abs_top_builddir)/bindings/python/.libs $@
babeltrace:
- $(LN_S) $(top_srcdir)/bindings/python $@
+ $(mkdir_p) $@
+ $(LN_S) $(abs_top_builddir)/bindings/python/__init__.py $@/__init__.py
+ $(LN_S) $(abs_top_srcdir)/bindings/python/common.py $@/common.py
+ $(LN_S) $(abs_top_srcdir)/bindings/python/reader.py $@/reader.py
+ $(LN_S) $(abs_top_srcdir)/bindings/python/writer.py $@/writer.py
+ $(LN_S) $(abs_top_builddir)/bindings/python/nativebt.py $@/nativebt.py
clean-local:
- rm -rf build swig-libs babeltrace
+ rm -rf $(SPHINX_BUILD_DIR) swig-libs babeltrace
--- /dev/null
+#!/usr/bin/env python
+import sys
+
+
+if __name__ == '__main__':
+ from sphinx import main, make_main
+
+ if sys.argv[1:2] == ['-M']:
+ sys.exit(make_main(sys.argv))
+ else:
+ sys.exit(main(sys.argv))
--- /dev/null
+# check_sphinx.m4 -- check for Sphinx Python package
+#
+# Copyright (C) 2015 - Philippe Proulx <pproulx@efficios.com>
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# Sphinx ships with a script named "sphinx-build", which is usually
+# installed in "/usr/bin". Unfortunately, this script uses
+# "/usr/bin/python" as its interpreter. Since "/usr/bin/python" can
+# be either Python 2 or Python 3, depending on the distribution, and
+# since we absolutely need the Python 3 Sphinx package for Babeltrace
+# because it needs to import our bindings for autodocumentation,
+# there's no way to tell if "sphinx-build" is actually using Python 2
+# or Python 3.
+#
+# This macro checks if the Sphinx package ("sphinx") is installed
+# and visible from the interpreter designated by the PYTHON variable.
+# It sets PYTHON_SPHINX_EXISTS to "yes" if Sphinx is found for the
+# given Python interpreter, otherwise "no".
+
+# AM_CHECK_PYTHON_SPHINX(PYTHON)
+# ---------------------------------------------------------------------------
+AC_DEFUN([AM_CHECK_PYTHON_SPHINX],
+ [prog="
+try:
+ import sphinx
+ print('yes')
+except ImportError:
+ print('no')"
+ PYTHON_SPHINX_EXISTS=`${$1} -c "$prog"`])