Add reverse target

This target takes files whose installed versions are newer than those
in the current working directory and copies them there.
This commit is contained in:
Tom Willemsen 2013-02-15 00:47:01 +01:00
parent f85643301d
commit 55e386bf0c

View file

@ -16,28 +16,34 @@ define older =
$(shell if [ "$(1)" -ot "$(DESTDIR)/$(1)" ]; then echo "older"; fi) $(shell if [ "$(1)" -ot "$(DESTDIR)/$(1)" ]; then echo "older"; fi)
endef endef
install-objects=$(addprefix install-,$(objects))
uninstall-objects=$(addprefix uninstall-,$(objects))
check-objects=$(addprefix check-,$(objects)) check-objects=$(addprefix check-,$(objects))
install-objects=$(addprefix install-,$(objects))
reverse-objects=$(addprefix reverse-,$(objects))
uninstall-objects=$(addprefix uninstall-,$(objects))
install-modules=$(addprefix install-,$(modules))
uninstall-modules=$(addprefix uninstall-,$(modules))
check-modules=$(addprefix check-,$(modules)) check-modules=$(addprefix check-,$(modules))
install-modules=$(addprefix install-,$(modules))
reverse-modules=$(addprefix reverse-,$(modules))
uninstall-modules=$(addprefix uninstall-,$(modules))
.PHONY: all install uninstall check uninstall $(modules) \ .PHONY: all install uninstall check uninstall $(modules) \
$(install-objects) $(uninstall-objects) $(check-objects) \ $(install-objects) $(uninstall-objects) $(check-objects) \
$(install-modules) $(uninstall-modules) $(check-modules) $(install-modules) $(uninstall-modules) $(check-modules) \
$(reverse) $(reverse-objects) $(reverse-modules)
all: $(modules) $(objects) all: $(modules) $(objects)
ifeq ($(MAKEROOT),y) ifeq ($(MAKEROOT),y)
check: $(check-modules) $(check-objects) check: $(check-modules) $(check-objects)
install: $(install-modules) $(install-objects) install: $(install-modules) $(install-objects)
reverse: $(reverse-modules) $(reverse-objects)
uninstall: $(uninstall-modules) $(uninstall-objects) uninstall: $(uninstall-modules) $(uninstall-objects)
else else
check: check:
@$(MAKE) -s -C ../ check @$(MAKE) -s -C ../ check
install: install:
@$(MAKE) -s -C ../ install @$(MAKE) -s -C ../ install
reverse:
@$(MAKE) -s -C ../ reverse
uninstall: uninstall:
@$(MAKE) -C ../ uninstall @$(MAKE) -C ../ uninstall
endif endif
@ -55,6 +61,15 @@ $(install-objects): install-%: %
$(install-modules): install-%: $(install-modules): install-%:
@$(MAKE) -s -C $* install @$(MAKE) -s -C $* install
$(reverse-objects): reverse-%:
@$(if $(call older,$*), \
echo -e "$(FG_GRE)reversing $(FG_YEL)$(DESTDIR)/$* $(CLR_RE)"; \
cp -a "$(DESTDIR)/$*" "$*", \
echo -e "$(FG_RED)not reversing $(FG_YEL)$*$(CLR_RE)")
$(reverse-modules): reverse-%:
@$(MAKE) -s -C $* reverse
$(uninstall-objects): uninstall-%: $(uninstall-objects): uninstall-%:
@$(if $(call older,$*), \ @$(if $(call older,$*), \
echo -e "$(FG_RED)not uninstalling $(FG_YEL)$*$(CLR_RE)", \ echo -e "$(FG_RED)not uninstalling $(FG_YEL)$*$(CLR_RE)", \