-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
147 lines (128 loc) · 4.63 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
SHELL=/bin/bash
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
# MAKEFLAGS += --silent
.DEFAULT_GOAL = help
.DELETE_ON_ERROR:
.NOTPARALLEL:
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
all: help
.PHONY: all
# -----------------------------------------------------------------------------
# Configutation
# -----------------------------------------------------------------------------
export XDG_CACHE_HOME := $(HOME)/.cache
export XDG_CONFIG_HOME := $(HOME)/.config
export XDG_DATA_HOME := $(HOME)/.local/share
export XDG_STATE_HOME := $(HOME)/.local/state
include include/make/variables.mk
-include include/make/variables.$(CURRENT_OS).mk
include include/make/utils.mk
# Use the FORCE rule as dependency to force the execution of the target rule when
# the false prerequisites contain `%` which is interpreted as a literal.
# https://www.gnu.org/software/make/manual/html_node/Force-Targets.html
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
FORCE:
.PHONY: FORCE
# -----------------------------------------------------------------------------
# Target: main
# -----------------------------------------------------------------------------
## Perform setup of the device.
setup:: setup-dirs
.PHONY: setup
## Install all the prerequisites.
install:: setup-dirs install-stow setup-links
.PHONY: install
install-stow:
@echo "$(PURPLE)• Installing GNU Stow$(RESET)"
@$(INSTALL) stow
.PHONY: install-stow
## Clean all cache systems.
cleanup::
@trash-put "$ZSH_EVALCACHE_DIR"/init-*.sh
@npm cache verify
@gem cleanup --silent $(_DRY_RUN)
@rm -f $(XDG_DATA_HOME)/$$USER/symbols/nerdfonts.json
.PHONY: cleanup
## Print the version number of main programs.
versions:
@brew --version
@echo "$(PURPLE)node$(RESET) $$(node --version)"
@echo "$(PURPLE)npm$(RESET) $$(npm --version)"
@ruby --version
@echo "$(PURPLE)gem$(RESET) $$(gem --version)"
.PHONY: versions
# -----------------------------------------------------------------------------
# Target: tree structure
# -----------------------------------------------------------------------------
ENSURE_DIRS = $(XDG_CACHE_HOME)/gem \
$(XDG_CACHE_HOME)/less \
$(XDG_CACHE_HOME)/npm \
$(XDG_CACHE_HOME)/zsh \
$(XDG_CONFIG_HOME)/npm \
$(XDG_DATA_HOME)/cargo \
$(XDG_DATA_HOME)/dictionaries \
$(XDG_DATA_HOME)/fonts \
$(XDG_DATA_HOME)/gem \
$(XDG_DATA_HOME)/npm-packages \
$(XDG_STATE_HOME)/nvim/shada \
$(XDG_STATE_HOME)/nvim/swap \
$(XDG_STATE_HOME)/nvim/undo \
$(XDG_STATE_HOME)/nvim/view \
$(XDG_DATA_HOME)/tmux \
$(XDG_DATA_HOME)/zoxide \
$(HOME)/.local/bin \
$(HOME)/go/bin
## Creates the dotfiles tree structure.
setup-dirs:
@echo "$(PURPLE)• Creating directories$(RESET)"
@$(MAKE) $(ENSURE_DIRS)
.PHONY: setup-dirs
$(ENSURE_DIRS):
@mkdir -p $@
# -----------------------------------------------------------------------------
# Targets
# -----------------------------------------------------------------------------
-include include/make/$(CURRENT_OS).mk
include include/make/target-apps.mk
-include include/make/target-apps.$(CURRENT_OS).mk
include include/make/target-backup.mk
-include include/make/target-backup.$(CURRENT_OS).mk
include include/make/target-links.mk
include include/make/target-downloads.mk
-include include/make/target-downloads.$(CURRENT_OS).mk
include include/make/target-fonts.mk
-include include/make/target-fonts.$(CURRENT_OS).mk
include include/make/target-neovim.mk
-include include/make/target-neovim.$(CURRENT_OS).mk
include include/make/target-themes.mk
-include include/make/target-themes.$(CURRENT_OS).mk
-include include/make/bedrock.mk
# -----------------------------------------------------------------------------
# Target: usage and help
# credits: https://gist.github.com/prwhite/8168133#gistcomment-2278355
# -----------------------------------------------------------------------------
## Print usage and this help message.
help: SEPARATOR := |
help:
@echo ''
@echo "$(GREEN)Dotfiles management on $(CURRENT_OS)$(RESET)."
@echo ''
@echo 'Usage:'
@echo " $(PURPLE)make$(RESET) $(GREEN)<target>$(RESET)"
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z0-9_-]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf "$(PURPLE)%s$(RESET)$(SEPARATOR)%s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST) | sort | column -t -s "$(SEPARATOR)" | $(GNU_SED) "s/^/ /"
@echo ''
@echo 'Symlink targets:'
@printf " $(PURPLE)[un]%s$(RESET)\n" $(sort $(LINK_TARGETS))
.PHONY: help