Commit | Line | Data |
---|---|---|
678c0c06 MJ |
1 | GENERATED_BINDINGS_DEPS = \ |
2 | lttngust/__init__.py \ | |
3 | setup.py | |
4 | ||
d9bf54d4 MJ |
5 | # For python < 3.12, force the use of distutils even if setuptools is |
6 | # installed. For python >= 3.12, set the externally managed option to allow | |
7 | # installation in a directory which isn't in the current PYTHONPATH. | |
8 | if HAVE_PYTHON_312_OR_GREATER | |
9 | PY_INSTALL_OPTS = --single-version-externally-managed | |
10 | else | |
11 | export SETUPTOOLS_USE_DISTUTILS=stdlib | |
12 | endif | |
13 | ||
5b6ff569 PP |
14 | # Use setup.py for the installation instead of Autoconf. |
15 | # This ease the installation process and assure a *pythonic* | |
16 | # installation. | |
678c0c06 | 17 | all-local: $(GENERATED_BINDINGS_DEPS) |
5b6ff569 PP |
18 | $(PYTHON) setup.py build --verbose |
19 | ||
20 | install-exec-local: | |
21 | @opts="--prefix=$(prefix) --verbose --no-compile $(DISTSETUPOPTS)"; \ | |
22 | if [ "$(DESTDIR)" != "" ]; then \ | |
23 | opts="$$opts --root=$(DESTDIR)"; \ | |
24 | fi; \ | |
d9bf54d4 | 25 | $(PYTHON) setup.py install $(PY_INSTALL_OPTS) $$opts; |
5b6ff569 PP |
26 | |
27 | clean-local: | |
a49a7e68 | 28 | rm -rf $(builddir)/build |
5b6ff569 | 29 | |
a49a7e68 FD |
30 | # Distutils' setup.py does not include an uninstall target, we thus need to do |
31 | # it manually. We fake an install in a temporary folder and use the generated | |
32 | # tree structure to infere the actual location within the install prefix. | |
33 | # 1. Create temporary file and folder | |
34 | # 2. Set the root install folder for a temporary folder | |
35 | # 3. Install in that temporary folder and record all the files installed | |
36 | # 4. If DESTDIR is set, prepend it to the paths of the install files | |
37 | # 5. Remove the installed files and the Python package folder | |
38 | # 6. Remove the files created by this target | |
5b6ff569 | 39 | |
a49a7e68 FD |
40 | uninstall-local: |
41 | $(eval TMP_INSTALLED_FILES:=$(shell mktemp $(builddir)/tmp-installed-files-XXXXXX)) | |
42 | $(eval TMP_INSTALL_DIR:=$(shell mktemp -d $(builddir)/tmp-install-dir-XXXXXX)) | |
43 | $(eval TMP_BUILD_DIR:=$(shell mktemp -d $(builddir)/tmp-build-dir-XXXXXX)) | |
44 | @opts="--root=$(TMP_INSTALL_DIR) --prefix=$(prefix) --record $(TMP_INSTALLED_FILES) --no-compile $(DISTSETUPOPTS)"; \ | |
45 | if [ "$(DESTDIR)" != "" ]; then \ | |
46 | opts="$$opts --root=$(DESTDIR)"; \ | |
47 | else \ | |
48 | opts="$$opts --root=$(TMP_INSTALL_DIR)"; \ | |
49 | fi; \ | |
50 | $(PYTHON) setup.py build --build-base $(TMP_BUILD_DIR) install $$opts > /dev/null || true | |
51 | ||
52 | if [ "$(DESTDIR)" != "" ]; then \ | |
53 | $(SED) -i "s|^|$(DESTDIR)/|g" $(TMP_INSTALLED_FILES); \ | |
54 | fi | |
55 | ||
56 | cat $(TMP_INSTALLED_FILES) | xargs rm -rf || true | |
57 | $(GREP) "__init__.py" $(TMP_INSTALLED_FILES) | xargs dirname | xargs rm -rf || true | |
58 | rm -f $(TMP_INSTALLED_FILES) | |
59 | rm -rf $(TMP_INSTALL_DIR) | |
60 | rm -rf $(TMP_BUILD_DIR) |