summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2013-02-15 00:47:01 +0100
committerGravatar Tom Willemsen2013-02-15 00:48:19 +0100
commit55e386bf0c0b6a98ce295366bb4f31c00f048e16 (patch)
tree2322c54e606c8bfcf925f9cb1e1ea538db4983aa
parentf85643301d86821c721dd067f86c858917545f99 (diff)
downloaddotfiles-55e386bf0c0b6a98ce295366bb4f31c00f048e16.tar.gz
dotfiles-55e386bf0c0b6a98ce295366bb4f31c00f048e16.zip
Add reverse target
This target takes files whose installed versions are newer than those in the current working directory and copies them there.
-rw-r--r--dotfiles.mk21
1 files changed, 18 insertions, 3 deletions
diff --git a/dotfiles.mk b/dotfiles.mk
index aaabad3..92e35a1 100644
--- a/dotfiles.mk
+++ b/dotfiles.mk
@@ -16,28 +16,34 @@ define older =
$(shell if [ "$(1)" -ot "$(DESTDIR)/$(1)" ]; then echo "older"; fi)
endef
+check-objects=$(addprefix check-,$(objects))
install-objects=$(addprefix install-,$(objects))
+reverse-objects=$(addprefix reverse-,$(objects))
uninstall-objects=$(addprefix uninstall-,$(objects))
-check-objects=$(addprefix check-,$(objects))
+check-modules=$(addprefix check-,$(modules))
install-modules=$(addprefix install-,$(modules))
+reverse-modules=$(addprefix reverse-,$(modules))
uninstall-modules=$(addprefix uninstall-,$(modules))
-check-modules=$(addprefix check-,$(modules))
.PHONY: all install uninstall check uninstall $(modules) \
$(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)
ifeq ($(MAKEROOT),y)
check: $(check-modules) $(check-objects)
install: $(install-modules) $(install-objects)
+reverse: $(reverse-modules) $(reverse-objects)
uninstall: $(uninstall-modules) $(uninstall-objects)
else
check:
@$(MAKE) -s -C ../ check
install:
@$(MAKE) -s -C ../ install
+reverse:
+ @$(MAKE) -s -C ../ reverse
uninstall:
@$(MAKE) -C ../ uninstall
endif
@@ -55,6 +61,15 @@ $(install-objects): install-%: %
$(install-modules): 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-%:
@$(if $(call older,$*), \
echo -e "$(FG_RED)not uninstalling $(FG_YEL)$*$(CLR_RE)", \