[xen master] Makefile: Fix uninstall target

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[xen master] Makefile: Fix uninstall target

patchbot
commit f2b40dababedcd8355bf3e85d00baf17f9827131
Author:     Petre Pircalabu <[hidden email]>
AuthorDate: Thu Jul 27 20:08:27 2017 +0300
Commit:     Wei Liu <[hidden email]>
CommitDate: Fri Jul 28 17:47:42 2017 +0100

    Makefile: Fix uninstall target
   
    Running "make uninstall" does not remove all installed files, a
    situation which might cause link related issues if xen is re-installed
    in a different location.
    In order to make uninstall correctly remove the files it is best
    the process should be done recursively by mirroring each "install"
    target with an "uninstall" who removes the installed files.
   
    An exception to this rule is uninstalling the files produced by
    "qemu-xen-dir-remote" and "qemu-xen-traditional-dir", which are external
    to the project. These projects do not implement an "uninstall" target so
    the files have to be removed manually.
   
    Signed-off-by: Petre Pircalabu <[hidden email]>
    Acked-by: Wei Liu <[hidden email]>
---
 Makefile                                     | 22 +++++++++++--
 docs/Makefile                                | 15 ++++++++-
 m4/stubdom.m4                                |  2 ++
 stubdom/Makefile                             | 31 ++++++++++++++++++
 tools/Makefile                               | 47 +++++++---------------------
 tools/Rules.mk                               |  4 +--
 tools/blktap2/Makefile                       |  4 +--
 tools/blktap2/control/Makefile               | 10 +++++-
 tools/blktap2/drivers/Makefile               |  5 ++-
 tools/blktap2/include/Makefile               |  2 ++
 tools/blktap2/lvm/Makefile                   |  4 ++-
 tools/blktap2/vhd/Makefile                   |  6 +++-
 tools/blktap2/vhd/lib/Makefile               |  8 ++++-
 tools/console/Makefile                       |  5 +++
 tools/debugger/gdbsx/Makefile                |  4 +++
 tools/debugger/kdd/Makefile                  |  4 +++
 tools/examples/Makefile                      | 11 +++++++
 tools/firmware/Makefile                      | 10 ++++++
 tools/flask/Makefile                         |  4 +--
 tools/flask/policy/Makefile.common           |  5 ++-
 tools/flask/utils/Makefile                   |  4 +++
 tools/fuzz/Makefile                          |  4 +--
 tools/fuzz/libelf/Makefile                   |  2 ++
 tools/fuzz/x86_instruction_emulator/Makefile |  2 ++
 tools/golang/Makefile                        |  3 ++
 tools/golang/xenlight/Makefile               |  3 ++
 tools/helpers/Makefile                       |  7 +++++
 tools/hotplug/FreeBSD/Makefile               | 13 ++++++++
 tools/hotplug/Linux/Makefile                 | 19 +++++++++++
 tools/hotplug/Linux/systemd/Makefile         |  6 ++++
 tools/hotplug/Makefile                       |  4 +--
 tools/hotplug/NetBSD/Makefile                | 13 ++++++++
 tools/hotplug/common/Makefile                |  8 +++++
 tools/include/Makefile                       |  5 +++
 tools/libfsimage/Makefile                    |  4 +--
 tools/libfsimage/Rules.mk                    |  7 +++++
 tools/libfsimage/common/Makefile             |  9 ++++++
 tools/libfsimage/ext2fs-lib/Makefile         |  3 ++
 tools/libfsimage/ext2fs/Makefile             |  3 ++
 tools/libfsimage/fat/Makefile                |  3 ++
 tools/libfsimage/iso9660/Makefile            |  3 ++
 tools/libfsimage/reiserfs/Makefile           |  3 ++
 tools/libfsimage/ufs/Makefile                |  3 ++
 tools/libfsimage/xfs/Makefile                |  3 ++
 tools/libfsimage/zfs/Makefile                |  3 ++
 tools/libs/Makefile                          |  2 +-
 tools/libs/call/Makefile                     |  9 ++++++
 tools/libs/devicemodel/Makefile              |  9 ++++++
 tools/libs/evtchn/Makefile                   |  9 ++++++
 tools/libs/foreignmemory/Makefile            |  9 ++++++
 tools/libs/gnttab/Makefile                   |  9 ++++++
 tools/libs/toollog/Makefile                  |  9 ++++++
 tools/libvchan/Makefile                      |  9 ++++++
 tools/libxc/Makefile                         | 16 ++++++++++
 tools/libxl/Makefile                         | 14 +++++++++
 tools/memshr/Makefile                        |  4 ++-
 tools/misc/Makefile                          |  6 ++++
 tools/ocaml/Makefile                         |  3 ++
 tools/ocaml/libs/Makefile                    |  3 ++
 tools/ocaml/test/Makefile                    |  2 ++
 tools/ocaml/xenstored/Makefile               |  4 +++
 tools/pygrub/Makefile                        | 15 +++++++--
 tools/python/Makefile                        | 13 ++++++--
 tools/tests/Makefile                         |  4 ++-
 tools/xcutils/Makefile                       |  3 ++
 tools/xenmon/Makefile                        |  6 ++++
 tools/xenpaging/Makefile                     |  5 ++-
 tools/xenpmd/Makefile                        |  4 +++
 tools/xenstat/Makefile                       |  4 +--
 tools/xenstat/libxenstat/Makefile            | 24 ++++++++++++++
 tools/xenstat/xentop/Makefile                |  8 +++--
 tools/xenstore/Makefile                      | 30 ++++++++++++++++++
 tools/xentrace/Makefile                      |  9 ++++++
 tools/xl/Makefile                            |  5 +++
 74 files changed, 517 insertions(+), 70 deletions(-)

diff --git a/Makefile b/Makefile
index 0b5f57d..1d43044 100644
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,7 @@ all: dist
 SUBSYSTEMS?=xen tools stubdom docs
 TARGS_DIST=$(patsubst %, dist-%, $(SUBSYSTEMS))
 TARGS_INSTALL=$(patsubst %, install-%, $(SUBSYSTEMS))
+TARGS_UNINSTALL=$(patsubst %, uninstall-%, $(SUBSYSTEMS))
 TARGS_BUILD=$(patsubst %, build-%, $(SUBSYSTEMS))
 TARGS_CLEAN=$(patsubst %, clean-%, $(SUBSYSTEMS))
 TARGS_DISTCLEAN=$(patsubst %, distclean-%, $(SUBSYSTEMS))
@@ -303,11 +304,26 @@ help:
  @echo '  [ this documentation is sadly not complete ]'
 
 # Use this target with extreme care!
+
+.PHONY: uninstall-xen
+uninstall-xen:
+ $(MAKE) -C xen uninstall
+
+.PHONY: uninstall-tools
+uninstall-tools:
+ $(MAKE) -C tools uninstall
+
+.PHONY: uninstall-stubdom
+uninstall-stubdom:
+ $(MAKE) -C stubdom uninstall
+
+.PHONY: uninstall-docs
+uninstall-docs:
+ $(MAKE) -C docs uninstall
+
 .PHONY: uninstall
 uninstall: D=$(DESTDIR)
-uninstall:
- $(MAKE) -C xen uninstall
- make -C tools uninstall
+uninstall: uninstall-tools-public-headers $(TARGS_UNINSTALL)
  rm -rf $(D)/boot/tboot*
 
 .PHONY: xenversion
diff --git a/docs/Makefile b/docs/Makefile
index e064de0..9422472 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -92,7 +92,7 @@ distclean: clean
 
 # Top level install targets
 
-.PHONY: man-pages install-man-pages clean-man-pages
+.PHONY: man-pages install-man-pages clean-man-pages uninstall-man-pages
 
 # Metarules for generating manpages.  Run with $(1) substitued for section
 define GENERATE_MANPAGE_RULES
@@ -165,10 +165,16 @@ install-man$(1)-pages: man$(1)-pages
 clean-man$(1)-pages:
  rm -rf man$(1)
 
+# Uninstall
+.PHONY: uninstall-man$(1)-pages
+uninstall-man$(1)-pages:
+ rm -f $(addprefix $(DESTDIR)$(mandir)/man$(1)/, $(filter-out %.pod.$(1) %.markdown.$(1), $(notdir $(DOC_MAN$(1)))))
+
 # Link buld/install/clean to toplevel rules
 man-pages: man$(1)-pages
 install-man-pages: install-man$(1)-pages
 clean-man-pages: clean-man$(1)-pages
+uninstall-man-pages: uninstall-man$(1)-pages
 
 endef
 
@@ -183,6 +189,13 @@ install-html: html txt figs
 .PHONY: install
 install: install-man-pages install-html
 
+.PHONY: uninstall-html
+uninstall-html:
+ rm -rf $(DESTDIR)$(docdir)
+
+.PHONY: uninstall
+uninstall: uninstall-man-pages uninstall-html
+
 # Individual file build targets
 html/index.html: $(DOC_HTML) $(CURDIR)/gen-html-index INDEX
  $(PERL) -w -- $(CURDIR)/gen-html-index -i INDEX html $(DOC_HTML)
diff --git a/m4/stubdom.m4 b/m4/stubdom.m4
index f4b4cef..6aa488b 100644
--- a/m4/stubdom.m4
+++ b/m4/stubdom.m4
@@ -46,6 +46,7 @@ $2=y
 STUBDOM_TARGETS="$STUBDOM_TARGETS $2"
 STUBDOM_BUILD="$STUBDOM_BUILD $1"
 STUBDOM_INSTALL="$STUBDOM_INSTALL install-$2"
+STUBDOM_UNINSTALL="$STUBDOM_UNINSTALL install-$2"
 ])
 
 AC_DEFUN([AX_DISABLE_STUBDOM], [
@@ -67,6 +68,7 @@ AC_DEFUN([AX_STUBDOM_FINISH], [
 AC_SUBST(STUBDOM_TARGETS)
 AC_SUBST(STUBDOM_BUILD)
 AC_SUBST(STUBDOM_INSTALL)
+AC_SUBST(STUBDOM_UNINSTALL)
 echo "Will build the following stub domains:"
 for x in $STUBDOM_BUILD; do
  echo "  $x"
diff --git a/stubdom/Makefile b/stubdom/Makefile
index 5055e31..39067c8 100644
--- a/stubdom/Makefile
+++ b/stubdom/Makefile
@@ -606,6 +606,37 @@ install-vtpmmgr: vtpmmgr-stubdom
  $(INSTALL_DIR) "$(DESTDIR)$(XENFIRMWAREDIR)"
  $(INSTALL_PROG) mini-os-$(XEN_TARGET_ARCH)-vtpmmgr/mini-os.gz "$(DESTDIR)$(XENFIRMWAREDIR)/vtpmmgr-stubdom.gz"
 
+###########
+# uninstall
+###########
+
+ifeq (x$(STUBDOM_UNINSTALL),x)
+STUBDOM_UNINSTALL=$(patsubst install-%,uninstall-%,$(STUBDOM_INSTALL))
+endif
+
+ifeq ($(STUBDOM_SUPPORTED),1)
+uninstall: $(STUBDOM_UNINSTALL)
+else
+uninstall:
+endif
+
+uninstall-ioemu:
+ rm -f $(DESTDIR)$(LIBEXEC_BIN)/stubdom-dm
+ rm -f $(DESTDIR)$(LIBEXEC_BIN)/stubdompath.sh
+ rm -f $(DESTDIR)$(XENFIRMWAREDIR)/ioemu-stubdom.gz
+
+uninstall-grub:
+ rm -f $(DESTDIR)$(XENFIRMWAREDIR)/pv-grub-$(XEN_TARGET_ARCH).gz
+
+uninstall-xenstore:
+ rm -f $(DESTDIR)$(XENFIRMWAREDIR)/xenstore-stubdom.gz
+
+uninstall-vtpm:
+ rm -f $(DESTDIR)$(XENFIRMWAREDIR)/vtpm-stubdom.gz
+
+uninstall-vtpmmgr:
+ rm -f $(DESTDIR)$(XENFIRMWAREDIR)/vtpmmgr-stubdom.gz
+
 #######
 # clean
 #######
diff --git a/tools/Makefile b/tools/Makefile
index 496428e..11ad42c 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -77,43 +77,10 @@ install:
 uninstall: D=$(DESTDIR)
 uninstall:
  [ -d $(D)$(XEN_CONFIG_DIR) ] && mv -f $(D)$(XEN_CONFIG_DIR) $(D)$(XEN_CONFIG_DIR).old-`date +%s` || true
- rm -rf $(D)$(CONFIG_DIR)/init.d/xendomains $(D)$(CONFIG_DIR)/init.d/xend
- rm -rf $(D)$(CONFIG_DIR)/init.d/xencommons $(D)$(CONFIG_DIR)/init.d/xen-watchdog
- rm -f  $(D)$(CONFIG_DIR)/udev/rules.d/xen-backend.rules
- rm -f  $(D)$(CONFIG_DIR)/udev/rules.d/xend.rules
- rm -f  $(D)$(SYSCONFIG_DIR)/xendomains
- rm -f  $(D)$(sbindir)/xendomains
- rm -f  $(D)$(SYSCONFIG_DIR)/xencommons
- rm -rf $(D)$(XEN_LIB_DIR)
- rm -rf $(D)$(XEN_LIB_STORED)
- rm -rf $(D)$(XEN_RUN_STORED)
- rm -rf $(D)$(PKG_INSTALLDIR)
- rm -rf $(D)$(bindir)/cpuperf-perfcntr $(D)$(bindir)/cpuperf-xen
- rm -rf $(D)$(bindir)/xc_shadow
- rm -rf $(D)$(bindir)/pygrub
- rm -rf $(D)$(bindir)/setsize $(D)$(bindir)/tbctl
- rm -rf $(D)$(bindir)/xsls
- rm -rf $(D)$(bindir)/xenstore* $(D)$(bindir)/xentrace*
- rm -rf $(D)$(bindir)/xen-detect $(D)$(bindir)/xencons
- rm -rf $(D)$(bindir)/xenpvnetboot $(D)$(bindir)/qemu-*-xen
- rm -rf $(D)$(includedir)/xenctrl* $(D)$(includedir)/xenguest.h
- rm -rf $(D)$(includedir)/xs_lib.h $(D)$(includedir)/xs.h
- rm -rf $(D)$(includedir)/xenstore-compat/xs_lib.h $(D)$(includedir)/xenstore-compat/xs.h
- rm -rf $(D)$(includedir)/xenstore_lib.h $(D)$(includedir)/xenstore.h
- rm -rf $(D)$(includedir)/xen
- rm -rf $(D)$(includedir)/_libxl* $(D)$(includedir)/libxl*
- rm -rf $(D)$(includedir)/xenstat.h $(D)$(includedir)/xentoollog.h
- rm -rf $(D)$(libdir)/libxenctrl* $(D)$(libdir)/libxenguest*
- rm -rf $(D)$(libdir)/libxenstore* $(D)$(libdir)/libxlutil*
- rm -rf $(D)$(libdir)/python/xen $(D)$(libdir)/python/grub
- rm -rf $(D)$(LIBEXEC)
- rm -rf $(D)$(sbindir)/setmask
- rm -rf $(D)$(sbindir)/xen* $(D)$(sbindir)/netfix $(D)$(sbindir)/xm
- rm -rf $(D)$(SHAREDIR)/doc/xen
+ rm -rf $(D)$(libdir)/xen
  rm -rf $(D)$(SHAREDIR)/xen
  rm -rf $(D)$(SHAREDIR)/qemu-xen
- rm -rf $(D)$(MAN1DIR)/xen*
- rm -rf $(D)$(MAN8DIR)/xen*
+ $(MAKE) subdirs-uninstall
 
 .PHONY: clean
 clean: subdirs-clean
@@ -221,6 +188,9 @@ subdir-clean-qemu-xen-traditional-dir:
  set -e; if test -d qemu-xen-traditional-dir/.; then \
  $(MAKE) -C qemu-xen-traditional-dir clean; \
  fi
+subdir-uninstall-qemu-xen-traditional-dir:
+ rm -f $(D)$(bindir)/qemu-nbd*
+ rm -f $(D)$(bindir)/qemu-img*
 
 # External target: qemu-xen
 qemu-xen-dir-find:
@@ -317,6 +287,8 @@ subdir-clean-qemu-xen-dir:
  $(MAKE) -C qemu-xen-build clean; \
  fi
 
+subdir-uninstall-qemu-xen-dir: ;
+
 subdir-clean-debugger/gdbsx subdir-distclean-debugger/gdbsx: .phony
  $(MAKE) -C debugger/gdbsx clean
 
@@ -326,6 +298,8 @@ subdir-install-debugger/gdbsx: .phony
 subdir-all-debugger/gdbsx: .phony
  $(MAKE) -C debugger/gdbsx all
 
+subdir-uninstall-debugger/gdbsx: .phony
+ $(MAKE) -C debugger/gdbsx uninstall
 
 subdir-clean-debugger/kdd subdir-distclean-debugger/kdd: .phony
  $(MAKE) -C debugger/kdd clean
@@ -333,6 +307,9 @@ subdir-clean-debugger/kdd subdir-distclean-debugger/kdd: .phony
 subdir-install-debugger/kdd: .phony
  $(MAKE) -C debugger/kdd install
 
+subdir-uninstall-debugger/kdd: .phony
+ $(MAKE) -C debugger/kdd uninstall
+
 subdir-all-debugger/kdd: .phony
  $(MAKE) -C debugger/kdd all
 
diff --git a/tools/Rules.mk b/tools/Rules.mk
index f55fb66..4592601 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -233,12 +233,12 @@ headers.chk:
  done >$@.new
  mv $@.new $@
 
-subdirs-all subdirs-clean subdirs-install subdirs-distclean: .phony
+subdirs-all subdirs-clean subdirs-install subdirs-distclean subdirs-uninstall: .phony
  @set -e; for subdir in $(SUBDIRS) $(SUBDIRS-y); do \
  $(MAKE) subdir-$(patsubst subdirs-%,%,$@)-$$subdir; \
  done
 
-subdir-all-% subdir-clean-% subdir-install-%: .phony
+subdir-all-% subdir-clean-% subdir-install-% subdir-uninstall-%: .phony
  $(MAKE) -C $* $(patsubst subdir-%-$*,%,$@)
 
 subdir-distclean-%: .phony
diff --git a/tools/blktap2/Makefile b/tools/blktap2/Makefile
index 94200dc..f4758ef 100644
--- a/tools/blktap2/Makefile
+++ b/tools/blktap2/Makefile
@@ -16,5 +16,5 @@ clean:
 
 distclean: clean
 
-.PHONY: all clean install distclean
-all clean install distclean: %: subdirs-%
+.PHONY: all clean install distclean uninstall
+all clean install distclean uninstall: %: subdirs-%
diff --git a/tools/blktap2/control/Makefile b/tools/blktap2/control/Makefile
index 0d731f7..c168283 100644
--- a/tools/blktap2/control/Makefile
+++ b/tools/blktap2/control/Makefile
@@ -92,8 +92,16 @@ clean:
  rm -f *~
  rm -f xenblktapctl.pc
 
+uninstall:
+ rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenblktapctl.pc
+ rm -f $(DESTDIR)$(libdir)/$(LIBSONAME)
+ rm -f $(DESTDIR)$(libdir)/$(LIBNAME).so
+ rm -f $(addprefix $(DESTDIR)$(libdir)/, $(LIB_SHARED))
+ rm -f $(addprefix $(DESTDIR)$(libdir)/, $(LIB_STATIC))
+ rm -f $(addprefix $(DESTDIR)$(sbindir)/, $(IBIN))
+
 distclean: clean
 
-.PHONY: all build clean distclean install
+.PHONY: all build clean distclean install uninstall
 
 -include $(DEPS)
diff --git a/tools/blktap2/drivers/Makefile b/tools/blktap2/drivers/Makefile
index 5328c40..f610ddb 100644
--- a/tools/blktap2/drivers/Makefile
+++ b/tools/blktap2/drivers/Makefile
@@ -105,9 +105,12 @@ install: all
  $(INSTALL_DIR) -p $(DESTDIR)$(INST_DIR)
  $(INSTALL_PROG) $(IBIN) $(LOCK_UTIL) $(QCOW_UTIL) $(DESTDIR)$(INST_DIR)
 
+uninstall:
+ rm -f $(addprefix $(DESTDIR)$(INST_DIR)/, $(IBIN) $(LOCK_UTIL) $(QCOW_UTIL))
+
 clean:
  rm -rf .*.d *.o *~ xen TAGS $(IBIN) $(LIB) $(LOCK_UTIL) $(QCOW_UTIL)
 
 distclean: clean
 
-.PHONY: clean install distclean
+.PHONY: clean install distclean uninstall
diff --git a/tools/blktap2/include/Makefile b/tools/blktap2/include/Makefile
index 66e8a1e..c8e2d26 100644
--- a/tools/blktap2/include/Makefile
+++ b/tools/blktap2/include/Makefile
@@ -8,6 +8,8 @@ all:
 install:
  $(INSTALL_DIR) -p $(DESTDIR)$(includedir)
 
+.PHONY: uninstall
+.uninstall:
 
 .PHONY: clean
 clean:
diff --git a/tools/blktap2/lvm/Makefile b/tools/blktap2/lvm/Makefile
index 7d5f8ea..72fea0a 100644
--- a/tools/blktap2/lvm/Makefile
+++ b/tools/blktap2/lvm/Makefile
@@ -23,6 +23,8 @@ build: $(TEST) $(LVM-OBJS)
 
 install: all
 
+uninstall:
+
 lvm-util: lvm-util.o
  $(CC) -DLVM_UTIL $(LDFLAGS) -o lvm-util lvm-util.c
 
@@ -31,6 +33,6 @@ clean:
 
 distclean: clean
 
-.PHONY: all build clean distclean install lvm-util
+.PHONY: all build clean distclean install lvm-util uninstall
 
 -include $(DEPS)
diff --git a/tools/blktap2/vhd/Makefile b/tools/blktap2/vhd/Makefile
index fabd665..e60b7af 100644
--- a/tools/blktap2/vhd/Makefile
+++ b/tools/blktap2/vhd/Makefile
@@ -41,11 +41,15 @@ install: all
  $(INSTALL_DIR) -p $(DESTDIR)$(INST_DIR)
  $(INSTALL_PROG) $(IBIN) $(DESTDIR)$(INST_DIR)
 
+uninstall:
+ $(MAKE) subdirs-uninstall
+ rm -f $(addprefix $(DESTDIR)$(INST_DIR)/, $(IBIN))
+
 clean: subdirs-clean
  rm -rf *.o *~ $(DEPS) $(IBIN)
 
 distclean: clean
 
-.PHONY: all build clean distclean install vhd-util vhd-update
+.PHONY: all build clean distclean install uninstall vhd-util vhd-update
 
 -include $(DEPS)
diff --git a/tools/blktap2/vhd/lib/Makefile b/tools/blktap2/vhd/lib/Makefile
index ab2d648..3bf603e 100644
--- a/tools/blktap2/vhd/lib/Makefile
+++ b/tools/blktap2/vhd/lib/Makefile
@@ -72,11 +72,17 @@ install: all
  ln -sf libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $(DESTDIR)$(INST-DIR)/libvhd.so.$(LIBVHD-MAJOR)
  ln -sf libvhd.so.$(LIBVHD-MAJOR) $(DESTDIR)$(INST-DIR)/libvhd.so
 
+uninstall:
+ rm -f $(DESTDIR)$(INST-DIR)/libvhd.so
+ rm -f $(DESTDIR)$(INST-DIR)/libvhd.so.$(LIBVHD-MAJOR)
+ rm -f $(DESTDIR)$(INST-DIR)/libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR)
+ rm -f $(DESTDIR)$(INST-DIR)/libvhd.a
+
 clean:
  rm -rf *.a *.so* *.o *.opic *~ $(DEPS) $(LIBVHD)
 
 distclean: clean
 
-.PHONY: all build clean distclean install libvhd
+.PHONY: all build clean distclean install libvhd uninstall
 
 -include $(DEPS)
diff --git a/tools/console/Makefile b/tools/console/Makefile
index c8b0300..abe77b2 100644
--- a/tools/console/Makefile
+++ b/tools/console/Makefile
@@ -49,4 +49,9 @@ install: $(BIN)
  $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
  $(INSTALL_PROG) xenconsole $(DESTDIR)$(LIBEXEC_BIN)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(LIBEXEC_BIN)/xenconsole
+ rm -f $(DESTDIR)$(sbindir)/xenconsoled
+
 -include $(DEPS)
diff --git a/tools/debugger/gdbsx/Makefile b/tools/debugger/gdbsx/Makefile
index 4ed6d76..723a274 100644
--- a/tools/debugger/gdbsx/Makefile
+++ b/tools/debugger/gdbsx/Makefile
@@ -21,6 +21,10 @@ install: all
  [ -d $(DESTDIR)$(sbindir) ] || $(INSTALL_DIR) $(DESTDIR)$(sbindir)
  $(INSTALL_PROG) gdbsx $(DESTDIR)$(sbindir)/gdbsx
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(sbindir)/gdbsx
+
 gdbsx: gx/gx_all.a xg/xg_all.a
  $(CC) -o $@ $^
 
diff --git a/tools/debugger/kdd/Makefile b/tools/debugger/kdd/Makefile
index f3a597d..bcec440 100644
--- a/tools/debugger/kdd/Makefile
+++ b/tools/debugger/kdd/Makefile
@@ -25,3 +25,7 @@ distclean: clean
 install: all
  [ -d $(DESTDIR)$(sbindir) ] || $(INSTALL_DIR) $(DESTDIR)$(sbindir)
  $(INSTALL_PROG) kdd $(DESTDIR)$(sbindir)/kdd
+
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(sbindir)/kdd
diff --git a/tools/examples/Makefile b/tools/examples/Makefile
index 87dd760..f86ed3a 100644
--- a/tools/examples/Makefile
+++ b/tools/examples/Makefile
@@ -21,6 +21,9 @@ build:
 .PHONY: install
 install: all install-readmes install-configs
 
+.PHONY: uninstall
+uninstall: uninstall-readmes uninstall-configs
+
 .PHONY: install-readmes
 install-readmes:
  [ -d $(DESTDIR)$(XEN_CONFIG_DIR) ] || \
@@ -30,6 +33,10 @@ install-readmes:
     $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_CONFIG_DIR); \
  done
 
+.PHONY: uninstall-readmes
+uninstall-readmes:
+ rm -f $(addprefix $(DESTDIR)$(XEN_CONFIG_DIR)/, $(XEN_READMES))
+
 .PHONY: install-configs
 install-configs: $(XEN_CONFIGS)
  [ -d $(DESTDIR)$(XEN_CONFIG_DIR) ] || \
@@ -41,6 +48,10 @@ install-configs: $(XEN_CONFIGS)
     $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_CONFIG_DIR); \
  done
 
+.PHONY: uninstall-configs
+uninstall-configs:
+ rm -f $(addprefix $(DESTDIR)$(XEN_CONFIG_DIR)/, $(XEN_CONFIGS))
+
 .PHONY: clean
 clean:
 
diff --git a/tools/firmware/Makefile b/tools/firmware/Makefile
index 8562f54..868b506 100644
--- a/tools/firmware/Makefile
+++ b/tools/firmware/Makefile
@@ -49,6 +49,16 @@ ifeq ($(CONFIG_OVMF),y)
  $(INSTALL_DATA) ovmf-dir/ovmf.bin $(INST_DIR)/ovmf.bin
 endif
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(addprefix $(INST_DIR)/, $(notdir $(TARGET)))
+ifeq ($(CONFIG_SEABIOS),y)
+ rm -f $(INST_DIR)/seabios.bin
+endif
+ifeq ($(CONFIG_OVMF),y)
+ rm -f $(INST_DIR)/ovmf.bin
+endif
+
 .PHONY: clean
 clean: subdirs-clean
 
diff --git a/tools/flask/Makefile b/tools/flask/Makefile
index a31cc16..335ee2a 100644
--- a/tools/flask/Makefile
+++ b/tools/flask/Makefile
@@ -4,6 +4,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 SUBDIRS-y := utils
 SUBDIRS-$(FLASK_POLICY) += policy
 
-.PHONY: all clean install distclean
-all clean install distclean: %: subdirs-%
+.PHONY: all clean install distclean uninstall
+all clean install distclean uninstall: %: subdirs-%
 
diff --git a/tools/flask/policy/Makefile.common b/tools/flask/policy/Makefile.common
index bb85ded..bea5ba4 100644
--- a/tools/flask/policy/Makefile.common
+++ b/tools/flask/policy/Makefile.common
@@ -118,6 +118,9 @@ install: $(POLICY_FILENAME)
  $(INSTALL_DIR) $(DESTDIR)/$(POLICY_LOADPATH)
  $(INSTALL_DATA) $^ $(DESTDIR)/$(POLICY_LOADPATH)
 
+uninstall:
+ rm -f $(DESTDIR)/$(POLICY_LOADPATH)/$(POLICY_FILENAME)
+
 $(POLICY_FILENAME): $(FLASK_BUILD_DIR)/policy.conf
  $(CHECKPOLICY) $(CHECKPOLICY_PARAM) $^ -o $@
 
@@ -129,4 +132,4 @@ clean:
 
 distclean: clean
 
-.PHONY: all install clean distclean
+.PHONY: all install clean distclean uninstall
diff --git a/tools/flask/utils/Makefile b/tools/flask/utils/Makefile
index 91a53b4..fc047e9 100644
--- a/tools/flask/utils/Makefile
+++ b/tools/flask/utils/Makefile
@@ -55,4 +55,8 @@ install: all
  $(INSTALL_DIR) $(DESTDIR)$(sbindir)
  $(INSTALL_PROG) $(CLIENTS) $(DESTDIR)$(sbindir)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(addprefix $(DESTDIR)$(sbindir)/, $(CLIENTS))
+
 -include $(DEPS)
diff --git a/tools/fuzz/Makefile b/tools/fuzz/Makefile
index 986fbb8..85213dc 100644
--- a/tools/fuzz/Makefile
+++ b/tools/fuzz/Makefile
@@ -5,5 +5,5 @@ SUBDIRS-y :=
 SUBDIRS-y += libelf
 SUBDIRS-y += x86_instruction_emulator
 
-.PHONY: all clean distclean install
-all clean distclean install: %: subdirs-%
+.PHONY: all clean distclean install uninstall
+all clean distclean install uninstall: %: subdirs-%
diff --git a/tools/fuzz/libelf/Makefile b/tools/fuzz/libelf/Makefile
index 6cdc31e..9eb30ee 100644
--- a/tools/fuzz/libelf/Makefile
+++ b/tools/fuzz/libelf/Makefile
@@ -36,5 +36,7 @@ clean:
 .PHONY: install
 install: all
 
+.PHONY: uninstall
+
 .PHONY: afl
 afl: afl-libelf-fuzzer
diff --git a/tools/fuzz/x86_instruction_emulator/Makefile b/tools/fuzz/x86_instruction_emulator/Makefile
index 6e3fa1e..a3f6b2c 100644
--- a/tools/fuzz/x86_instruction_emulator/Makefile
+++ b/tools/fuzz/x86_instruction_emulator/Makefile
@@ -51,5 +51,7 @@ clean:
 .PHONY: install
 install: all
 
+.PHONY: uninstall
+
 .PHONY: afl
 afl: afl-harness
diff --git a/tools/golang/Makefile b/tools/golang/Makefile
index 47a9235..aba11eb 100644
--- a/tools/golang/Makefile
+++ b/tools/golang/Makefile
@@ -19,6 +19,9 @@ all build: subdirs-all
 .PHONY: install
 install: subdirs-install
 
+.PHONY: uninstall
+uninstall: subdirs-uninstall
+
 .PHONY: clean
 clean: subdirs-clean
  $(RM) -r src pkg
diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile
index a4a1a5b..88202a6 100644
--- a/tools/golang/xenlight/Makefile
+++ b/tools/golang/xenlight/Makefile
@@ -38,6 +38,9 @@ install: build
  $(INSTALL_DIR) $(DESTDIR)$(GOXL_INSTALL_DIR)
  $(INSTALL_DATA) $(XEN_GOPATH)$(GOXL_PKG_DIR)$(PKGSOURCES) $(DESTDIR)$(GOXL_INSTALL_DIR)
 
+.PHONY: uninstall
+ rm -f $(addprefix $(DESTDIR)$(GOXL_INSTALL_DIR)/, $(PKGSOURCES))
+
 .PHONY: clean
 clean:
  $(RM) -r $(XEN_GOPATH)$(GOXL_PKG_DIR)
diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile
index 5017350..fcfca46 100644
--- a/tools/helpers/Makefile
+++ b/tools/helpers/Makefile
@@ -41,6 +41,13 @@ ifeq ($(CONFIG_Linux),y)
  $(INSTALL_PROG) init-xenstore-domain $(DESTDIR)$(LIBEXEC_BIN)
 endif
 
+.PHONY: uninstall
+uninstall:
+ifeq ($(CONFIG_Linux),y)
+ rm -f $(DESTDIR)$(LIBEXEC_BIN)/init-xenstore-domain
+endif
+ rm -f $(DESTDIR)$(LIBEXEC_BIN)/xen-init-dom0
+
 .PHONY: clean
 clean:
  $(RM) -f *.o $(PROGS) $(DEPS) _paths.h
diff --git a/tools/hotplug/FreeBSD/Makefile b/tools/hotplug/FreeBSD/Makefile
index bd7a86f..de9928c 100644
--- a/tools/hotplug/FreeBSD/Makefile
+++ b/tools/hotplug/FreeBSD/Makefile
@@ -17,6 +17,9 @@ build:
 .PHONY: install
 install: install-scripts install-rcd
 
+.PHONY: uninstall
+uninstall: uninstall-script uninstall-rcd
+
 .PHONY: install-scripts
 install-scripts:
  $(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
@@ -29,6 +32,11 @@ install-scripts:
    $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
  done
 
+.PHONY: uninstall-scripts
+uninstall-scripts:
+ rm -f $(addprefix $(DESTDIR)$(XEN_SCRIPT_DIR)/, $(XEN_SCRIPTS))
+ rm -f $(addprefix $(DESTDIR)$(XEN_SCRIPT_DIR)/, $(XEN_SCRIPT_DATA))
+
 .PHONY: install-rcd
 install-rcd:
  $(INSTALL_DIR) $(DESTDIR)$(INITD_DIR)
@@ -38,6 +46,11 @@ install-rcd:
  done
  $(INSTALL_DATA) ../common/hotplugpath.sh $(DESTDIR)$(XEN_SCRIPT_DIR)
 
+.PHONY: uninstall-rcd
+uninstall-rcd:
+ rm -f $(addprefix $(DESTDIR)$(INITD_DIR)/, $(XEN_RCD_PROG))
+ rm -f $(DESTDIR)$(XEN_SCRIPT_DIR)/hotplugpath.sh
+
 .PHONY: clean
 clean:
 
diff --git a/tools/hotplug/Linux/Makefile b/tools/hotplug/Linux/Makefile
index 29280cb..d4c3cdc 100644
--- a/tools/hotplug/Linux/Makefile
+++ b/tools/hotplug/Linux/Makefile
@@ -47,6 +47,9 @@ build:
 .PHONY: install
 install: install-initd install-scripts subdirs-install
 
+.PHONY: uninstall
+uninstall: uninstall-initd uninstall-scripts subdirs-uninstall
+
 # See docs/misc/distro_mapping.txt for INITD_DIR location
 .PHONY: install-initd
 install-initd:
@@ -61,6 +64,17 @@ install-initd:
  $(INSTALL_PROG) $(XENDRIVERDOMAIN_INITD) $(DESTDIR)$(INITD_DIR)
  $(INSTALL_PROG) init.d/xen-watchdog $(DESTDIR)$(INITD_DIR)
 
+.PHONY: uninstall-initd
+uninstall-initd:
+ rm -f $(DESTDIR)$(INITD_DIR)/xen-watchdog
+ rm -f $(addprefix $(DESTDIR)$(INITD_DIR)/, $(XENDRIVERDOMAIN_INITD))
+ rm -f $(addprefix $(DESTDIR)$(INITD_DIR)/, $(XENDRIVERDOMAIN_INITD))
+ rm -f $(addprefix $(DESTDIR)$(SYSCONFIG_DIR)/xencommons/, $(XENCOMMONS_SYSCONFIG))
+ rm -f $(addprefix $(DESTDIR)$(INITD_DIR)/, $(XENCOMMONS_INITD))
+ rm -f $(addprefix $(DESTDIR)$(SYSCONFIG_DIR)/xendomains/, $(XENDOMAINS_SYSCONFIG))
+ rm -f $(addprefix $(DESTDIR)$(INITD_DIR)/, $(XENDOMAINS_INITD))
+ rm -f $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/, $(XENDOMAINS_LIBEXEC))
+
 .PHONY: install-scripts
 install-scripts:
  [ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \
@@ -74,6 +88,11 @@ install-scripts:
     $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
  done
 
+.PHONY: uninstall-scripts
+uninstall-scripts:
+ rm -f $(addprefix $(DESTDIR)$(XEN_SCRIPT_DIR)/, $(XEN_SCRIPTS))
+ rm -f $(addprefix $(DESTDIR)$(XEN_SCRIPT_DIR)/, $(XEN_SCRIPT_DATA))
+
 .PHONY: clean
 clean: subdirs-clean
 
diff --git a/tools/hotplug/Linux/systemd/Makefile b/tools/hotplug/Linux/systemd/Makefile
index 7d24bbe..a5d41d8 100644
--- a/tools/hotplug/Linux/systemd/Makefile
+++ b/tools/hotplug/Linux/systemd/Makefile
@@ -38,6 +38,12 @@ install: $(ALL_XEN_SYSTEMD)
  $(INSTALL_DATA) *.mount $(DESTDIR)$(XEN_SYSTEMD_DIR)
  $(INSTALL_DATA) *.conf $(DESTDIR)$(XEN_SYSTEMD_MODULES_LOAD)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(XEN_SYSTEMD_MODULES_LOAD)/*.conf
+ rm -f $(DESTDIR)$(XEN_SYSTEMD_DIR)/*.mount
+ rm -f $(DESTDIR)$(XEN_SYSTEMD_DIR)/*.service
+
 $(XEN_SYSTEMD_MODULES):
  rm -f $@.tmp
  for mod in $(LINUX_BACKEND_MODULES) ; do \
diff --git a/tools/hotplug/Makefile b/tools/hotplug/Makefile
index c1a82c1..4cf6cc0 100644
--- a/tools/hotplug/Makefile
+++ b/tools/hotplug/Makefile
@@ -6,5 +6,5 @@ SUBDIRS-$(CONFIG_NetBSD) += NetBSD
 SUBDIRS-$(CONFIG_Linux) += Linux
 SUBDIRS-$(CONFIG_FreeBSD) += FreeBSD
 
-.PHONY: all clean install distclean
-all clean install distclean: %: subdirs-%
+.PHONY: all clean install distclean uninstall
+all clean install distclean uninstall: %: subdirs-%
diff --git a/tools/hotplug/NetBSD/Makefile b/tools/hotplug/NetBSD/Makefile
index d01aabf..6926885 100644
--- a/tools/hotplug/NetBSD/Makefile
+++ b/tools/hotplug/NetBSD/Makefile
@@ -19,6 +19,9 @@ build:
 .PHONY: install
 install: install-scripts install-rcd
 
+.PHONY: uninstall
+uninstall: uninstall-scripts uninstall-rcd
+
 .PHONY: install-scripts
 install-scripts:
  $(INSTALL_DIR) $(DESTDIR)$(XEN_SCRIPT_DIR)
@@ -31,6 +34,11 @@ install-scripts:
    $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
  done
 
+.PHONY: uninstall-scripts
+uninstall-scripts:
+ rm -f $(addprefix $(DESTDIR)$(XEN_SCRIPT_DIR)/, $(XEN_SCRIPTS))
+ rm -f $(addprefix $(DESTDIR)$(XEN_SCRIPT_DIR)/, $(XEN_SCRIPT_DATA))
+
 .PHONY: install-rcd
 install-rcd:
  $(INSTALL_DIR) $(DESTDIR)$(INITD_DIR)
@@ -40,6 +48,11 @@ install-rcd:
  done
  $(INSTALL_DATA) ../common/hotplugpath.sh $(DESTDIR)$(INITD_DIR)/xen-hotplugpath.sh
 
+.PHONY: uninstall-rcd
+uninstall-rcd:
+ rm -f $(subst rc.d,$(DESTDIR)$(INITD_DIR),$(XEN_RCD_PROG))
+ rm -f $(DESTDIR)$(INITD_DIR)/xen-hotplugpath.sh
+
 .PHONY: clean
 clean:
 
diff --git a/tools/hotplug/common/Makefile b/tools/hotplug/common/Makefile
index b53b55c..ef48bfa 100644
--- a/tools/hotplug/common/Makefile
+++ b/tools/hotplug/common/Makefile
@@ -21,6 +21,9 @@ build: $(HOTPLUGPATH)
 .PHONY: install
 install: install-scripts
 
+.PHONY: uninstall
+uninstall: uninstall-scripts
+
 .PHONY: install-scripts
 install-scripts: build
  [ -d $(DESTDIR)$(XEN_SCRIPT_DIR) ] || \
@@ -34,6 +37,11 @@ install-scripts: build
    $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
  done
 
+.PHONY: uninstall-scripts
+uninstall-scripts:
+ rm -f $(addprefix $(DESTDIR)$(XEN_SCRIPT_DIR)/, $(XEN_SCRIPTS))
+ rm -f $(addprefix $(DESTDIR)$(XEN_SCRIPT_DIR)/, $(XEN_SCRIPT_DATA))
+
 .PHONY: clean
 clean:
  rm -f $(HOTPLUGPATH)
diff --git a/tools/include/Makefile b/tools/include/Makefile
index db0f030..6665105 100644
--- a/tools/include/Makefile
+++ b/tools/include/Makefile
@@ -58,6 +58,11 @@ install: all
  $(INSTALL_DATA) xen/sys/*.h $(DESTDIR)$(includedir)/xen/sys
  $(INSTALL_DATA) xen/xsm/*.h $(DESTDIR)$(includedir)/xen/xsm
 
+.PHONY: uninstall
+uninstall:
+ echo "[FIXME] uninstall headers"
+ rm -rf $(DESTDIR)$(includedir)/xen
+
 .PHONY: clean
 clean:
  rm -rf xen xen-xsm acpi
diff --git a/tools/libfsimage/Makefile b/tools/libfsimage/Makefile
index 69fd18a..da0deca 100644
--- a/tools/libfsimage/Makefile
+++ b/tools/libfsimage/Makefile
@@ -9,8 +9,8 @@ else
     SUBDIRS-y += ext2fs
 endif
 
-.PHONY: all clean install
-all clean install: %: subdirs-%
+.PHONY: all clean install uninstall
+all clean install uninstall: %: subdirs-%
 
 .PHONY: distclean
 distclean: clean
diff --git a/tools/libfsimage/Rules.mk b/tools/libfsimage/Rules.mk
index a0c6504..ee7de44 100644
--- a/tools/libfsimage/Rules.mk
+++ b/tools/libfsimage/Rules.mk
@@ -18,6 +18,13 @@ fs-install: fs-all
  $(INSTALL_DIR) $(DESTDIR)$(FSDIR)/$(FS)
  $(INSTALL_PROG) $(FSLIB) $(DESTDIR)$(FSDIR)/$(FS)
 
+.PHONY: fs-uninstall
+fs-uninstall:
+ rm -f $(addprefix $(DESTDIR)$(FSDIR)/$(FS)/, $(FSLIB))
+ if [ -d $(DESTDIR)$(FSDIR)/$(FS) ]; then \
+ rmdir $(DESTDIR)$(FSDIR)/$(FS); \
+ fi
+
 $(FSLIB): $(PIC_OBJS)
  $(CC) $(LDFLAGS) $(SHLIB_LDFLAGS) -o $@ $^ -lfsimage $(FS_LIBDEPS) $(APPEND_LDFLAGS)
 
diff --git a/tools/libfsimage/common/Makefile b/tools/libfsimage/common/Makefile
index 4840bc2..af6f67e 100644
--- a/tools/libfsimage/common/Makefile
+++ b/tools/libfsimage/common/Makefile
@@ -31,6 +31,15 @@ install: all
  $(INSTALL_DATA) fsimage_plugin.h $(DESTDIR)$(includedir)
  $(INSTALL_DATA) fsimage_grub.h $(DESTDIR)$(includedir)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(includedir)/fsimage_grub.h
+ rm -f $(DESTDIR)$(includedir)/fsimage_plugin.h
+ rm -f $(DESTDIR)$(includedir)/fsimage.h
+ rm -f $(DESTDIR)$(libdir)/libfsimage.so
+ rm -f $(DESTDIR)$(libdir)/libfsimage.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libfsimage.so.$(MAJOR).$(MINOR)
+
 clean distclean::
  rm -f $(LIB)
 
diff --git a/tools/libfsimage/ext2fs-lib/Makefile b/tools/libfsimage/ext2fs-lib/Makefile
index 0e00fde..431a790 100644
--- a/tools/libfsimage/ext2fs-lib/Makefile
+++ b/tools/libfsimage/ext2fs-lib/Makefile
@@ -15,4 +15,7 @@ all: fs-all
 .PHONY: install
 install: fs-install
 
+.PHONY: uninstall
+uninstall: fs-uninstall
+
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
diff --git a/tools/libfsimage/ext2fs/Makefile b/tools/libfsimage/ext2fs/Makefile
index 8ff4c71..c62ae35 100644
--- a/tools/libfsimage/ext2fs/Makefile
+++ b/tools/libfsimage/ext2fs/Makefile
@@ -10,4 +10,7 @@ all: fs-all
 .PHONY: install
 install: fs-install
 
+.PHONY: uninstall
+uninstall: fs-uninstall
+
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
diff --git a/tools/libfsimage/fat/Makefile b/tools/libfsimage/fat/Makefile
index 2911a0e..7ee5e75 100644
--- a/tools/libfsimage/fat/Makefile
+++ b/tools/libfsimage/fat/Makefile
@@ -10,4 +10,7 @@ all: fs-all
 .PHONY: install
 install: fs-install
 
+.PHONY: uninstall
+uninstall: fs-uninstall
+
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
diff --git a/tools/libfsimage/iso9660/Makefile b/tools/libfsimage/iso9660/Makefile
index 4096caf..bc86baf 100644
--- a/tools/libfsimage/iso9660/Makefile
+++ b/tools/libfsimage/iso9660/Makefile
@@ -10,6 +10,9 @@ all: fs-all
 .PHONY: install
 install: fs-install
 
+.PHONY: uninstall
+uninstall: fs-uninstall
+
 fsys_iso9660.c: iso9660.h
 
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
diff --git a/tools/libfsimage/reiserfs/Makefile b/tools/libfsimage/reiserfs/Makefile
index 57f286b..5acfedf 100644
--- a/tools/libfsimage/reiserfs/Makefile
+++ b/tools/libfsimage/reiserfs/Makefile
@@ -10,4 +10,7 @@ all: fs-all
 .PHONY: install
 install: fs-install
 
+.PHONY: uninstall
+uninstall: fs-uninstall
+
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
diff --git a/tools/libfsimage/ufs/Makefile b/tools/libfsimage/ufs/Makefile
index c137108..f32b917 100644
--- a/tools/libfsimage/ufs/Makefile
+++ b/tools/libfsimage/ufs/Makefile
@@ -10,4 +10,7 @@ all: fs-all
 .PHONY: install
 install: fs-install
 
+.PHONY: uninstall
+uninstall: fs-uninstall
+
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
diff --git a/tools/libfsimage/xfs/Makefile b/tools/libfsimage/xfs/Makefile
index 6580007..54eeb6e 100644
--- a/tools/libfsimage/xfs/Makefile
+++ b/tools/libfsimage/xfs/Makefile
@@ -10,4 +10,7 @@ all: fs-all
 .PHONY: install
 install: fs-install
 
+.PHONY: uninstall
+uninstall: fs-uninstall
+
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
diff --git a/tools/libfsimage/zfs/Makefile b/tools/libfsimage/zfs/Makefile
index 4b9f131..084e5ec 100644
--- a/tools/libfsimage/zfs/Makefile
+++ b/tools/libfsimage/zfs/Makefile
@@ -34,4 +34,7 @@ all: fs-all
 .PHONY: install
 install: fs-install
 
+.PHONY: uninstall
+uninstall: fs-uninstall
+
 include $(XEN_ROOT)/tools/libfsimage/Rules.mk
diff --git a/tools/libs/Makefile b/tools/libs/Makefile
index deae4ae..2035873 100644
--- a/tools/libs/Makefile
+++ b/tools/libs/Makefile
@@ -9,4 +9,4 @@ SUBDIRS-y += call
 SUBDIRS-y += foreignmemory
 SUBDIRS-y += devicemodel
 
-all clean install distclean: %: subdirs-%
+all clean install distclean uninstall: %: subdirs-%
diff --git a/tools/libs/call/Makefile b/tools/libs/call/Makefile
index 30f8437..bd3d1f0 100644
--- a/tools/libs/call/Makefile
+++ b/tools/libs/call/Makefile
@@ -75,6 +75,15 @@ install: build
  $(INSTALL_DATA) include/xencall.h $(DESTDIR)$(includedir)
  $(INSTALL_DATA) xencall.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xencall.pc
+ rm -f $(DESTDIR)$(includedir)/xencall.h
+ rm -f $(DESTDIR)$(libdir)/libxencall.so
+ rm -f $(DESTDIR)$(libdir)/libxencall.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxencall.so.$(MAJOR).$(MINOR)
+ rm -f $(DESTDIR)$(libdir)/libxencall.a
+
 .PHONY: TAGS
 TAGS:
  etags -t *.c *.h
diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile
index 81fa5a4..e41fd20 100644
--- a/tools/libs/devicemodel/Makefile
+++ b/tools/libs/devicemodel/Makefile
@@ -76,6 +76,15 @@ install: build
  $(INSTALL_DATA) include/xendevicemodel.h $(DESTDIR)$(includedir)
  $(INSTALL_DATA) xendevicemodel.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xendevicemodel.pc
+ rm -f $(DESTDIR)$(includedir)/xendevicemodel.h
+ rm -f $(DESTDIR)$(libdir)/libxendevicemodel.so
+ rm -f $(DESTDIR)$(libdir)/libxendevicemodel.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxendevicemodel.so.$(MAJOR).$(MINOR)
+ rm -f $(DESTDIR)$(libdir)/libxendevicemodel.a
+
 .PHONY: TAGS
 TAGS:
  etags -t *.c *.h
diff --git a/tools/libs/evtchn/Makefile b/tools/libs/evtchn/Makefile
index cbd4219..c9537ff 100644
--- a/tools/libs/evtchn/Makefile
+++ b/tools/libs/evtchn/Makefile
@@ -74,6 +74,15 @@ install: build
  $(INSTALL_DATA) include/xenevtchn.h $(DESTDIR)$(includedir)
  $(INSTALL_DATA) xenevtchn.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenevtchn.pc
+ rm -f $(DESTDIR)$(includedir)/xenevtchn.h
+ rm -f $(DESTDIR)$(libdir)/libxenevtchn.so
+ rm -f $(DESTDIR)$(libdir)/libxenevtchn.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxenevtchn.so.$(MAJOR).$(MINOR)
+ rm -f $(DESTDIR)$(libdir)/libxenevtchn.a
+
 .PHONY: TAGS
 TAGS:
  etags -t *.c *.h
diff --git a/tools/libs/foreignmemory/Makefile b/tools/libs/foreignmemory/Makefile
index 5e93ee7..b110076 100644
--- a/tools/libs/foreignmemory/Makefile
+++ b/tools/libs/foreignmemory/Makefile
@@ -75,6 +75,15 @@ install: build
  $(INSTALL_DATA) include/xenforeignmemory.h $(DESTDIR)$(includedir)
  $(INSTALL_DATA) xenforeignmemory.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenforeignmemory.pc
+ rm -f $(DESTDIR)$(includedir)/xenforeignmemory.h
+ rm -f $(DESTDIR)$(libdir)/libxenforeignmemory.so
+ rm -f $(DESTDIR)$(libdir)/libxenforeignmemory.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxenforeignmemory.so.$(MAJOR).$(MINOR)
+ rm -f $(DESTDIR)$(libdir)/libxenforeignmemory.a
+
 .PHONY: TAGS
 TAGS:
  etags -t *.c *.h
diff --git a/tools/libs/gnttab/Makefile b/tools/libs/gnttab/Makefile
index 88b3683..3363bd5 100644
--- a/tools/libs/gnttab/Makefile
+++ b/tools/libs/gnttab/Makefile
@@ -77,6 +77,15 @@ install: build
  $(INSTALL_DATA) include/xengnttab.h $(DESTDIR)$(includedir)
  $(INSTALL_DATA) xengnttab.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xengnttab.pc
+ rm -f $(DESTDIR)$(includedir)/xengnttab.h
+ rm -f $(DESTDIR)$(libdir)/libxengnttab.so
+ rm -f $(DESTDIR)$(libdir)/libxengnttab.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxengnttab.so.$(MAJOR).$(MINOR)
+ rm -f $(DESTDIR)$(libdir)/libxengnttab.a
+
 .PHONY: TAGS
 TAGS:
  etags -t *.c *.h
diff --git a/tools/libs/toollog/Makefile b/tools/libs/toollog/Makefile
index 7361194..01619ec 100644
--- a/tools/libs/toollog/Makefile
+++ b/tools/libs/toollog/Makefile
@@ -69,6 +69,15 @@ install: build
  $(INSTALL_DATA) include/xentoollog.h $(DESTDIR)$(includedir)
  $(INSTALL_DATA) xentoollog.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
+.PHONY: uinstall
+uninstall:
+ rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xentoollog.pc
+ rm -f $(DESTDIR)$(includedir)/xentoollog.h
+ rm -f $(DESTDIR)$(libdir)/libxentoollog.so
+ rm -f $(DESTDIR)$(libdir)/libxentoollog.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxentoollog.so.$(MAJOR).$(MINOR)
+ rm -f $(DESTDIR)$(libdir)/libxentoollog.a
+
 .PHONY: TAGS
 TAGS:
  etags -t *.c *.h
diff --git a/tools/libvchan/Makefile b/tools/libvchan/Makefile
index 70c92bd..277c1c0 100644
--- a/tools/libvchan/Makefile
+++ b/tools/libvchan/Makefile
@@ -70,6 +70,15 @@ install: all
  $(INSTALL_DATA) libxenvchan.a $(DESTDIR)$(libdir)
  $(INSTALL_DATA) xenvchan.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenvchan.pc
+ rm -f $(DESTDIR)$(libdir)/libxenvchan.a
+ rm -f $(DESTDIR)$(includedir)/libxenvchan.h
+ rm -f $(DESTDIR)$(libdir)/libxenvchan.so
+ rm -f $(DESTDIR)$(libdir)/libxenvchan.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxenvchan.so.$(MAJOR).$(MINOR)
+
 .PHONY: clean
 clean:
  $(RM) -f *.o *.opic *.so* *.a vchan-node1 vchan-node2 $(DEPS)
diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index 28b1857..83e3416 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -203,6 +203,22 @@ install: build
  $(INSTALL_DATA) xencontrol.pc $(DESTDIR)$(PKG_INSTALLDIR)
  $(INSTALL_DATA) xenguest.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenguest.pc
+ rm -f $(DESTDIR)$(includedir)/xenguest.h
+ rm -f $(DESTDIR)$(libdir)/libxenguest.so
+ rm -f $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR).$(MINOR)
+ rm -f $(DESTDIR)$(libdir)/libxenguest.a
+ rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xencontrol.pc
+ rm -f $(DESTDIR)$(includedir)/xenctrl.h
+ rm -f $(DESTDIR)$(includedir)/xenctrl_compat.h
+ rm -f $(DESTDIR)$(libdir)/libxenctrl.so
+ rm -f $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR).$(MINOR)
+ rm -f $(DESTDIR)$(libdir)/libxenctrl.a
+
 .PHONY: TAGS
 TAGS:
  etags -t *.c *.h
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 2ffb78f..082af8f 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -327,6 +327,20 @@ install: all
  $(INSTALL_DATA) xenlight.pc $(DESTDIR)$(PKG_INSTALLDIR)
  $(INSTALL_DATA) xlutil.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(addprefix $(DESTDIR)$(PKG_INSTALLDIR)/,xlutil.pc xenlight.pc)
+ rm -f $(addprefix $(DESTDIR)$(includedir)/,libxl.h libxl_event.h libxl_json.h _libxl_types.h _libxl_types_json.h _libxl_list.h libxl_utils.h libxl_uuid.h libxlutil.h)
+ rm -f $(DESTDIR)$(libdir)/libxlutil.a
+ rm -f $(DESTDIR)$(libdir)/libxlutil.so
+ rm -f $(DESTDIR)$(libdir)/libxlutil.so.$(XLUMAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxlutil.so.$(XLUMAJOR).$(XLUMINOR)
+ rm -f $(DESTDIR)$(libdir)/libxenlight.a
+ rm -f $(DESTDIR)$(libdir)/libxenlight.so
+ rm -f $(DESTDIR)$(libdir)/libxenlight.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxenlight.so.$(MAJOR).$(MINOR)
+ rm -f $(DESTDIR)$(LIBEXEC_BIN)/libxl-save-helper
+
 .PHONY: clean
 clean:
  $(RM) -f _*.h *.o *.so* *.a $(CLIENTS) $(DEPS)
diff --git a/tools/memshr/Makefile b/tools/memshr/Makefile
index ce86f20..cb5ea61 100644
--- a/tools/memshr/Makefile
+++ b/tools/memshr/Makefile
@@ -36,12 +36,14 @@ libmemshr.a: $(LIB-OBJS)
 
 install: all
 
+uninstall:
+
 clean:
  rm -rf *.a *.o *~ $(DEPS)
 
 .PHONY: distclean
 distclean: clean
 
-.PHONY: all build clean install distclean
+.PHONY: all build clean install distclean uninstall
 
 -include $(DEPS)
diff --git a/tools/misc/Makefile b/tools/misc/Makefile
index c1113b9..54f6e2e 100644
--- a/tools/misc/Makefile
+++ b/tools/misc/Makefile
@@ -62,6 +62,12 @@ install: build
  $(INSTALL_PYTHON_PROG) $(INSTALL_SBIN) $(DESTDIR)$(sbindir)
  $(INSTALL_PYTHON_PROG) $(INSTALL_PRIVBIN) $(DESTDIR)$(LIBEXEC_BIN)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/, $(INSTALL_PRIVBIN))
+ rm -f $(addprefix $(DESTDIR)$(sbindir)/, $(INSTALL_SBIN))
+ rm -f $(addprefix $(DESTDIR)$(bindir)/, $(INSTALL_BIN))
+
 .PHONY: clean
 clean:
  $(RM) *.o $(TARGETS_BUILD) *~ $(DEPS)
diff --git a/tools/ocaml/Makefile b/tools/ocaml/Makefile
index cfa931a..66f2d6b 100644
--- a/tools/ocaml/Makefile
+++ b/tools/ocaml/Makefile
@@ -18,6 +18,9 @@ all: subdirs-all
 .PHONY: install
 install: subdirs-install
 
+.PHONY: uninstall
+uninstall: subdirs-uninstall
+
 .PHONY: clean
 clean: subdirs-clean
 
diff --git a/tools/ocaml/libs/Makefile b/tools/ocaml/libs/Makefile
index f7c3c0e..7e7c27e 100644
--- a/tools/ocaml/libs/Makefile
+++ b/tools/ocaml/libs/Makefile
@@ -13,6 +13,9 @@ all: subdirs-all
 .PHONY: install
 install: subdirs-install
 
+.PHONY: uninstall
+uninstall: subdirs-uninstall
+
 .PHONY: clean
 clean: subdirs-clean
 
diff --git a/tools/ocaml/test/Makefile b/tools/ocaml/test/Makefile
index 30a304b..256c830 100644
--- a/tools/ocaml/test/Makefile
+++ b/tools/ocaml/test/Makefile
@@ -50,4 +50,6 @@ bins: $(PROGRAMS)
 
 install:
 
+uninstall:
+
 include $(OCAML_TOPLEVEL)/Makefile.rules
diff --git a/tools/ocaml/xenstored/Makefile b/tools/ocaml/xenstored/Makefile
index d238836..68d35c4 100644
--- a/tools/ocaml/xenstored/Makefile
+++ b/tools/ocaml/xenstored/Makefile
@@ -90,6 +90,10 @@ install: all
  $(INSTALL_DIR) $(DESTDIR)$(XEN_CONFIG_DIR)
  $(INSTALL_DATA) oxenstored.conf $(DESTDIR)$(XEN_CONFIG_DIR)
 
+uninstall:
+ rm -f $(DESTDIR)$(XEN_CONFIG_DIR)/oxenstored.conf
+ rm -f $(DESTDIR)$(sbindir)/oxenstored
+
 include $(OCAML_TOPLEVEL)/Makefile.rules
 
 genpath-target = $(call buildmakevars2module,paths.ml)
diff --git a/tools/pygrub/Makefile b/tools/pygrub/Makefile
index a318490..3a6074b 100644
--- a/tools/pygrub/Makefile
+++ b/tools/pygrub/Makefile
@@ -4,6 +4,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 PY_CFLAGS = $(CFLAGS) $(PY_NOOPT_CFLAGS)
 PY_LDFLAGS = $(LDFLAGS) $(APPEND_LDFLAGS)
+INSTALL_LOG = build/installed_files.txt
 
 .PHONY: all
 all: build
@@ -13,18 +14,26 @@ build:
 
 .PHONY: install
 install: all
+ $(INSTALL_DIR) $(DESTDIR)/$(bindir)
  CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) \
- setup.py install $(PYTHON_PREFIX_ARG) --root="$(DESTDIR)"  \
- --install-scripts=$(LIBEXEC_BIN) --force
+ setup.py install --record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
+ --root="$(DESTDIR)" --install-scripts=$(LIBEXEC_BIN) --force
  set -e; if [ $(bindir) != $(LIBEXEC_BIN) -a \
              "`readlink -f $(DESTDIR)/$(bindir)`" != \
              "`readlink -f $(LIBEXEC_BIN)`" ]; then \
     ln -sf $(LIBEXEC_BIN)/pygrub $(DESTDIR)/$(bindir); \
  fi
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)/$(bindir)/pygrub
+ if [ -e $(INSTALL_LOG) ]; then \
+ cat $(INSTALL_LOG) | xargs -i rm -f $(DESTDIR)/{}; \
+ fi
+
 .PHONY: clean
 clean:
- rm -rf build tmp *.pyc *.pyo *.o *.a *~ a.out $(DEPS)
+ rm -rf build tmp *.pyc *.pyo *.o *.a *~ a.out $(INSTALL_LOG) $(DEPS)
 
 .PHONY: distclean
 distclean: clean
diff --git a/tools/python/Makefile b/tools/python/Makefile
index da08f46..e7a3c51 100644
--- a/tools/python/Makefile
+++ b/tools/python/Makefile
@@ -6,6 +6,7 @@ all: build
 
 PY_CFLAGS = $(CFLAGS) $(PY_NOOPT_CFLAGS)
 PY_LDFLAGS = $(LDFLAGS) $(APPEND_LDFLAGS)
+INSTALL_LOG = build/installed_files.txt
 
 .PHONY: build
 build:
@@ -16,12 +17,20 @@ install:
  $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
 
  CC="$(CC)" CFLAGS="$(PY_CFLAGS)" LDFLAGS="$(PY_LDFLAGS)" $(PYTHON) \
- setup.py install $(PYTHON_PREFIX_ARG) --root="$(DESTDIR)"  \
- --force
+ setup.py install --record $(INSTALL_LOG) $(PYTHON_PREFIX_ARG) \
+ --root="$(DESTDIR)" --force
 
  $(INSTALL_PROG) scripts/convert-legacy-stream $(DESTDIR)$(LIBEXEC_BIN)
  $(INSTALL_PROG) scripts/verify-stream-v2 $(DESTDIR)$(LIBEXEC_BIN)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(LIBEXEC_BIN)/verify-stream-v2
+ rm -f $(DESTDIR)$(LIBEXEC_BIN)/convert-legacy-stream
+ if [ -e $(INSTALL_LOG) ]; then \
+ cat $(INSTALL_LOG) | xargs -i rm -f $(DESTDIR)/{}; \
+ fi
+
 .PHONY: test
 test:
  export LD_LIBRARY_PATH=$$(readlink -f ../libxc):$$(readlink -f ../xenstore); $(PYTHON) test.py -b -u
diff --git a/tools/tests/Makefile b/tools/tests/Makefile
index 6397761..7162945 100644
--- a/tools/tests/Makefile
+++ b/tools/tests/Makefile
@@ -14,7 +14,9 @@ SUBDIRS-$(CONFIG_X86) += x86_emulator
 SUBDIRS-y += xen-access
 SUBDIRS-y += xenstore
 
-.PHONY: all clean install distclean
+.PHONY: all clean install distclean uninstall
 all clean distclean: %: subdirs-%
 
 install:
+
+uninstall:
diff --git a/tools/xcutils/Makefile b/tools/xcutils/Makefile
index e127af8..6bc9062 100644
--- a/tools/xcutils/Makefile
+++ b/tools/xcutils/Makefile
@@ -36,6 +36,9 @@ install: build
  $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
  $(INSTALL_PROG) $(PROGRAMS) $(DESTDIR)$(LIBEXEC_BIN)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(addprefix $(DESTDIR)$(LIBEXECDIR)/, $(PROGRAMS))
 
 .PHONY: clean
 clean:
diff --git a/tools/xenmon/Makefile b/tools/xenmon/Makefile
index 98056f2..537c176 100644
--- a/tools/xenmon/Makefile
+++ b/tools/xenmon/Makefile
@@ -34,6 +34,12 @@ install: build
  $(INSTALL_PROG) xentrace_setmask  $(DESTDIR)$(sbindir)/xentrace_setmask
  $(INSTALL_PROG) xenmon.py  $(DESTDIR)$(sbindir)/xenmon.py
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(sbindir)/xenbaked
+ rm -f $(DESTDIR)$(sbindir)/xentrace_setmask
+ rm -f $(DESTDIR)$(sbindir)/xenmon.py
+
 .PHONY: clean
 clean:
  $(RM) -f $(DEPS)
diff --git a/tools/xenpaging/Makefile b/tools/xenpaging/Makefile
index 64876b3..ba083ca 100644
--- a/tools/xenpaging/Makefile
+++ b/tools/xenpaging/Makefile
@@ -28,12 +28,15 @@ install: all
  $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
  $(INSTALL_PROG) $(IBINS) $(DESTDIR)$(LIBEXEC_BIN)
 
+uninstall:
+ rm -f $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/, $(IBINS))
+
 clean:
  rm -f *.o *~ $(DEPS) xen TAGS $(IBINS) $(LIB)
 
 distclean: clean
 
-.PHONY: clean install distclean
+.PHONY: clean install distclean uninstall
 
 .PHONY: TAGS
 TAGS:
diff --git a/tools/xenpmd/Makefile b/tools/xenpmd/Makefile
index 55e8fc5..e0d0697 100644
--- a/tools/xenpmd/Makefile
+++ b/tools/xenpmd/Makefile
@@ -21,6 +21,10 @@ clean:
 .PHONY: distclean
 distclean: clean
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(sbindir)/xenpmd
+
 xenpmd: xenpmd.o Makefile
  $(CC) $(LDFLAGS) $< -o $@ $(LDLIBS) $(APPEND_LDFLAGS)
 
diff --git a/tools/xenstat/Makefile b/tools/xenstat/Makefile
index 90d033a..b300f31 100644
--- a/tools/xenstat/Makefile
+++ b/tools/xenstat/Makefile
@@ -5,6 +5,6 @@ SUBDIRS :=
 SUBDIRS += libxenstat
 SUBDIRS += xentop
 
-.PHONY: all install clean distclean
+.PHONY: all install clean distclean uninstall
 
-all install clean distclean: %: subdirs-%
+all install clean distclean uninstall: %: subdirs-%
diff --git a/tools/xenstat/libxenstat/Makefile b/tools/xenstat/libxenstat/Makefile
index 9d6649d..4b94d81 100644
--- a/tools/xenstat/libxenstat/Makefile
+++ b/tools/xenstat/libxenstat/Makefile
@@ -81,6 +81,15 @@ install: all
  ln -sf libxenstat.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenstat.so
  $(INSTALL_DATA) xenstat.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenstat.pc
+ rm -f $(DESTDIR)$(libdir)/libxenstat.so
+ rm -f $(DESTDIR)$(libdir)/libxenstat.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxenstat.so.$(MAJOR).$(MINOR)
+ rm -f $(DESTDIR)$(libdir)/libxenstat.a
+ rm -f $(DESTDIR)$(includedir)/xenstat.h
+
 PYLIB=bindings/swig/python/_xenstat.so
 PYMOD=bindings/swig/python/xenstat.py
 PYSRC=bindings/swig/python/_xenstat.c
@@ -97,6 +106,9 @@ all-bindings: perl-bindings python-bindings
 # The install-bindings target installs all the language bindings
 install-bindings: install-perl-bindings install-python-bindings
 
+.PHONY: uninstall-bindings
+uninstall-bindings: uninstall-perl-bindings uninstall-python-bindings
+
 $(BINDINGS): $(SHLIB) $(SHLIB_LINKS) src/xenstat.h
 
 SWIG_FLAGS=-module xenstat -Isrc
@@ -118,10 +130,16 @@ install-python-bindings: $(PYLIB) $(PYMOD)
  $(INSTALL_PROG) $(PYLIB) $(DESTDIR)$(pythonlibdir)/_xenstat.so
  $(INSTALL_PROG) $(PYMOD) $(DESTDIR)$(pythonlibdir)/xenstat.py
 
+.PHONY: uninstall-python-bindings
+uninstall-python-bindings:
+ rm -f $(DESTDIR)$(pythonlibdir)/_xenstat.so
+ rm -f $(DESTDIR)$(pythonlibdir)/xenstat.py
+
 ifeq ($(XENSTAT_PYTHON_BINDINGS),y)
 .PHONY: all
 all: python-bindings
 install: install-python-bindings
+uninstall: uninstall-python-bindings
 endif
 
 # Perl bindings
@@ -143,12 +161,18 @@ install-perl-bindings: $(PERLLIB) $(PERLMOD)
  $(INSTALL_PROG) $(PERLLIB) $(DESTDIR)$(perllibdir)/xenstat.so
  $(INSTALL_PROG) $(PERLMOD) $(DESTDIR)$(perlmoddir)/xenstat.pm
 
+.PHONY: uninstall-perl-bindings
+uninstall-perl-bindings:
+ rm -f $(DESTDIR)$(perllibdir)/xenstat.so
+ rm -f $(DESTDIR)$(perlmoddir)/xenstat.pm
+
 ifeq ($(XENSTAT_PERL_BINDINGS),y)
 .PHONY: all
 all: perl-bindings
 
 .PHONY: install
 install: install-perl-bindings
+uninstall: uninstall-perl-bindings
 endif
 
 .PHONY: clean
diff --git a/tools/xenstat/xentop/Makefile b/tools/xenstat/xentop/Makefile
index 2275ccd..2e156f1 100644
--- a/tools/xenstat/xentop/Makefile
+++ b/tools/xenstat/xentop/Makefile
@@ -14,8 +14,8 @@ XEN_ROOT=$(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 ifneq ($(XENSTAT_XENTOP),y)
-.PHONY: all install xentop
-all install xentop:
+.PHONY: all install xentop uninstall
+all install xentop uninstall:
 else
 
 CFLAGS += -DGCC_PRINTF -Werror $(CFLAGS_libxenstat)
@@ -34,6 +34,10 @@ install: xentop
  $(INSTALL_DIR) $(DESTDIR)$(sbindir)
  $(INSTALL_PROG) xentop $(DESTDIR)$(sbindir)/xentop
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(sbindir)/xentop
+
 endif
 
 .PHONY: clean
diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
index 773d646..108c942 100644
--- a/tools/xenstore/Makefile
+++ b/tools/xenstore/Makefile
@@ -173,6 +173,36 @@ endif
  ln -sf xenstore-compat/xs_lib.h $(DESTDIR)$(includedir)/xs_lib.h
  $(INSTALL_DATA) xenstore.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenstore.pc
+ rm -f $(DESTDIR)$(includedir)/xs_lib.h
+ rm -f $(DESTDIR)$(includedir)/xs.h
+ rm -f $(DESTDIR)$(includedir)/xenstore-compat/xs_lib.h
+ rm -f $(DESTDIR)$(includedir)/xenstore-compat/xs.h
+ rm -f $(DESTDIR)$(includedir)/xenstore_lib.h
+ rm -f $(DESTDIR)$(includedir)/xenstore.h
+ rm -f $(DESTDIR)$(libdir)/libxenstore.a
+ rm -f $(DESTDIR)$(libdir)/libxenstore.so
+ rm -f $(DESTDIR)$(libdir)/libxenstore.so.$(MAJOR)
+ rm -f $(DESTDIR)$(libdir)/libxenstore.so.$(MAJOR).$(MINOR)
+ rm -f $(addprefix $(DESTDIR)$(bindir)/, $(CLIENTS))
+ rm -f $(DESTDIR)$(bindir)/xenstore
+ rm -f $(DESTDIR)$(bindir)/xenstore-control
+ifeq ($(XENSTORE_XENSTORED),y)
+ rm -f $(DESTDIR)$(sbindir)/xenstored
+ if [ -d $(DESTDIR)$(XEN_LIB_STORED) ]; then \
+ rmdir --ignore-fail-on-non-empty $(DESTDIR)$(XEN_LIB_STORED); \
+ fi
+endif
+ if [ -d $(DESTDIR)$(includedir)/xenstore-compat ]; then \
+ rmdir --ignore-fail-on-non-empty $(DESTDIR)$(includedir)/xenstore-compat; \
+ fi
+
+.PHONY: clients-uninstall
+clients-uninstall:
+ rm -f $(addprefix $(DESTDIR)$(bindir)/, $(CLIENTS))
+
 .PHONY: clients-install
 clients-install: clients
  $(INSTALL_DIR) $(DESTDIR)$(bindir)
diff --git a/tools/xentrace/Makefile b/tools/xentrace/Makefile
index c8c36a8..bcd8f5b 100644
--- a/tools/xentrace/Makefile
+++ b/tools/xentrace/Makefile
@@ -33,6 +33,15 @@ endif
  $(INSTALL_PYTHON_PROG) $(SCRIPTS) $(DESTDIR)$(bindir)
  [ -z "$(LIBBIN)" ] || $(INSTALL_PROG) $(LIBBIN) $(DESTDIR)$(LIBEXEC_BIN)
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/, $(LIBBIN))
+ rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS))
+ rm -f $(addprefix $(DESTDIR)$(sbindir)/, $(SBIN))
+ifneq ($(BIN),)
+ rm -f $(addprefix $(DESTDIR)$(bindir)/, $(BIN))
+endif
+
 .PHONY: clean
 clean:
  $(RM) *.a *.so *.o *.rpm $(BIN) $(SBIN) $(LIBBIN) $(DEPS)
diff --git a/tools/xl/Makefile b/tools/xl/Makefile
index e16f877..c868899 100644
--- a/tools/xl/Makefile
+++ b/tools/xl/Makefile
@@ -44,6 +44,11 @@ install: all
  $(INSTALL_PROG) xl $(DESTDIR)$(sbindir)
  $(INSTALL_DATA) bash-completion $(DESTDIR)$(BASH_COMPLETION_DIR)/xl.sh
 
+.PHONY: uninstall
+uninstall:
+ rm -f $(DESTDIR)$(BASH_COMPLETION_DIR)/xl.sh
+ rm -f $(DESTDIR)$(sbindir)/xl
+
 .PHONY: clean
 clean:
  $(RM) -f *.o xl _paths.h $(DEPS)
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog
Loading...