summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile40
1 files changed, 37 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 691e8a9..5e70c84 100644
--- a/Makefile
+++ b/Makefile
@@ -2,16 +2,50 @@ ifndef HOME
2$(error "$$HOME" must be defined) 2$(error "$$HOME" must be defined)
3endif 3endif
4 4
5DOTFILES := $(shell find dot \( -type f -o -type l \) -not -name '.*') 5.DEFAULT_GOAL = simulate-install
6 6
7DESTINATIONS = $(DOTFILES:dot/%=${HOME}/.%) 7SOURCES := $(shell find dot \( -type f -o -type l \) -not -name '.*')
8
9DESTINATIONS = $(SOURCES:dot/%=${HOME}/.%)
8 10
9${HOME}/.gitconfig: 11${HOME}/.gitconfig:
10 ./src/gitconfig.sh 12 ./src/gitconfig.sh
11 13
12EXECUTABLES = $(filter dot/local/bin/%, $(DOTFILES)) 14EXECUTABLES = $(filter dot/local/bin/%, $(SOURCES))
13 15
16ifndef REVERSE
14$(HOME)/.%: dot/% 17$(HOME)/.%: dot/%
15 install -D -m $(if $(filter $<, $(EXECUTABLES)), 0755, 0644) $< $@ 18 install -D -m $(if $(filter $<, $(EXECUTABLES)), 0755, 0644) $< $@
19endif
20
21.PHONY: install simulate-install diff
22
23diff:
24 $(MAKE) REVERSE=y reverse-all | less -E
25
26help:
27 @echo 'To see all files changed outside the source tree:'
28 @echo
29 @echo ' make diff'
30 @echo
31 @echo 'To show the diff of one file (e.g. .xinitrc):'
32 @echo
33 @echo ' make REVERSE=y dot/xinitrc'
34 @echo
35 @echo 'To _copy_ from $$HOME/.xinitrc into the source tree:'
36 @echo
37 @echo ' make REVERSE=y WRITE_REVERSE=y dot/xinitrc'
38 @echo
39
40ifdef REVERSE
41.PHONY: reverse-all
42reverse-all: $(SOURCES)
43.FORCE:
44$(SOURCES): .FORCE
45 @diff -u3 $@ $(@:dot/%=$(HOME)/.%) || rsync $(if $(WRITE_REVERSE),,-n) -ui $(@:dot/%=$(HOME)/.%) $@
46endif
16 47
17install: $(DESTINATIONS) 48install: $(DESTINATIONS)
49
50simulate-install:
51 $(MAKE) -n install