-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
90 lines (78 loc) · 2.72 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
# Find all the files/folders ending with .symlink
files_to_symlink := $(shell find . -name '*.symlink')
# Extract just the name.symlink from the previous list
symlinks := $(patsubst %.symlink, %, $(shell basename -a $(files_to_symlink)))
# Generate the complete list of symlink target we need
symlink_paths := $(addprefix $(HOME)/., $(symlinks))
# VPATH tells Make to search this list of folders when using the % pattern
# Documentation: https://www.gnu.org/software/make/manual/html_node/General-Search.html
VPATH = $(shell dirname $(files_to_symlink))
## Create symbolic links for files/folders with a .symlink suffix
.PHONY: links
links: $(symlink_paths) $(HOME)/.config/sublime-merge/Packages/User $(HOME)/.config/sublime-text/Packages/User antibody/zsh_plugins.sh $(HOME)/.config/direnv $(HOME)/.config/nix
# Create all symlink
# Documentation: https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html#Automatic-Variables
$(HOME)/.%: %.symlink
ln -s $(abspath $<) $@
$(HOME)/.config/sublime-merge/Packages/User:
ln -s $(PWD)/sublime-merge $@
$(HOME)/.config/sublime-text/Packages/User:
ln -s $(PWD)/sublime-text-3 $@
$(HOME)/.var/app/dev.zed.Zed/config/zed/settings.json:
ln -s $(PWD)/zed/settings.json $@
$(HOME)/.var/app/dev.zed.Zed/config/zed/keymap.json:
ln -s $(PWD)/zed/keymap.json $@
$(HOME)/.config/%:
ln -s $(PWD)/config/$* $@
antibody/zsh_plugins.sh: antibody/zsh_plugins.txt
antibody bundle < $< > $@
define primary
\033[38;2;166;204;112;1m$(1)\033[0m
endef
define title
\033[38;2;255;204;102m$(1)\033[0m\n
endef
.DEFAULT_GOAL := help
## List available commands
.PHONY: help
help:
@printf "$(call primary,dotfiles)\n"
@printf "My local configuration\n\n"
@printf "$(call title,USAGE)"
@printf " make <SUBCOMMAND>\n\n"
@printf "$(call title,SUBCOMMANDS)"
@awk '{ \
line = $$0; \
while((n = index(line, "http")) > 0) { \
if (match(line, "https?://[^ ]+")) { \
url = substr(line, RSTART, RLENGTH); \
sub(url, "\033[38;2;119;168;217m"url"\033[0m", $$0); \
line = substr(line, n + RLENGTH); \
} else {\
break; \
} \
}\
\
if ($$0 ~ /^.PHONY: [a-zA-Z0-9]+$$/) { \
helpCommand = substr($$0, index($$0, ":") + 2); \
if (helpMessage) { \
printf " $(call primary,%-8s)%s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
helpCommand = substr($$0, 0, index($$0, ":")); \
if (helpMessage) { \
printf " $(call primary,%-8s)%s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage "\n " substr($$0, 3); \
} else { \
helpMessage = substr($$0, 3); \
} \
} \
}' \
$(MAKEFILE_LIST)