-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
247 lines (201 loc) · 5.37 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
MODE ?= install
DRY ?= no
LINK_CONFIGS = \
bash_profile \
bashrc \
inputrc_linux \
inputrc_macos \
looking-glass-client \
mpv \
neofetch \
npm \
picom \
qutebrowser \
bspwm \
sxhkd \
systemd-wallpaper-service \
systemd-wallpaper-timer \
polybar \
yabai \
skhd \
ubersicht \
tmux \
vim
COPY_CONFIGS = \
bashrc_custom \
dolphin \
fontconfig \
gwenview \
htop \
konsole
.PHONY: $(LINK_CONFIGS) $(COPY_CONFIGS)
DOTFILES_DIR ?= ${PWD}
HOME_DIR ?= ${HOME}
CONFIG_DIR ?= $(HOME_DIR)/.config
.DEFAULT:;
all:;
$(LINK_CONFIGS):
$(eval $@_DEST := $(strip $(subst $<,,$^)))
$(eval $@_BASEDIR := $(shell dirname "$($@_DEST)"))
ifeq ($(MODE),install)
ifeq ($(DRY),yes)
@printf "[dry] '%s' -> '%s'\\n" "$($@_DEST)" "$<"
else
@# Remove previous link if it exists
@if [ -L "$($@_DEST)" ]; then \
rm -f "$($@_DEST)"; \
fi
@# Create parent directory if it does not exist
@mkdir -p "$($@_BASEDIR)"
@# Link the source to the destination
@ln -svf "$<" "$($@_DEST)"
endif # ifeq ($(DRY),yes)
endif # ifeq ($(MODE),install)
ifeq ($(MODE),uninstall)
ifeq ($(DRY),yes)
@printf "[dry] removed '%s'\\n" "$($@_DEST)"
else
@if [ -L "$($@_DEST)" ]; then \
rm -rfv "$($@_DEST)"; \
fi
endif # ifeq ($(DRY),yes)
endif # ifeq ($(MODE),uninstall)
ifneq ($(MODE),uninstall)
ifneq ($(MODE),install)
@printf "%s: unknown mode: %s\\n" "$@" "$(MODE)"
@exit 1
endif # ifneq ($(MODE),install)
endif # ifneq ($(MODE),uninstall)
$(COPY_CONFIGS):
$(eval $@_DEST := $(strip $(subst $<,,$^)))
$(eval $@_BASEDIR := $(shell dirname "$($@_DEST)"))
ifeq ($(MODE),install)
ifeq ($(DRY),yes)
@printf "[dry] '%s' -> '%s'\\n" "$<" "$($@_DEST)"
else
@# If source is a file, destination should also be a file
@# If destination is a directory, the source file will be copied into the
@# destination directory. Exit if that's the case
@if [ -e "$($@_DEST)" ] && [ -d "$($@_DEST)" ] && [ -f "$<" ]; then \
printf "Source '%s' is a file. " "$<"; \
printf "Target '%s' is a directory. " "$($@_DEST)"; \
printf "Copying to this directory breaks the path.\\n" "$($@_DEST)"; \
printf "Exiting...\\n"; \
exit 1; \
fi
@# Overwrite the destination directory if the source is a directory
@if [ -e "$($@_DEST)" ] && [ -d "$<" ]; then \
rm -rf "$($@_DEST)"; \
fi
@# Create parent directory if it does not exist
@mkdir -p "$($@_BASEDIR)"
@# Copy the source to the destination
@cp -r -v "$<" "$($@_DEST)"
endif # ifeq ($(DRY),yes)
endif # ifeq ($(MODE),install)
ifeq ($(MODE),uninstall)
ifeq ($(DRY),yes)
@printf "[dry] removed '%s'\\n" "$($@_DEST)"
else
@if [ -e "$($@_DEST)" ]; then \
rm -rfv "$($@_DEST)"; \
fi
endif # ifeq ($(DRY),yes)
endif # ifeq ($(MODE),uninstall)
ifneq ($(MODE),uninstall)
ifneq ($(MODE),install)
@printf "%s: unknown mode: %s\\n" "$@" "$(MODE)"
@exit 1
endif # ifneq ($(MODE),install)
endif # ifneq ($(MODE),uninstall)
# format:
# application-config: \
# source-file \
# destination-file
### LINK_CONFIGS
# Bash configuration files is os dependant.
# It also includes .bash_profile, .bashrc and .inputrc
bash_linux: bash inputrc_linux
bash_macos: bash inputrc_macos
bash: bash_profile bashrc
# Systemd services and timers requires linking multiple files
systemd-wallpaper: systemd-wallpaper-service systemd-wallpaper-timer
bash_profile: \
$(DOTFILES_DIR)/bashrc/bash_profile \
$(HOME_DIR)/.bash_profile
bashrc: \
$(DOTFILES_DIR)/bashrc/bashrc \
$(HOME_DIR)/.bashrc
inputrc_linux: \
$(DOTFILES_DIR)/bashrc/inputrc_linux \
$(HOME_DIR)/.inputrc
inputrc_macos: \
$(DOTFILES_DIR)/bashrc/inputrc_macos \
$(HOME_DIR)/.inputrc
looking-glass-client: \
$(DOTFILES_DIR)/looking-glass-client/looking-glass-client.ini \
$(HOME_DIR)/.looking-glass-client.ini
mpv: \
$(DOTFILES_DIR)/mpv \
$(CONFIG_DIR)/.mpv
neofetch: \
$(DOTFILES_DIR)/neofetch \
$(CONFIG_DIR)/neofetch
npm: \
$(DOTFILES_DIR)/npm/npmrc \
$(HOME_DIR)/.npmrc
picom: \
$(DOTFILES_DIR)/picom \
$(CONFIG_DIR)/picom
qutebrowser: \
$(DOTFILES_DIR)/qutebrowser \
$(CONFIG_DIR)/qutebrowser
bspwm: \
$(DOTFILES_DIR)/bspwm \
$(CONFIG_DIR)/bspwm
sxhkd: \
$(DOTFILES_DIR)/sxhkd \
$(CONFIG_DIR)/sxhkd
systemd-wallpaper-service: \
$(DOTFILES_DIR)/systemd/wallpaper.service \
$(CONFIG_DIR)/systemd/user/wallpaper.service
systemd-wallpaper-timer: \
$(DOTFILES_DIR)/systemd/wallpaper.timer \
$(CONFIG_DIR)/systemd/user/wallpaper.timer
polybar: \
$(DOTFILES_DIR)/polybar \
$(CONFIG_DIR)/polybar
yabai: \
$(DOTFILES_DIR)/yabai/yabairc \
$(HOME_DIR)/.yabairc
skhd: \
$(DOTFILES_DIR)/skhd/skhdrc \
$(HOME_DIR)/.skhdrc
ubersicht: \
$(DOTFILES_DIR)/ubersicht \
$(HOME_DIR)/Library/Application\ Support/Übersicht/widgets/dotfiles-bar
tmux: \
$(DOTFILES_DIR)/tmux/tmux.conf \
$(HOME_DIR)/.tmux.conf
vim: \
$(DOTFILES_DIR)/vimrc \
$(HOME_DIR)/.vim
### COPY_CONFIGS
bashrc_custom:\
$(DOTFILES_DIR)/bashrc/bashrc_custom \
$(HOME_DIR)/.bashrc_custom
dolphin: \
$(DOTFILES_DIR)/plasma/dolphin/dolphinrc \
$(CONFIG_DIR)/dolphinrc
fontconfig: \
$(DOTFILES_DIR)/fontconfig \
$(CONFIG_DIR)/fontconfig
gwenview: \
$(DOTFILES_DIR)/plasma/gwenview/gwenviewrc \
$(CONFIG_DIR)/gwenviewrc
htop: \
$(DOTFILES_DIR)/htop \
$(CONFIG_DIR)/htop
konsole: \
$(DOTFILES_DIR)/plasma/konsole/konsolerc \
$(CONFIG_DIR)/konsolerc