-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
163 lines (143 loc) Β· 7.15 KB
/
Copy pathMakefile
File metadata and controls
163 lines (143 loc) Β· 7.15 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
SHELL := /bin/bash
DOTFILES := $(shell pwd)
HOMEBREW_PREFIX := $(or $(shell /opt/homebrew/bin/brew --prefix 2>/dev/null),$(shell /usr/local/bin/brew --prefix 2>/dev/null),$(if $(filter arm%,$(shell uname -m)),/opt/homebrew,/usr/local))
# Require Xcode Command Line Tools
ifeq ($(shell xcode-select -p 2>/dev/null),)
$(error Xcode Command Line Tools not found. Install with: xcode-select --install)
endif
# Colors
BLUE := \033[00;34m
GREEN := \033[00;32m
RED := \033[0;31m
YELLOW := \033[0;33m
RESET := \033[0m
define INFO
@printf " [ $(BLUE)..$(RESET) ] $(1)\n"
endef
define OK
@printf " [ $(GREEN)OK$(RESET) ] $(1)\n"
endef
define FAIL
@printf " [$(RED)FAIL$(RESET)] $(1)\n"
endef
define BANNER
@echo ""
@echo ""
@echo "βββββββ βββββββ βββββββββββββββββββββββ ββββββββββββββββ"
@echo "ββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββ"
@echo "βββ ββββββ βββ βββ ββββββ ββββββ ββββββ ββββββββ"
@echo "βββ ββββββ βββ βββ ββββββ ββββββ ββββββ ββββββββ"
@echo "βββββββββββββββββ βββ βββ βββββββββββββββββββββββββββ"
@echo "βββββββ βββββββ βββ βββ βββββββββββββββββββββββββββ"
@echo " "
@echo "βββββββ βββ βββ ββββ ββββββ βββββββ βββ βββββββ "
@echo "ββββββββββββ ββββ βββββ ββββββ ββββββββ ββββββββββββ "
@echo "ββββββββ βββββββ ββββββ ββββββ βββββββββ ββββββ βββ "
@echo "ββββββββ βββββ βββββββββββββ ββββββββββββββββ βββ "
@echo "ββββββββ βββ βββ ββββββββββββββββββ βββββββββββββββ "
@echo "βββββββ βββ βββ βββββ βββββββ βββ βββββ βββββββ "
@echo ""
@echo ""
endef
.PHONY: all link brew native-installs node python vim macos hostname gitsetup clean help
all: ## Full install
@$(MAKE) --no-print-directory banner
@$(MAKE) --no-print-directory link
@$(MAKE) --no-print-directory brew
@$(MAKE) --no-print-directory gitsetup
@$(MAKE) --no-print-directory node
@$(MAKE) --no-print-directory python
@$(MAKE) --no-print-directory native-installs
@$(MAKE) --no-print-directory vim
@$(MAKE) --no-print-directory hostname
@$(MAKE) --no-print-directory macos
@echo ""
@printf " $(GREEN)Installation completed! Have fun! π₯$(RESET)\n"
@echo ""
banner:
$(BANNER)
@printf " $(GREEN)Here we go! π$(RESET)\n"
@echo ""
help: ## Show targets
$(BANNER)
@echo " Usage: make [target]"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-12s %s\n", $$1, $$2}'
@echo ""
link: ## Create symlinks and directories
$(call INFO,Creating directories...)
@mkdir -p $(HOME)/workspace
@mkdir -p $(HOME)/.local/bin
$(call INFO,Creating symlinks...)
@ln -sf $(DOTFILES)/zshrc $(HOME)/.zshrc
@ln -sf $(DOTFILES)/git/gitconfig $(HOME)/.gitconfig
@ln -sf $(DOTFILES)/git/gitignore $(HOME)/.gitignore
@ln -sf $(DOTFILES)/git/gitmessage $(HOME)/.gitmessage
@ln -sf $(DOTFILES)/vim/vimrc $(HOME)/.vimrc
@ln -sf $(DOTFILES)/vim/vimrc.bundles $(HOME)/.vimrc.bundles
@ln -sf $(DOTFILES)/macos/hushlogin $(HOME)/.hushlogin
$(call OK,Symlinks created)
brew: ## Install Homebrew packages
$(call INFO,Installing Homebrew packages...)
@command -v brew >/dev/null || /bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@$(HOMEBREW_PREFIX)/bin/brew bundle --file $(DOTFILES)/Brewfile
$(call OK,Homebrew packages installed)
node: ## Install Node.js via n
$(call INFO,Installing Node.js...)
@N_PREFIX=$(HOME)/.n $(HOMEBREW_PREFIX)/bin/n latest
$(call OK,Node.js installed)
python: ## Install Python via pyenv
$(call INFO,Installing Python...)
@$(HOMEBREW_PREFIX)/bin/pyenv install -s 3.13
@$(HOMEBREW_PREFIX)/bin/pyenv global 3.13
$(call OK,Python 3.13 installed)
native-installs: ## Run native shell installers
$(call INFO,Running native installers...)
@$(DOTFILES)/native-installs.sh
$(call OK,Native installers completed)
vim: ## Install vim plugins
$(call INFO,Installing Vim plugins...)
@test -f $(HOME)/.vim/autoload/plug.vim || \
curl -fLo $(HOME)/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
@vim +PlugInstall +qa
$(call OK,Vim plugins installed)
macos: ## Apply macOS defaults
$(call INFO,Applying macOS defaults...)
@$(DOTFILES)/macos/defaults.sh
$(call OK,macOS defaults applied. Some changes require logout/restart.)
hostname: ## Set computer name
ifeq ($(CI),true)
@printf " [ $(YELLOW)SKIP$(RESET) ] hostname (CI environment)\n"
else
$(call INFO,Setting computer name...)
@read -p " Enter computer name: " name; \
if [ -z "$$name" ]; then printf " [$(RED)FAIL$(RESET)] No name provided\n"; exit 1; fi; \
if echo "$$name" | grep -qvE '^[a-zA-Z0-9-]+$$'; then printf " [$(RED)FAIL$(RESET)] Name must be alphanumeric with hyphens only\n"; exit 1; fi; \
sudo scutil --set ComputerName "$$name"; \
sudo scutil --set HostName "$$name"; \
sudo scutil --set LocalHostName "$$name"; \
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$$name"
$(call OK,Computer name set)
endif
gitsetup: ## Configure git identity
ifeq ($(CI),true)
@printf " [ $(YELLOW)SKIP$(RESET) ] gitsetup (CI environment)\n"
else
$(call INFO,Setting up git identity...)
@test -f $(HOME)/.gitconfig.local && \
printf " [ $(GREEN)OK$(RESET) ] gitconfig.local already exists. Skipping.\n" || \
(read -p " Git name: " name; read -p " Git email: " email; \
sed -e "s/AUTHORNAME/$$name/g" -e "s/AUTHOREMAIL/$$email/g" \
$(DOTFILES)/git/gitconfig.local.example > $(HOME)/.gitconfig.local && \
printf " [ $(GREEN)OK$(RESET) ] Git identity configured\n")
$(call INFO,Setting up GitHub CLI...)
@$(HOMEBREW_PREFIX)/bin/gh auth status &>/dev/null && printf " [ $(GREEN)OK$(RESET) ] GitHub CLI already authenticated\n" || $(HOMEBREW_PREFIX)/bin/gh auth login
@$(HOMEBREW_PREFIX)/bin/gh auth setup-git
endif
clean: ## Remove symlinks
$(call INFO,Removing symlinks...)
@rm -f $(HOME)/.zshrc $(HOME)/.gitconfig $(HOME)/.gitignore \
$(HOME)/.gitmessage $(HOME)/.vimrc $(HOME)/.vimrc.bundles \
$(HOME)/.hushlogin
$(call OK,Symlinks removed)