X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=python-lttngust%2FMakefile.am;h=8643d0f98340418154a9c79f8696f26c7ae0cd10;hb=c0c0989ab70574e09b2f7e8b48c2da6af664a849;hp=cc289895e42f1b6cd4474b8c2ac9e2c02d4e0c95;hpb=5b6ff569c0bf82b72f263a259e7a73a453903648;p=lttng-ust.git diff --git a/python-lttngust/Makefile.am b/python-lttngust/Makefile.am index cc289895..8643d0f9 100644 --- a/python-lttngust/Makefile.am +++ b/python-lttngust/Makefile.am @@ -1,7 +1,8 @@ +# SPDX-License-Identifier: LGPL-2.1-only + # Use setup.py for the installation instead of Autoconf. # This ease the installation process and assure a *pythonic* # installation. -agent_path=lttngust all-local: $(PYTHON) setup.py build --verbose @@ -13,13 +14,36 @@ install-exec-local: $(PYTHON) setup.py install $$opts; clean-local: - rm -rf build - -uninstall-local: - rm -rf $(DESTDIR)$(pkgpythondir) + rm -rf $(builddir)/build -EXTRA_DIST=$(agent_path) +# Distutils' setup.py does not include an uninstall target, we thus need to do +# it manually. We fake an install in a temporary folder and use the generated +# tree structure to infere the actual location within the install prefix. +# 1. Create temporary file and folder +# 2. Set the root install folder for a temporary folder +# 3. Install in that temporary folder and record all the files installed +# 4. If DESTDIR is set, prepend it to the paths of the install files +# 5. Remove the installed files and the Python package folder +# 6. Remove the files created by this target -# Remove automake generated file before dist -dist-hook: - rm -rf $(distdir)/$(agent_path)/__init__.py +uninstall-local: + $(eval TMP_INSTALLED_FILES:=$(shell mktemp $(builddir)/tmp-installed-files-XXXXXX)) + $(eval TMP_INSTALL_DIR:=$(shell mktemp -d $(builddir)/tmp-install-dir-XXXXXX)) + $(eval TMP_BUILD_DIR:=$(shell mktemp -d $(builddir)/tmp-build-dir-XXXXXX)) + @opts="--root=$(TMP_INSTALL_DIR) --prefix=$(prefix) --record $(TMP_INSTALLED_FILES) --no-compile $(DISTSETUPOPTS)"; \ + if [ "$(DESTDIR)" != "" ]; then \ + opts="$$opts --root=$(DESTDIR)"; \ + else \ + opts="$$opts --root=$(TMP_INSTALL_DIR)"; \ + fi; \ + $(PYTHON) setup.py build --build-base $(TMP_BUILD_DIR) install $$opts > /dev/null || true + + if [ "$(DESTDIR)" != "" ]; then \ + $(SED) -i "s|^|$(DESTDIR)/|g" $(TMP_INSTALLED_FILES); \ + fi + + cat $(TMP_INSTALLED_FILES) | xargs rm -rf || true + $(GREP) "__init__.py" $(TMP_INSTALLED_FILES) | xargs dirname | xargs rm -rf || true + rm -f $(TMP_INSTALLED_FILES) + rm -rf $(TMP_INSTALL_DIR) + rm -rf $(TMP_BUILD_DIR)