ifndef HOME $(error "$$HOME" must be defined) endif .DEFAULT_GOAL = simulate-install 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/%, $(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)/.%) 2>/dev/null || rsync $(if $(WRITE_REVERSE),,-n) --ignore-missing-args -ui $(@:dot/%=$(HOME)/.%) $@ endif install: $(DESTINATIONS) install-packages: ifeq ($(shell id -u),0) install -m0644 eschew-unstable.pref /etc/apt/preferences.d/ bash install-packages.bash else sudo -- $(MAKE) -$(MAKEFLAGS) $@ endif simulate-install: @echo @echo \#\# SIMULATED INSTALL \#\# @echo @echo run \'make install\' to execute the install commands shown below @echo @$(MAKE) -n install