Commits

Anonymous committed 042f53c

git-gui: Provide 'uninstall' Makefile target to undo an installation

Several users have requested a "make uninstall" target be provided
in the stock git-gui Makefile so that they can undo an install
if git-gui goes to the wrong place during the initial install,
or if they are unhappy with the tool and want to remove it from
their system.

We currently assume that the complete set of files we need to delete
are those defined by our Makefile and current source directory.
This could differ from what the user actually has installed if they
installed one version then attempt to use another to perform the
uninstall. Right now I'm just going to say that is "pilot error".
Users should uninstall git-gui using the same version of source
that they used to make the installation. Perhaps in the future we
could read tclIndex and base our uninstall decisions on its contents.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

  • Participants
  • Parent commits afe2098

Comments (0)

Files changed (1)

 	INSTALL = install
 endif
 
+RM_F      ?= rm -f
+RMDIR     ?= rmdir
+
 INSTALL_D0 = $(INSTALL) -d -m755 # space is required here
 INSTALL_D1 =
 INSTALL_R0 = $(INSTALL) -m644 # space is required here
 INSTALL_L2 =
 INSTALL_L3 =
 
+REMOVE_D0  = $(RMDIR) # space is required here
+REMOVE_D1  = || true
+REMOVE_F0  = $(RM_F) # space is required here
+REMOVE_F1  =
+CLEAN_DST  = true
+
 ifndef V
 	QUIET          = @
 	QUIET_GEN      = $(QUIET)echo '   ' GEN $@ &&
 	INSTALL_L1 = && src=
 	INSTALL_L2 = && dst=
 	INSTALL_L3 = && echo '   ' 'LINK       ' `basename "$$dst"` '->' `basename "$$src"` && rm -f "$$dst" && ln "$$src" "$$dst"
+
+	CLEAN_DST = echo ' ' UNINSTALL
+	REMOVE_D0 = dir=
+	REMOVE_D1 = && echo ' ' REMOVE $$dir && test -d "$$dir" && $(RMDIR) "$$dir" || true
+	REMOVE_F0 = dst=
+	REMOVE_F1 = && echo '   ' REMOVE `basename "$$dst"` && $(RM_F) "$$dst"
 endif
 
 TCL_PATH   ?= tclsh
 	$(QUIET)$(INSTALL_R0)lib/tclIndex $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)'
 	$(QUIET)$(foreach p,$(ALL_LIBFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' &&) true
 
+uninstall:
+	$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
+	$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
+	$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
+	$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(libdir_SQ)'
+	$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/tclIndex $(REMOVE_F1)
+	$(QUIET)$(foreach p,$(ALL_LIBFILES), $(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/$(notdir $p) $(REMOVE_F1) &&) true
+	$(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(REMOVE_D1)
+	$(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(REMOVE_D1)
+	$(QUIET)$(REMOVE_D0)`dirname '$(DESTDIR_SQ)$(libdir_SQ)'` $(REMOVE_D1)
+
 dist-version:
 	@mkdir -p $(TARDIR)
 	@echo $(GITGUI_VERSION) > $(TARDIR)/version
 	rm -f $(ALL_PROGRAMS) lib/tclIndex
 	rm -f GIT-VERSION-FILE GIT-GUI-VARS
 
-.PHONY: all install dist-version clean
+.PHONY: all install uninstall dist-version clean
 .PHONY: .FORCE-GIT-VERSION-FILE
 .PHONY: .FORCE-GIT-GUI-VARS