-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
230 lines (181 loc) · 4.13 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File: Makefile
# Author: Zakhary Kaplan <https://zakhary.dev>
# Created: 23 Feb 2020
# SPDX-License-Identifier: MIT
# Vim: set fdl=0 fdm=marker:
# ----------------
# -- Variables --
# ----------------
# {{{
# -- Directories -- {{{
# XDG
XDG_CONFIG_HOME ?= $(HOME)/.config
XDG_DATA_HOME ?= $(HOME)/.local/share
# Home
CRON = $(HOME)/.cron
DOTS = $(HOME)/.dots
FZF = $(XDG_DATA_HOME)/fzf
NVIM = $(XDG_CONFIG_HOME)/nvim
PACKER = $(XDG_DATA_HOME)/nvim/site/pack/packer
TMUX = $(XDG_CONFIG_HOME)/tmux
ZPACK = $(ZSH)/pack
ZPLUG = $(ZSH)/before
ZSH = $(XDG_CONFIG_HOME)/zsh
# }}}
# -- Files -- {{{
BREWFILE = $(DOTS)/Brewfile
# }}}
# -- Commands -- {{{
CLONE = git clone --depth 1
LN = ln -sf
MKDIR = mkdir -p
STOW = stow --no-folding --dir=$(DOTS) --target=$(HOME)
# Optional
BREW := $(notdir $(shell command -v brew 2> /dev/null))
# }}}
# -- URLs -- {{{
GITHUB = https://github.com
# }}}
# -- Plugins -- {{{
# tmux
TMUX_PLUGINS += tmux-plugins/tpm # use tpm to manage tmux plugins
# Zsh
ZSH_PLUGINS += zsh-users/zsh-autosuggestions
ZSH_PLUGINS += zsh-users/zsh-syntax-highlighting
# Zsh: Oh My Zsh
OHMYZSH = $(ZPACK)/ohmyzsh
OMZ_REPO = ohmyzsh/ohmyzsh
ZSH_PLUGINS += $(OMZ_REPO)
OMZ_LIB = $(OHMYZSH)/lib
OMZ_LIBS += $(ZPLUG)/completion.zsh
OMZ_LIBS += $(ZPLUG)/git.zsh
OMZ_LIBS += $(ZPLUG)/key-bindings.zsh
OMZ_PLUG = $(OHMYZSH)/plugins
# }}}
# -- Utilities -- {{{
FZF_CONFIG = $(HOME)/.config/fzf/fzf.zsh
# }}}
# }}}
# ----------------
# -- Targets --
# ----------------
# {{{
# -- Top-level Goals -- {{{
.PHONY: all
all: apps
# }}}
# -- Application Goals -- {{{
.PHONY: apps
apps: etc local nvim tmux zsh
.PHONY: etc
etc: fzf
.PHONY: local
local: stow-local
.PHONY: nvim
nvim: $(NVIM) plug-nvim stow
.PHONY: tmux
tmux: $(TMUX) plug-tmux stow
.PHONY: zsh
zsh: $(ZSH) plug-zsh stow
# }}}
# -- Install Goals -- {{{
.PHONY: install
install: brew all
.PHONY: uninstall
uninstall: unstow
# }}}
# -- Dependency Goals -- {{{
%: brew
.PHONY: brew
brew:
ifdef BREW
$(BREW) bundle --file=$(BREWFILE)
endif
# }}}
# -- Stow Goals -- {{{
.PHONY: stow
stow: stow-local
$(STOW) --restow home
.PHONY: stow-local
stow-local:
$(STOW) --restow local
.PHONY: unstow
unstow: unstow-local
@$(STOW) -v --delete home
.PHONY: unstow-local
unstow-local:
@$(STOW) -v --delete local
# }}}
# -- Plugins Goals -- {{{
.PHONY: plug
plug: plug-nvim plug-tmux plug-zsh
plug-%: stow # always plug after stow
# Nvim {{{
.PHONY: plug-nvim
plug-nvim: $(NVIM)
$(NVIM):
@$(MKDIR) $@
.PHONY: packer
packer: $(NVIM)
nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
# }}}
# tmux {{{
.PHONY: plug-tmux
plug-tmux: $(TMUX) $(TMUX_PLUGINS)
.PHONY: $(TMUX)
$(TMUX):
@bash -c "$(MKDIR) $(TMUX)/{plugins,themes}"
.PHONY: $(TMUX_PLUGINS)
$(TMUX_PLUGINS): PLUGIN = $(TMUX)/plugins/$(notdir $@)
$(TMUX_PLUGINS): $(TMUX)
$(if $(wildcard $(PLUGIN)),,$(CLONE) $(GITHUB)/[email protected] $(PLUGIN))
# }}}
# Zsh {{{
.PHONY: plug-zsh
plug-zsh: $(ZSH) $(ZSH_PLUGINS) $(OHMYZSH)
.PHONY: $(ZSH)
$(ZSH):
@bash -c "$(MKDIR) $(ZSH)/{after,before,functions,pack,plugin,themes}"
.PHONY: $(ZSH_PLUGINS)
$(ZSH_PLUGINS): PLUGIN = $(ZSH)/pack/$(notdir $@)
$(ZSH_PLUGINS): $(ZSH)
$(if $(wildcard $(PLUGIN)),,$(CLONE) $(GITHUB)/[email protected] $(PLUGIN))
# Oh My Zsh
.PHONY: $(OHMYZSH)
$(OHMYZSH): $(OMZ_REPO) $(OMZ_LIBS) $(OMZ_PLUGINS)
$(OMZ_LIBS): $(ZPLUG)/%: $(OMZ_LIB)/%
$(MKDIR) $(@D)
$(LN) $< $@
$(OMZ_PLUGINS): $(ZPACK)/%: $(OMZ_PLUG)/%
$(MKDIR) $(@D)
$(LN) $< $@
$(OHMYZSH)/%: $(OMZ_REPO) ;
# }}}
# }}}
# -- Application Goals -- {{{
# fzf {{{
ifdef BREW
FZF = $(shell $(BREW) --prefix fzf)
endif
.PHONY: fzf
fzf: $(FZF) $(FZF_CONFIG)
$(FZF): # if not using brew, install fzf using git
ifndef BREW
$(CLONE) $(GITHUB)/junegunn/fzf.git $(FZF)
endif
$(FZF_CONFIG): INSTALL = $(FZF)/install
$(FZF_CONFIG): FLAGS = --all --xdg --no-update-rc --no-bash
$(FZF_CONFIG): | $(FZF)
$(INSTALL) $(FLAGS)
# }}}
# }}}
# }}}
# ----------------
# -- Extras --
# ----------------
# {{{
.SECONDARY: # do not remove secondary files
.SUFFIXES: # delete the default suffixes
# Includes
-include ./local/Makefile
# }}}