summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dotfiles.mk27
1 files changed, 23 insertions, 4 deletions
diff --git a/dotfiles.mk b/dotfiles.mk
index 8ca45fc..0a51b92 100644
--- a/dotfiles.mk
+++ b/dotfiles.mk
@@ -20,27 +20,33 @@ check-objects=$(addprefix check-,$(objects))
install-objects=$(addprefix install-,$(objects))
reverse-objects=$(addprefix reverse-,$(objects))
cleanup-objects=$(addprefix cleanup-,$(objects))
+uninstall-objects=$(addprefix uninstall-,$(objects))
check-modules=$(addprefix check-,$(modules))
install-modules=$(addprefix install-,$(modules))
reverse-modules=$(addprefix reverse-,$(modules))
cleanup-modules=$(addprefix cleanup-,$(modules))
+uninstall-modules=$(addprefix uninstall-,$(modules))
.PHONY: all install cleanup check cleanup $(modules) \
$(install-objects) $(cleanup-objects) $(check-objects) \
$(install-modules) $(cleanup-modules) $(check-modules) \
- $(reverse) $(reverse-objects) $(reverse-modules)
+ $(reverse) $(reverse-objects) $(reverse-modules) \
+ $(uninstall-objects) $(uninstall-modules)
all: $(modules) $(objects)
ifeq ($(MAKEROOT),y)
check: $(check-modules) $(check-objects)
install: cleanup $(install-modules) $(install-objects) Makefile.old
reverse: $(reverse-modules) $(reverse-objects)
+uninstall: $(uninstall-modules) $(uninstall-objects)
+ @rmdir --ignore-fail-on-non-empty $(DESTDIR) 2> /dev/null || true
ifeq ($(firstword $(MAKEFILE_LIST)),Makefile.old)
cleanup: $(cleanup-modules) $(cleanup-objects)
@rmdir --ignore-fail-on-non-empty $(DESTDIR) 2> /dev/null || true
else
-cleanup: export NEWLIST = $(objects)
+cleanup: export NEWOBJS = $(objects)
+cleanup: export NEWMODS = $(modules)
cleanup:
@$(MAKE) -s -f Makefile.old cleanup
@@ -60,6 +66,8 @@ reverse:
@$(MAKE) -s -C ../ reverse
cleanup:
@$(MAKE) -s -C ../ cleanup
+uninstall:
+ @$(MAKE) -s -C ../ uninstall
endif
$(modules): %:
@@ -85,14 +93,16 @@ $(reverse-modules): reverse-%:
@$(MAKE) -s -C $* reverse MKDPREFIX=$(MKDPREFIX)$*/
$(cleanup-objects): cleanup-%:
- @$(if $(findstring $*,$(NEWLIST)),, \
+ @$(if $(findstring $*,$(NEWOBJS)),, \
@$(if $(call older,$*), \
echo -e "$(FG_RED)+ $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \
echo -e "$(FG_GRE)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"; \
unlink "$(DESTDIR)/$*" || true))
$(cleanup-modules): cleanup-%:
- @$(MAKE) -C $* cleanup MKDPREFIX=$(MKDPREFIX)$*/
+ @$(if $(findstring $*,$(NEWMODS)), \
+ @$(MAKE) -C $* cleanup MKDPREFIX=$(MKDPREFIX)$*/, \
+ @$(MAKE) -C $* uninstall MKDPREFIX=$(MKDPREFIX)$*/)
$(check-objects): check-%:
@$(if $(call newer,$*), \
@@ -104,5 +114,14 @@ $(check-objects): check-%:
$(check-modules): check-%:
@$(MAKE) -s -C $* check 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)"; \
+ unlink "$(DESTDIR)/$*" || true)
+
+$(uninstall-modules): uninstall-%:
+ @$(MAKE) -s -C $* uninstall MKDPREFIX=$(MKDPREFIX)$*/
+
$(filter %.elc,$(objects)): %.elc: %.el
$(call compile,$^)