APATH := $(realpath .)
RPATH := $(subst $(wildcard ~/),,$(APATH))
-EXCLUDES := Makefile
-ALL := $(wildcard *)
-FILES := $(filter-out $(EXCLUDES),$(ALL))
+FILES := bin
+DOTFILES := aliasesrc bash* flexget vim* zsh*
-
-test:
- echo $(APATH)
- echo $(FILES);
- echo $(RPATH)
-
-.PHONY: install $(FILES)
-install: $(FILES)
+.PHONY: install $(FILES) $(DOTFILES)
+install: $(FILES) $(DOTFILES)
$(FILES):
- cp -r ~/.$@ $@
- rm -r ~/.$@
- ln -sf $(RPATH)/$@ ~/.$@
+ @if [[ -e ~/$@ && ! -L ~/$@ ]]; then \
+ if [[ -d $@ ]]; then \
+ cp -r ~/$@/* $@; \
+ else \
+ cp -r ~/$@ $@; \
+ fi; \
+ rm -r ~/$@; \
+ fi;
+ ln -sfT $(RPATH)/$@ ~/$@
+
+$(DOTFILES):
+ @if [[ -e ~/.$@ && ! -L ~/.$@ ]]; then \
+ if [[ -d .$@ ]]; then \
+ cp -r ~/.$@/* $@; \
+ else \
+ cp -r ~/.$@ $@; \
+ fi; \
+ rm -r ~/.$@; \
+ fi;
+ ln -sfT $(RPATH)/$@ ~/.$@