APATH := $(realpath .) RPATH := $(subst $(wildcard ~/),,$(APATH)) FILES := DOTFILES := bash* flexget vimrc .PHONY: install $(FILES) $(DOTFILES) install: $(FILES) $(DOTFILES) $(FILES): @if [[ -f ~/$@ || -d ~/$@ ]]; then \ if [[ -d $@ ]]; then \ cp -r ~/$@/* $@; \ else \ cp -r ~/$@ $@; \ fi; \ rm -r ~/$@; \ fi; ln -sf $(RPATH)/$@ ~/.$@ $(DOTFILES): @if [[ -f ~/.$@ || -d ~/.$@ ]]; then \ if [[ -d $@ ]]; then \ cp -r ~/.$@/* $@; \ else \ cp -r ~/.$@ $@; \ fi; \ rm -r ~/.$@; \ fi; ln -sf $(RPATH)/$@ ~/.$@