diff options
-rw-r--r-- | Makefile | 40 |
1 files changed, 37 insertions, 3 deletions
@@ -2,16 +2,50 @@ ifndef HOME | |||
2 | $(error "$$HOME" must be defined) | 2 | $(error "$$HOME" must be defined) |
3 | endif | 3 | endif |
4 | 4 | ||
5 | DOTFILES := $(shell find dot \( -type f -o -type l \) -not -name '.*') | 5 | .DEFAULT_GOAL = simulate-install |
6 | 6 | ||
7 | DESTINATIONS = $(DOTFILES:dot/%=${HOME}/.%) | 7 | SOURCES := $(shell find dot \( -type f -o -type l \) -not -name '.*') |
8 | |||
9 | DESTINATIONS = $(SOURCES:dot/%=${HOME}/.%) | ||
8 | 10 | ||
9 | ${HOME}/.gitconfig: | 11 | ${HOME}/.gitconfig: |
10 | ./src/gitconfig.sh | 12 | ./src/gitconfig.sh |
11 | 13 | ||
12 | EXECUTABLES = $(filter dot/local/bin/%, $(DOTFILES)) | 14 | EXECUTABLES = $(filter dot/local/bin/%, $(SOURCES)) |
13 | 15 | ||
16 | ifndef 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) $< $@ |
19 | endif | ||
20 | |||
21 | .PHONY: install simulate-install diff | ||
22 | |||
23 | diff: | ||
24 | $(MAKE) REVERSE=y reverse-all | less -E | ||
25 | |||
26 | help: | ||
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 | |||
40 | ifdef REVERSE | ||
41 | .PHONY: reverse-all | ||
42 | reverse-all: $(SOURCES) | ||
43 | .FORCE: | ||
44 | $(SOURCES): .FORCE | ||
45 | @diff -u3 $@ $(@:dot/%=$(HOME)/.%) || rsync $(if $(WRITE_REVERSE),,-n) -ui $(@:dot/%=$(HOME)/.%) $@ | ||
46 | endif | ||
16 | 47 | ||
17 | install: $(DESTINATIONS) | 48 | install: $(DESTINATIONS) |
49 | |||
50 | simulate-install: | ||
51 | $(MAKE) -n install | ||