~lttng/lttng-ust/lttng-ust

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# SPDX-License-Identifier: LGPL-2.1-only

INSTALLED_FILES=$(builddir)/installed_files.txt

STATIC_BINDINGS_DEPS = \
	lttngust/__init__.py \
	lttngust/agent.py \
	lttngust/cmd.py \
	lttngust/compat.py \
	lttngust/debug.py \
	lttngust/loghandler.py

GENERATED_BINDINGS_DEPS = \
	lttngust/version.py \
	setup.py

# For python < 3.12, force the use of distutils even if setuptools is
# installed. For python >= 3.12, set the externally managed option to allow
# installation in a directory which isn't in the current PYTHONPATH.
if HAVE_PYTHON_312_OR_GREATER
PY_INSTALL_OPTS = --single-version-externally-managed
else
export SETUPTOOLS_USE_DISTUTILS=stdlib
endif

all-local: build-python-bindings.stamp

copy-static-deps.stamp: $(addprefix $(srcdir)/, $(STATIC_BINDINGS_DEPS))
	$(AM_V_at)if [ x"$(srcdir)" != x"$(builddir)" ]; then \
		for file in $(STATIC_BINDINGS_DEPS); do \
			cp -f $(srcdir)/$$file $(builddir)/$$file; \
		done; \
	fi
	touch $@

# Use setup.py for the installation instead of Autoconf.
# This ease the installation process and assure a *pythonic*
# installation.
build-python-bindings.stamp: copy-static-deps.stamp $(GENERATED_BINDINGS_DEPS)
	$(AM_V_at)$(PYTHON) $(builddir)/setup.py build --force
	touch $@

install-exec-local: build-python-bindings.stamp
	$(AM_V_at)opts="--prefix=$(prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \
	if [ "$(DESTDIR)" != "" ]; then \
		opts="$$opts --root=$(DESTDIR)"; \
	fi; \
	$(PYTHON) $(builddir)/setup.py install $(PY_INSTALL_OPTS) $$opts;

clean-local:
	rm -rf $(builddir)/build
	$(AM_V_at)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)

EXTRA_DIST = $(STATIC_BINDINGS_DEPS)

CLEANFILES = \
	build-python-bindings.stamp \
	copy-static-deps.stamp