Add uninstall targets

These targets can be used to remove (parts of) the file installation.
They are also used by the cleanup targets to remove complete
submodules from the installation.
This commit is contained in:
Tom Willemse 2013-04-14 23:58:45 +02:00
parent 50c3f9ade9
commit ea413a5023

View file

@ -20,27 +20,33 @@ check-objects=$(addprefix check-,$(objects))
install-objects=$(addprefix install-,$(objects)) install-objects=$(addprefix install-,$(objects))
reverse-objects=$(addprefix reverse-,$(objects)) reverse-objects=$(addprefix reverse-,$(objects))
cleanup-objects=$(addprefix cleanup-,$(objects)) cleanup-objects=$(addprefix cleanup-,$(objects))
uninstall-objects=$(addprefix uninstall-,$(objects))
check-modules=$(addprefix check-,$(modules)) check-modules=$(addprefix check-,$(modules))
install-modules=$(addprefix install-,$(modules)) install-modules=$(addprefix install-,$(modules))
reverse-modules=$(addprefix reverse-,$(modules)) reverse-modules=$(addprefix reverse-,$(modules))
cleanup-modules=$(addprefix cleanup-,$(modules)) cleanup-modules=$(addprefix cleanup-,$(modules))
uninstall-modules=$(addprefix uninstall-,$(modules))
.PHONY: all install cleanup check cleanup $(modules) \ .PHONY: all install cleanup check cleanup $(modules) \
$(install-objects) $(cleanup-objects) $(check-objects) \ $(install-objects) $(cleanup-objects) $(check-objects) \
$(install-modules) $(cleanup-modules) $(check-modules) \ $(install-modules) $(cleanup-modules) $(check-modules) \
$(reverse) $(reverse-objects) $(reverse-modules) $(reverse) $(reverse-objects) $(reverse-modules) \
$(uninstall-objects) $(uninstall-modules)
all: $(modules) $(objects) all: $(modules) $(objects)
ifeq ($(MAKEROOT),y) ifeq ($(MAKEROOT),y)
check: $(check-modules) $(check-objects) check: $(check-modules) $(check-objects)
install: cleanup $(install-modules) $(install-objects) Makefile.old install: cleanup $(install-modules) $(install-objects) Makefile.old
reverse: $(reverse-modules) $(reverse-objects) 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) ifeq ($(firstword $(MAKEFILE_LIST)),Makefile.old)
cleanup: $(cleanup-modules) $(cleanup-objects) cleanup: $(cleanup-modules) $(cleanup-objects)
@rmdir --ignore-fail-on-non-empty $(DESTDIR) 2> /dev/null || true @rmdir --ignore-fail-on-non-empty $(DESTDIR) 2> /dev/null || true
else else
cleanup: export NEWLIST = $(objects) cleanup: export NEWOBJS = $(objects)
cleanup: export NEWMODS = $(modules)
cleanup: cleanup:
@$(MAKE) -s -f Makefile.old cleanup @$(MAKE) -s -f Makefile.old cleanup
@ -60,6 +66,8 @@ reverse:
@$(MAKE) -s -C ../ reverse @$(MAKE) -s -C ../ reverse
cleanup: cleanup:
@$(MAKE) -s -C ../ cleanup @$(MAKE) -s -C ../ cleanup
uninstall:
@$(MAKE) -s -C ../ uninstall
endif endif
$(modules): %: $(modules): %:
@ -85,14 +93,16 @@ $(reverse-modules): reverse-%:
@$(MAKE) -s -C $* reverse MKDPREFIX=$(MKDPREFIX)$*/ @$(MAKE) -s -C $* reverse MKDPREFIX=$(MKDPREFIX)$*/
$(cleanup-objects): cleanup-%: $(cleanup-objects): cleanup-%:
@$(if $(findstring $*,$(NEWLIST)),, \ @$(if $(findstring $*,$(NEWOBJS)),, \
@$(if $(call older,$*), \ @$(if $(call older,$*), \
echo -e "$(FG_RED)+ $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \ echo -e "$(FG_RED)+ $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \
echo -e "$(FG_GRE)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"; \ echo -e "$(FG_GRE)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"; \
unlink "$(DESTDIR)/$*" || true)) unlink "$(DESTDIR)/$*" || true))
$(cleanup-modules): cleanup-%: $(cleanup-modules): cleanup-%:
@$(MAKE) -C $* cleanup MKDPREFIX=$(MKDPREFIX)$*/ @$(if $(findstring $*,$(NEWMODS)), \
@$(MAKE) -C $* cleanup MKDPREFIX=$(MKDPREFIX)$*/, \
@$(MAKE) -C $* uninstall MKDPREFIX=$(MKDPREFIX)$*/)
$(check-objects): check-%: $(check-objects): check-%:
@$(if $(call newer,$*), \ @$(if $(call newer,$*), \
@ -104,5 +114,14 @@ $(check-objects): check-%:
$(check-modules): check-%: $(check-modules): check-%:
@$(MAKE) -s -C $* check MKDPREFIX=$(MKDPREFIX)$*/ @$(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 $(filter %.elc,$(objects)): %.elc: %.el
$(call compile,$^) $(call compile,$^)