From 7474e34062cec498a1c992921cb582c37f1483b3 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sun, 31 May 2020 12:39:04 -0400 Subject: Makefile improvements 1. changed default goal just to show what 'make install' would do. 2. added "REVERSE" variable and "reverse-all" target to show/incorporate back into the source the changes that have been made to installed versions. --- Makefile | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 691e8a9..5e70c84 100644 --- a/Makefile +++ b/Makefile @@ -2,16 +2,50 @@ ifndef HOME $(error "$$HOME" must be defined) endif -DOTFILES := $(shell find dot \( -type f -o -type l \) -not -name '.*') +.DEFAULT_GOAL = simulate-install -DESTINATIONS = $(DOTFILES:dot/%=${HOME}/.%) +SOURCES := $(shell find dot \( -type f -o -type l \) -not -name '.*') + +DESTINATIONS = $(SOURCES:dot/%=${HOME}/.%) ${HOME}/.gitconfig: ./src/gitconfig.sh -EXECUTABLES = $(filter dot/local/bin/%, $(DOTFILES)) +EXECUTABLES = $(filter dot/local/bin/%, $(SOURCES)) +ifndef REVERSE $(HOME)/.%: dot/% install -D -m $(if $(filter $<, $(EXECUTABLES)), 0755, 0644) $< $@ +endif + +.PHONY: install simulate-install diff + +diff: + $(MAKE) REVERSE=y reverse-all | less -E + +help: + @echo 'To see all files changed outside the source tree:' + @echo + @echo ' make diff' + @echo + @echo 'To show the diff of one file (e.g. .xinitrc):' + @echo + @echo ' make REVERSE=y dot/xinitrc' + @echo + @echo 'To _copy_ from $$HOME/.xinitrc into the source tree:' + @echo + @echo ' make REVERSE=y WRITE_REVERSE=y dot/xinitrc' + @echo + +ifdef REVERSE +.PHONY: reverse-all +reverse-all: $(SOURCES) +.FORCE: +$(SOURCES): .FORCE + @diff -u3 $@ $(@:dot/%=$(HOME)/.%) || rsync $(if $(WRITE_REVERSE),,-n) -ui $(@:dot/%=$(HOME)/.%) $@ +endif install: $(DESTINATIONS) + +simulate-install: + $(MAKE) -n install -- cgit v1.2.3