diff options
author | 2013-04-14 01:03:11 +0200 | |
---|---|---|
committer | 2013-04-14 01:03:11 +0200 | |
commit | d8aa1d0ed1cc726ea3d7cd6a39e0f57379d2142d (patch) | |
tree | 969fbf2d6ae4172240b41b59fc63f5c068fb5e21 /dotfiles.mk | |
parent | 9ab70194a65f1d7ab726aaacdb43a58a02a048b6 (diff) | |
download | dotfiles-d8aa1d0ed1cc726ea3d7cd6a39e0f57379d2142d.tar.gz dotfiles-d8aa1d0ed1cc726ea3d7cd6a39e0f57379d2142d.zip |
Have the install command uninstall first
The new uninstall functionality tries to remove any "orphan" files.
Files that were installed during the last install, but will not be
installed this time (because of removal, not necessity).
Diffstat (limited to 'dotfiles.mk')
-rw-r--r-- | dotfiles.mk | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/dotfiles.mk b/dotfiles.mk index 892c5b5..b7bd5c6 100644 --- a/dotfiles.mk +++ b/dotfiles.mk @@ -34,9 +34,23 @@ all: $(modules) $(objects) ifeq ($(MAKEROOT),y) check: $(check-modules) $(check-objects) -install: $(install-modules) $(install-objects) +install: uninstall $(install-modules) $(install-objects) Makefile.old reverse: $(reverse-modules) $(reverse-objects) +ifeq ($(firstword $(MAKEFILE_LIST)),Makefile.old) uninstall: $(uninstall-modules) $(uninstall-objects) + @rmdir --ignore-fail-on-non-empty $(DESTDIR) 2> /dev/null || true +else +uninstall: export NEWLIST = $(objects) +uninstall: + @$(MAKE) -s -f Makefile.old uninstall + +Makefile.old: $(firstword $(MAKEFILE_LIST)) + @cp "$^" "$@" + +ifdef SUBDIR +DESTDIR:=$(DESTDIR)/$(SUBDIR) +endif +endif else check: @$(MAKE) -s -C ../ check @@ -71,10 +85,11 @@ $(reverse-modules): reverse-%: @$(MAKE) -s -C $* reverse MKDPREFIX=$(MKDPREFIX)$*/ $(uninstall-objects): uninstall-%: - @$(if $(call older,$*), \ - echo -e "$(FG_RED)+ $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \ - echo -e "$(FG_GRE)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"; \ - rm -f "$(DESTDIR)/$*") + @$(if $(findstring $*,$(NEWLIST)),, \ + @$(if $(call older,$*), \ + echo -e "$(FG_RED)+ $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \ + echo -e "$(FG_GRE)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"; \ + unlink "$(DESTDIR)/$*" || true)) $(uninstall-modules): uninstall-%: @$(MAKE) -C $* uninstall MKDPREFIX=$(MKDPREFIX)$*/ |