Fix: legacy python bindings Makefile
[babeltrace.git] / bindings / python / babeltrace / Makefile.am
index 26f388caab4bd750a6dc0d2e7280a1acf4399e97..a331b389f68b14f84f56b7a2ceb094db8d78603d 100644 (file)
@@ -1,34 +1,68 @@
-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
+# Since the shared object used by the python bindings is not built with
+# libtool, we need to add the directory containing libbabeltrace to the
+# linker path.
+AM_LDFLAGS=-L$(top_builddir)/lib/.libs
 
-all-local: $(INIT_PY)
+INSTALLED_FILES=$(builddir)/installed_files.txt
 
-$(INIT_PY): $(INIT_PY_IN)
-       sed "s/BABELTRACE_VERSION_STR/$(PACKAGE_VERSION)/g" < $< > $@
+STATIC_BINDINGS_DEPS =                         \
+       babeltrace/common.py                    \
+       babeltrace/reader.py                    \
+       babeltrace/reader_event_declaration.py  \
+       babeltrace/reader_event.py              \
+       babeltrace/reader_field_declaration.py  \
+       babeltrace/reader_field_definition.py   \
+       babeltrace/reader_trace_collection.py   \
+       babeltrace/reader_trace_handle.py       \
+       babeltrace/writer.py
 
-AM_CFLAGS = $(PYTHON_INCLUDE) -I$(top_srcdir)/include/ -I$(srcdir)
+GENERATED_BINDINGS_DEPS =                      \
+       babeltrace/__init__.py                  \
+       setup.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)
+all-local: build-python-bindings.stamp
 
-MAINTAINERCLEANFILES = $(NATIVEBT_PY) $(NATIVEBT_WRAP_C)
+copy-static-deps.stamp: $(STATIC_BINDINGS_DEPS)
+       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+               for file in $(STATIC_BINDINGS_DEPS); do \
+                       cp -f $(srcdir)/$$file $(builddir)/$$file; \
+               done; \
+       fi
+       touch $@
 
-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
+build-python-bindings.stamp: copy-static-deps.stamp $(GENERATED_BINDINGS_DEPS)
+       $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build
+       touch $@
 
-# SWIG 'warning md variable unused' fixed after SWIG build:
-$(NATIVEBT_WRAP_C): $(NATIVEBT_I)
-       $(SWIG) -python -Wall -I$(srcdir) -I$(top_srcdir)/include -outcurrentdir $<
+install-exec-local: build-python-bindings.stamp
+       @opts="--prefix=$(prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \
+       if [ "$(DESTDIR)" != "" ]; then \
+               opts="$$opts --root=$(DESTDIR)"; \
+       fi; \
+       $(PYTHON) $(builddir)/setup.py install $$opts;
 
-CLEANFILES = $(NATIVEBT_PY) $(NATIVEBT_WRAP_C) $(INIT_PY)
+clean-local:
+       rm -rf $(builddir)/build
+       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+               for file in $(STATIC_BINDINGS_DEPS); do \
+                       rm -f $(builddir)/$$file; \
+               done; \
+       fi
+
+# Distutils' setup.py does not include an uninstall target, we thus need to do
+# it manually. We save the path of the files that were installed during the install target
+# and delete them during the uninstallation.
+uninstall-local:
+       if [ "$(DESTDIR)" != "" ]; then \
+               $(SED) -i "s|^|$(DESTDIR)/|g" $(INSTALLED_FILES); \
+       fi
+       cat $(INSTALLED_FILES) | xargs rm -rf || true
+       $(GREP) "__init__.py" $(INSTALLED_FILES) | xargs dirname | xargs rm -rf || true
+       rm -f $(INSTALLED_FILES)
+
+# distribute: extra Python modules and SWIG interface files
+EXTRA_DIST = $(STATIC_BINDINGS_DEPS)
+
+# clean: generated Python files and stamps
+CLEANFILES = build-python-bindings.stamp copy-static-deps.stamp
This page took 0.024536 seconds and 4 git commands to generate.