-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (66 loc) · 1.93 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
CONFIG := $(HOME)/.config/
VIM := $(addprefix ${CONFIG}, $(wildcard nvim/* nvim/**/*))
ZSH := $(addprefix ${CONFIG}, $(wildcard zsh/*))
ZSH_CONFIG := ${HOME}/.zshrc
GIT := ${HOME}/.gitconfig
YABAI := ${CONFIG}yabai/yabairc
SKHD := ${CONFIG}/.skhdrc
BREW := $(HOME)/Brewfile
BREW_ENV := $(HOME)/.brewenv
MAC := $(CONFIG)mac/install.sh
NODE := $(CONFIG)node/globals
CREATE_TARGET_DIR= if [ ! -d "$(@D)" ]; then echo "Directory $(@D) was not found, creating..." && mkdir -p "$(@D)";fi;
.PHONY: all mac brew git vim
all:| mac brew yabai skhd zsh git node vim;
.SECONDEXPANSION:
$(VIM): $$(subst ${CONFIG},, $$@)
@$(call CREATE_TARGET_DIR)
@if [ ! -d $< ]; then \
echo "Including ${^} configuration to ${@}" ;\
cp $< $@ ;\
fi
.SECONDEXPANSION:
$(ZSH): $$(subst ${CONFIG},, $$@)
@$(call CREATE_TARGET_DIR)
@echo "Including ${^} configuration to ${@}"
@cp "${^}" "${@}"
@if [ "${@F}" = "_setup.sh" ] ; then \
${@} "${HOME}" "${CONFIG}" ;\
else \
file="source '${CONFIG}${^}';" &&\
( \
grep "$${file}" ${ZSH_CONFIG} -q || echo "$${file}" >> ${ZSH_CONFIG} \
) ; \
fi
$(MAC): mac/install.sh
@$(call CREATE_TARGET_DIR)
@cp ${^} ${@}
@${@}
.SECONDEXPANSION:
$(YABAI): $$(subst ${CONFIG},, $$@)
@$(call CREATE_TARGET_DIR)
@cp ${^} ${@}
$(SKHD): skhd/skhdrc
@cp ${^} ${HOME}/.skhdrc
$(GIT): $(wildcard git/*)
@(./git/install.sh ./git/.gitconfig) || :
$(BREW): $(wildcard brew/*)
@./brew/install.sh
@cp ./brew/Brewfile ${HOME}/Brewfile
@source ${BREW_ENV} &&\
($${HOMEBREW_PREFIX}/bin/brew bundle --file ${HOME}/Brewfile --force) || : &&\
(./brew/_setup.sh) || :
$(NODE): node/globals
@xargs -I {} -n 4 npm install {} --global < "${^}"
@mkdir -p "${@}"
@cp "${^}" "${@}"
vim: $(VIM) ;
git: $(GIT) ;
brew: $(BREW) ;
mac: $(MAC) ;
node: $(NODE) ;
zsh: $(ZSH) ;
yabai: $(YABAI) ;
skhd: $(SKHD) ;
node/globals: ;
mac/install: ;