@@ -292,6 +292,32 @@ clean: clean_plugins clean_src
$(RM) $(OUTPUT)*.o $(OUTPUT)*~ $(TARGETS) $(OUTPUT)*.a $(OUTPUT)*.so $(VERSION_FILES) $(OUTPUT).*.d $(OUTPUT).*.cmd; \
$(RM) TRACEEVENT-CFLAGS $(OUTPUT)tags $(OUTPUT)TAGS; \
$(RM) $(PKG_CONFIG_FILE)
+ifneq ($(OUTPUT),)
+else
+BUILD_OUTPUT := $(shell pwd)
+endif
+
+define build_uninstall_script
+ $(Q)mkdir $(BUILD_OUTPUT)/tmp_build
+ $(Q)$(MAKE) -C $(srctree) DESTDIR=$(BUILD_OUTPUT)/tmp_build/ O=$(BUILD_OUTPUT) $1 > /dev/null
+ $(Q)find $(BUILD_OUTPUT)/tmp_build ! -type d -printf "%P\n" > $(BUILD_OUTPUT)/build_$2
+ $(Q)$(RM) -rf $(BUILD_OUTPUT)/tmp_build
+endef
+
+build_uninstall:
+ $(call build_uninstall_script,install,uninstall)
+
+$(BUILD_OUTPUT)/build_uninstall: build_uninstall
+
+define uninstall_file
+ if [ -f $(DESTDIR)/$1 -o -h $(DESTDIR)/$1 ]; then \
+ $(call PRINT_UNINST,$(DESTDIR)$1)$(RM) $(DESTDIR)/$1; \
+ fi;
+endef
+
+uninstall: $(BUILD_OUTPUT)/build_uninstall
+ @$(foreach file,$(shell cat $(BUILD_OUTPUT)/build_uninstall),$(call uninstall_file,$(file)))
+ $(Q)$(RM) $<
PHONY += doc
doc:
@@ -124,6 +124,7 @@ ifneq ($(silent),1)
$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
PRINT_INSTALL = printf ' INSTALL %s\n' $1;
+ PRINT_UNINST = printf ' UNINST %s\n' $1;
QUIET_CLEAN = @printf ' CLEAN %s\n' $1;
QUIET_INSTALL = @printf ' INSTALL %s\n' $1;
QUIET_UNINST = @printf ' UNINST %s\n' $1;