-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
85 lines (75 loc) · 2.49 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
export
DOTPATH ?= $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
XDG_CONFIG_HOME ?= $(HOME)/.config
XDG_CACHE_HOME ?= $(HOME)/.cache
XDG_DATA_HOME ?= $(HOME)/.local/share
XDG_STATE_HOME ?= $(HOME)/.local/state
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show targets in this Makefile
ifeq ($(TARGET),)
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[m %s\n", $$1, $$2}'
@echo 'Please run `$(MAKE) help TARGET=<target>` to see more detail of each of the targets.'
else
@awk -v TARGET=$(TARGET) \
'BEGIN {found = 0}; /^[^\t#]|^$$/ {found = $$1 == TARGET ":" || (found && $$1 ~ /^(if|else|endif)/)}; found' \
$(MAKEFILE_LIST)
endif
.PHONY: init
init: ## Initialize enviroment settings
mkdir -p $(XDG_CONFIG_HOME)
mkdir -p $(XDG_CACHE_HOME)
mkdir -p $(XDG_STATE_HOME)
mkdir -p $(XDG_DATA_HOME)
mkdir -p $(HOME)/.local/bin
mkdir -p $(HOME)/Develops
.PHONY: deploy
deploy: ## Create symlinks to actual directories
@echo 'Deploying dotfiles...'
@$(DOTPATH)/scripts/link.sh link
.PHONY: update
update: ## Fetch and rebase all changes from remote repository
@echo 'Updating dotfiles...'
ifneq ($(shell git rev-parse --abbrev-ref HEAD),main)
ifneq ($(FETCH_FROM_MAIN),)
git stash
git switch -m main
endif
endif
git fetch origin
git rebase --autostash --stat FETCH_HEAD
ifneq ($(shell git rev-parse --abbrev-ref HEAD),main)
ifneq ($(FETCH_FROM_MAIN),)
git switch -m -
git stash pop
git rebase --autostash --stat main
endif
endif
.PHONY: install
install: update init deploy ## Initialize and deploy dotfiles
@echo 'Please run `exec $$SHELL -l` to reload shell.'
.PHONY: clean
clean: ## Remove symlinks from actual directories
@echo 'Cleaning dotfiles...'
@$(DOTPATH)/scripts/link.sh unlink
.PHONY: python
python: ## Install and initialize python enviroments
python3 -m venv $(XDG_DATA_HOME)/poetry
$(XDG_DATA_HOME)/poetry/bin/python -m pip install poetry
cd $(XDG_CONFIG_HOME)/python; \
$(XDG_DATA_HOME)/poetry/bin/poetry install
.PHONY: aqua
aqua: ## Install and initialize aqua enviroments
ifeq ($(shell command -v aqua),)
curl -sSfL https://raw.githubusercontent.com/aquaproj/aqua-installer/v3.1.1/aqua-installer | bash -s -- -v v2.42.2
else
aqua update-aqua
endif
$${AQUA_ROOT_DIR:-$$XDG_DATA_HOME/aquaproj-aqua}/bin/aqua install --all
.PHONY: rust
rust: ## Install and initialize rust enviroments
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
rustup update nightly
rustup default nightly