-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
193 lines (152 loc) · 6.31 KB
/
Makefile
File metadata and controls
193 lines (152 loc) · 6.31 KB
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
.DEFAULT_GOAL:=help
SHELL:=/bin/zsh
XDG_CACHE_HOME := $(HOME)/.cache
XDG_CONFIG_HOME := $(HOME)/.config
XDG_DATA_HOME := $(HOME)/.local/share
XDG_STATE_HOME := $(HOME)/.local/state
XDG_RUNTIME_DIR ?= $(or $(TMPDIR),/tmp)
ZDOTDIR := $(XDG_CONFIG_HOME)/zsh
export XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_STATE_HOME XDG_RUNTIME_DIR ZDOTDIR
BREW_PATHS := /opt/homebrew/bin:/usr/local/bin:/home/linuxbrew/.linuxbrew/bin
export PATH := $(BREW_PATHS):$(PATH)
BREW = $(firstword $(wildcard /opt/homebrew/bin/brew /usr/local/bin/brew /home/linuxbrew/.linuxbrew/bin/brew))
BREW_BIN := $(BREW_PREFIX)/bin/brew
.PHONY: all
cwd := $(shell pwd)
UNAME_S := $(shell uname -s)
IS_DARWIN := $(if $(filter Darwin,$(UNAME_S)),1,0)
##@ Install
install: detect-os ## Install all the things
install-macos: macos cfg zsh homebrew-bundle neovim -fonts bat ## Install for macOS
install-linux: cfg zsh-linux homebrew-bundle neovim-linux ## Install for Linux
clean: cfg-clean neovim-clean ohmyzsh-clean zsh-clean homebrew-clean ## Uninstall all the things
detect-os: ## Detect OS and run appropriate install
ifeq ($(IS_DARWIN), 1)
@$(MAKE) install-macos
else
@$(MAKE) install-linux
endif
cfg: ## Link configuration files
@[ -e $$HOME/.config ] || ln -s $(cwd)/xdg_config $$HOME/.config
@[ -e $$HOME/bin ] || ln -sf $(cwd)/bin $$HOME/bin
cfg-clean: ## Clean (rm) XDG directories
rm -rf $(XDG_CONFIG_HOME) $(XDG_CACHE_HOME) $(XDG_DATA_HOME) $(XDG_STATE_HOME)
rm $$HOME/bin
##@ Homebrew
homebrew: ## Install homebrew
@if [ -n "$(BREW)" ]; then \
echo "Homebrew already installed"; \
else \
echo "Installing Homebrew..."; \
NONINTERACTIVE=1 /bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
fi
eval "$$($(BREW_BIN) shellenv)"
$(BREW_BIN) bundle --file "$(BREWFILE)"
homebrew-bundle: homebrew ## Install default homebrew formulae.(Slow in Docker!)
@if [ -z "$(BREW)" ]; then \
echo "Homebrew not found"; exit 1; \
fi; \
eval "$$($(BREW) shellenv)" && $(BREW) bundle
homebrew-clean: ## Uninstall homebrew
sudo curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh | /bin/bash
rm -r /usr/local/var/homebrew
##@ Neovim
NEOVIM_SRC_DIR := "$$HOME/work/neovim/neovim"
NEOVIM_CFG_DIR := "$(XDG_CONFIG_HOME)/nvim"
neovim: neovim-clone-or-pull /usr/local/bin/nvim neovim-install-plugins ## Install Neovim
neovim-linux: ## Install Neovim for Linux (use system package)
@echo "Using system neovim. Install plugins manually with: nvim --headless +Lazy! sync +qa"
neovim-clone-or-pull: ## Clone neovim, or pull the latest
@mkdir -p $$(dirname $(NEOVIM_SRC_DIR))
@if [ -d $(NEOVIM_SRC_DIR) ]; then \
git -C $(NEOVIM_SRC_DIR) pull; \
else \
git clone https://github.com/neovim/neovim.git $(NEOVIM_SRC_DIR); \
fi; \
/usr/local/bin/nvim: ## Install neovim from source
@if [ -z "$(BREW)" ]; then \
echo "Homebrew not found"; exit 1; \
fi
@for pkg in cmake automake ninja; do \
if ! which $$pkg >/dev/null; then \
$(BREW) install $$pkg; \
fi; \
done; \
$(MAKE) -C $(NEOVIM_SRC_DIR) CMAKE_BUILD_TYPE=RelWithDebInfo; \
sudo $(MAKE) -C $(NEOVIM_SRC_DIR) CMAKE_INSTALL_PREFIX=/usr/local install
neovim-plugins: /usr/local/bin/nvim ## Install Neovim plugins
@nvim --headless +Lazy! sync +qa
neovim-clean: ## Uninstall neovim
-sudo rm /usr/local/bin/nvim
-sudo rm /usr/local/bin/vi
-sudo rm -r /usr/local/lib/nvim
-sudo rm -r /usr/local/share/nvim
##@ Languages
mise: homebrew-bundle ## Install all languages configured for mise to handle
mise install
##@ zsh
zsh: zsh-cfg ohmyzsh ## Install zsh-related items
zsh-linux: zsh-cfg ## Install zsh for Linux (skip Oh My Zsh)
zsh-clean: zsh-cfg-clean ## Uninstall zsh-related items
zsh-cfg: ## Link ~/.zshenv
ln -sf $(cwd)/.zshenv $$HOME/.zshenv
ln -sf $(cwd)/.zshrc $$HOME/.zshrc
ohmyzsh: xdg-setup ## Install Oh My Zsh
@if [ -d "$(XDG_STATE_HOME)/ohmyzsh" ]; then \
echo "Oh My Zsh already installed"; \
else \
CHSH=no KEEP_ZSHRC=yes RUNZSH=no ZSH=$(XDG_STATE_HOME)/ohmyzsh sh -c "$$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" --unattended; \
fi
ohmyzsh-clean: ## Uninstall Oh My Zsh
@if [ -d "$(XDG_STATE_HOME)/ohmyzsh" ]; then \
rm -rf $(XDG_STATE_HOME)/ohmyzsh; \
else \
echo "Oh My Zsh not found in $(XDG_STATE_HOME)"; \
fi
zsh-cfg-clean: ## Unlink ~/.zshenv
rm $$HOME/.zshenv
##@ Misc
XCODE_INSTALLED := $(shell [ "$(IS_DARWIN)" = "1" ] && xcode-select -p 1>/dev/null; echo $$?)
macos: ## Set macOS defaults and install XCode command line developer tools
ifeq ($(IS_DARWIN), 1)
ifeq ($(XCODE_INSTALLED), 1)
xcode-select --install
endif
softwareupdate --install --recommended
./macos
killall Dock
endif
bat: ## Get TokyoNight theme for bat
mkdir -p "$$(bat --config-dir)/themes"
# Replace _night in the lines below with _day, _moon, or _storm if needed.
curl -H "Accept: application/xml" -O https://raw.githubusercontent.com/folke/tokyonight.nvim/main/extras/sublime/tokyonight_night.tmTheme --output-dir "$$(bat --config-dir)/themes"
bat cache --build
fonts: ## Install fonts
@if [ -z "$(BREW)" ]; then \
echo "Homebrew not found"; exit 1; \
fi; \
$(BREW) install font-space-mono-nerd-font
$(BREW) install font-blex-mono-nerd-font
$(BREW) install font-source-code-pro-for-powerline
## Font used with toilet banner generator
cp cosmic.flf $$HOMEBREW_CELLAR/toilet/0.3/share/figlet
ssh-cfg: ## Install ssh related files
@[ -d $$HOME/.ssh ] || mkdir $$HOME/.ssh
ssh-add-key: -ssh ## Add key to SSH agent
ssh-add -K ~/.ssh/id_ed25519
misc-cfg: ripgrep-cfg lazygit-cfg ## Miscellany
@[ -e $$HISTFILE ] || touch $$HISTFILE
misc-cfg-clean: ripgrep-cfg-clean lazygit-cfg-clean ## Unlink misc configs
xdg-setup: ## Create standard XDG Base Directory Specification directories
@[ -d $(XDG_CONFIG_HOME) ] || mkdir -p $(XDG_CONFIG_HOME)
@[ -d $(XDG_CACHE_HOME) ] || mkdir -p $(XDG_CACHE_HOME)
@[ -d $(XDG_DATA_HOME) ] || mkdir -p $(XDG_DATA_HOME)
@[ -d $(XDG_STATE_HOME) ] || mkdir -p $(XDG_STATE_HOME)
@if [ "$(IS_DARWIN)" != "1" ]; then \
[ -d $(XDG_RUNTIME_DIR) ] || mkdir -p $(XDG_RUNTIME_DIR); \
fi
##@ Helpers
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m\t%s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
-%:
-@$(MAKE) $*