From 55e386bf0c0b6a98ce295366bb4f31c00f048e16 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 15 Feb 2013 00:47:01 +0100 Subject: [PATCH] Add reverse target This target takes files whose installed versions are newer than those in the current working directory and copies them there. --- dotfiles.mk | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 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 -install-objects=$(addprefix install-,$(objects)) -uninstall-objects=$(addprefix uninstall-,$(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)) +install-modules=$(addprefix install-,$(modules)) +reverse-modules=$(addprefix reverse-,$(modules)) +uninstall-modules=$(addprefix uninstall-,$(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)", \