-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (68 loc) · 2.65 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
CONFIG_PATH ?= ${HOME}/.config/
VIM := $(addprefix ${CONFIG_PATH}, $(shell find nvim -type f -print))
ZSH := $(addprefix ${CONFIG_PATH}, $(shell find zsh -type f -print))
MAC := $(CONFIG_PATH)mac/setup.sh
GIT := ${HOME}/.gitconfig
BREW := $(HOME)/Brewfile
NODE := $(CONFIG_PATH)/node/globals
# helper function to create target directory
CREATE_TARGET_DIR= if [ ! -d "$(@D)" ]; then mkdir -p "$(@D)" && echo "'$(@D)' created.";fi;
.PHONY: vim zsh mac brew git node help
.DEFAULT_GOAL := help
define PRINT_HELP_PROLOGUE
+-----------------------------------------------------------------------------+
| This Makefile should work in most shell environments. |
| But it was only tested on Mac running with Apple sillicon. |
+--------------------+--------------------------------------------------------+
| commands: | description: |
+--------------------+--------------------------------------------------------+
endef
export PRINT_HELP_PROLOGUE
## The following lines
vim: $(VIM) ;@ ## Install neovim configuration
.SECONDEXPANSION:
$(VIM): $$(subst ${CONFIG_PATH},, $$@)
@$(call CREATE_TARGET_DIR)
@if [ ! -d $< ]; then \
echo "Including '${^}' configuration to '${@}'" ;\
cp $< $@ ;\
fi
## The following lines
zsh: $(ZSH) ;@ ## Configure zsh default alias, functions and etc.
.SECONDEXPANSION:
$(ZSH): $$(subst ${CONFIG_PATH},, $$@)
@$(call CREATE_TARGET_DIR)
@printf "Moving '${^F}' to '${@}'"
@cp "${^}" "${@}"
@. zsh/functions.sh && inject '${CONFIG_PATH}${^}' \
&& echo " - injected" \
|| echo " - already injected"
## The following lines
mac: $(MAC) ;@ ## Configure mac settings
$(MAC): $$(subst ${CONFIG_PATH},, $$@)
@$(call CREATE_TARGET_DIR)
@cp -f ${^} ${@}
@${@} || :
## The following lines
brew: $(BREW);@ ## Install brew packages
$(BREW): brew/Brewfile
@./brew/install.sh
@source ./brew/shellenv.sh && brew bundle --file=$(@) --force && ./setup.sh
@cp -f $(^) $(@)
## The following lines
git: $(GIT); ## Install git configuration
$(GIT): $(wildcard git/*)
@source ./git/setup.sh || :
## The following lines
node: $(NODE);@ ## Install nvm, node lts and global packages
$(NODE): node/globals
@./node/install.sh
@mkdir -p "${@}"
@cp -f "${^}" "${@}"
## Install all configurations
all: | mac zsh brew node git vim
# https://michaelgoerz.net/notes/self-documenting-makefiles.html
help: ## Show this help
@echo "$$PRINT_HELP_PROLOGUE"
@grep -E '^([a-zA-Z_-]+):.*## ' $(MAKEFILE_LIST) | awk -F ':.*## ' '{gsub(/^[ \t]+/, "", $$2);printf "| %-19s| %-55s|\n", $$1, $$2}'
@printf "+%20s+%-56s+\n" | tr ' ' '-'