1 # SPDX-License-Identifier: LGPL-2.1-only
3 INSTALLED_FILES=$(builddir)/installed_files.txt
5 STATIC_BINDINGS_DEPS = \
11 lttngust/loghandler.py
13 GENERATED_BINDINGS_DEPS = \
17 # For python < 3.12, force the use of distutils even if setuptools is
18 # installed. For python >= 3.12, set the externally managed option to allow
19 # installation in a directory which isn't in the current PYTHONPATH.
20 if HAVE_PYTHON_312_OR_GREATER
21 PY_INSTALL_OPTS = --single-version-externally-managed
23 export SETUPTOOLS_USE_DISTUTILS=stdlib
26 all-local: build-python-bindings.stamp
28 copy-static-deps.stamp: $(addprefix $(srcdir)/, $(STATIC_BINDINGS_DEPS))
29 @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
30 for file in $(STATIC_BINDINGS_DEPS); do \
31 cp -f $(srcdir)/$$file $(builddir)/$$file; \
36 # Use setup.py for the installation instead of Autoconf.
37 # This ease the installation process and assure a *pythonic*
39 build-python-bindings.stamp: copy-static-deps.stamp $(GENERATED_BINDINGS_DEPS)
40 $(PYTHON) $(builddir)/setup.py build --force
43 install-exec-local: build-python-bindings.stamp
44 @opts="--prefix=$(prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \
45 if [ "$(DESTDIR)" != "" ]; then \
46 opts="$$opts --root=$(DESTDIR)"; \
48 $(PYTHON) $(builddir)/setup.py install $(PY_INSTALL_OPTS) $$opts;
51 rm -rf $(builddir)/build
52 @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
53 for file in $(STATIC_BINDINGS_DEPS); do \
54 rm -f $(builddir)/$$file; \
58 # Distutils' setup.py does not include an uninstall target, we thus need to do
59 # it manually. We save the path of the files that were installed during the install target
60 # and delete them during the uninstallation.
62 if [ "$(DESTDIR)" != "" ]; then \
63 $(SED) -i "s|^|$(DESTDIR)/|g" $(INSTALLED_FILES); \
65 cat $(INSTALLED_FILES) | xargs rm -rf || true
66 $(GREP) "__init__.py" $(INSTALLED_FILES) | xargs dirname | xargs rm -rf || true
67 rm -f $(INSTALLED_FILES)
69 EXTRA_DIST = $(STATIC_BINDINGS_DEPS)
72 build-python-bindings.stamp \
73 copy-static-deps.stamp