Commit | Line | Data |
---|---|---|
c0c0989a MJ |
1 | # SPDX-License-Identifier: LGPL-2.1-only |
2 | ||
9bafacb2 MJ |
3 | INSTALLED_FILES=$(builddir)/installed_files.txt |
4 | ||
5 | STATIC_BINDINGS_DEPS = \ | |
50d2bb48 | 6 | lttngust/__init__.py \ |
9bafacb2 MJ |
7 | lttngust/agent.py \ |
8 | lttngust/cmd.py \ | |
9 | lttngust/compat.py \ | |
10 | lttngust/debug.py \ | |
11 | lttngust/loghandler.py | |
12 | ||
a3ff547e MJ |
13 | GENERATED_BINDINGS_DEPS = \ |
14 | lttngust/version.py \ | |
15 | setup.py | |
16 | ||
62ac7365 MJ |
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 | |
22 | else | |
23 | export SETUPTOOLS_USE_DISTUTILS=stdlib | |
24 | endif | |
25 | ||
9bafacb2 MJ |
26 | all-local: build-python-bindings.stamp |
27 | ||
28 | copy-static-deps.stamp: $(addprefix $(srcdir)/, $(STATIC_BINDINGS_DEPS)) | |
9bc9229a | 29 | $(AM_V_at)if [ x"$(srcdir)" != x"$(builddir)" ]; then \ |
9bafacb2 MJ |
30 | for file in $(STATIC_BINDINGS_DEPS); do \ |
31 | cp -f $(srcdir)/$$file $(builddir)/$$file; \ | |
32 | done; \ | |
33 | fi | |
34 | touch $@ | |
35 | ||
5b6ff569 PP |
36 | # Use setup.py for the installation instead of Autoconf. |
37 | # This ease the installation process and assure a *pythonic* | |
38 | # installation. | |
a3ff547e | 39 | build-python-bindings.stamp: copy-static-deps.stamp $(GENERATED_BINDINGS_DEPS) |
9bc9229a | 40 | $(AM_V_at)$(PYTHON) $(builddir)/setup.py build --force |
9bafacb2 | 41 | touch $@ |
5b6ff569 | 42 | |
9bafacb2 | 43 | install-exec-local: build-python-bindings.stamp |
9bc9229a | 44 | $(AM_V_at)opts="--prefix=$(prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \ |
5b6ff569 PP |
45 | if [ "$(DESTDIR)" != "" ]; then \ |
46 | opts="$$opts --root=$(DESTDIR)"; \ | |
47 | fi; \ | |
62ac7365 | 48 | $(PYTHON) $(builddir)/setup.py install $(PY_INSTALL_OPTS) $$opts; |
5b6ff569 PP |
49 | |
50 | clean-local: | |
a49a7e68 | 51 | rm -rf $(builddir)/build |
9bc9229a | 52 | $(AM_V_at)if [ x"$(srcdir)" != x"$(builddir)" ]; then \ |
9bafacb2 MJ |
53 | for file in $(STATIC_BINDINGS_DEPS); do \ |
54 | rm -f $(builddir)/$$file; \ | |
55 | done; \ | |
56 | fi | |
5b6ff569 | 57 | |
a49a7e68 | 58 | # Distutils' setup.py does not include an uninstall target, we thus need to do |
9bafacb2 MJ |
59 | # it manually. We save the path of the files that were installed during the install target |
60 | # and delete them during the uninstallation. | |
a49a7e68 | 61 | uninstall-local: |
a49a7e68 | 62 | if [ "$(DESTDIR)" != "" ]; then \ |
9bafacb2 | 63 | $(SED) -i "s|^|$(DESTDIR)/|g" $(INSTALLED_FILES); \ |
a49a7e68 | 64 | fi |
9bafacb2 MJ |
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) | |
68 | ||
69 | EXTRA_DIST = $(STATIC_BINDINGS_DEPS) | |
70 | ||
71 | CLEANFILES = \ | |
72 | build-python-bindings.stamp \ | |
73 | copy-static-deps.stamp |