diff options
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)$*/ |