generated from pythoninthegrasses/mvp
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
140 lines (124 loc) · 3.74 KB
/
Makefile
File metadata and controls
140 lines (124 loc) · 3.74 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
#!/usr/bin/make -f
.DEFAULT_GOAL := help
.ONESHELL:
# ENV VARS
export SHELL := $(shell which sh)
export UNAME := $(shell uname -s)
export ASDF_VERSION := v0.13.1
# check commands and OS
ifeq ($(UNAME), Darwin)
export XCODE := $(shell xcode-select -p 2>/dev/null)
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK := 1
else ifeq ($(UNAME), Linux)
include /etc/os-release
endif
export ASDF := $(shell command -v asdf 2>/dev/null)
export BREW := $(shell command -v brew 2>/dev/null)
export DEVBOX := $(shell command -v devbox 2>/dev/null)
export GIT := $(shell command -v git 2>/dev/null)
export PRE_COMMIT := $(shell command -v pre-commit 2>/dev/null)
export TASK := $(shell command -v task 2>/dev/null)
# colors
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
# targets
.PHONY: all
all: help asdf xcode brew devbox pre-commit task ## run all targets
xcode: ## install xcode command line tools
ifeq ($(UNAME), Darwin)
@if [ -z "${XCODE}" ]; then \
echo "Installing Xcode command line tools..."; \
xcode-select --install; \
else \
echo "xcode already installed."; \
fi
else
@echo "xcode not supported."
endif
brew: xcode ## install homebrew
ifeq ($(UNAME), Darwin)
@if [ -z "${BREW}" ]; then \
echo "Installing Homebrew..."; \
/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
else \
echo "brew already installed."; \
fi
else
@echo "brew not supported."
endif
devbox: ## install devbox
@if [ -z "${DEVBOX}" ]; then \
echo "Installing devbox..."; \
curl -fsSL https://get.jetpack.io/devbox | bash; \
else \
echo "devbox already installed."; \
fi
asdf: xcode ## install asdf
ifeq ($(UNAME), Darwin)
@if [ -z "${ASDF}" ]; then \
echo "Installing asdf..."; \
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch ${ASDF_VERSION}; \
echo "To use asdf, add the following to your shell rc (.bashrc/.zshrc):"; \
echo "export PATH=\"$$HOME/.asdf/shims:$$PATH\""; \
echo ". $$HOME/.asdf/asdf.sh"; \
echo ". $$HOME/.asdf/completions/asdf.bash"; \
else \
echo "asdf already installed."; \
fi
endif
git: ## install git
@if [ -n "${GIT}" ]; then \
echo "git already installed."; \
exit 0; \
fi
if [ "${UNAME}" = "Darwin" ] && [ -n "${BREW}" ]; then \
brew install git; \
elif [ "${ID}" = "ubuntu" ] || [ "${ID_LIKE}" = "debian" ]; then \
sudo apt install -y git; \
else \
echo "Uncaught error"; \
fi
pre-commit: ## install pre-commit
@if [ -n "${PRE_COMMIT}" ]; then \
echo "pre-commit already installed."; \
exit 0; \
fi
@if [ "${UNAME}" = "Darwin" ] && [ -n "${BREW}" ]; then \
brew install pre-commit; \
elif [ "${ID}" = "ubuntu" ] || [ "${ID_LIKE}" = "debian" ]; then \
python3 -m pip install pre-commit; \
else \
echo "Uncaught error"; \
fi
task: ## install taskfile
ifeq ($(UNAME), Darwin)
@if [ -z "${TASK}" ] && [ ! -z "${BREW}" ]; then \
echo "Installing taskfile..."; \
brew install go-task; \
else \
echo "taskfile already installed."; \
fi
else ifeq ($(UNAME), Linux)
@if [ -z "${TASK}" ] && [ "${ID_LIKE}" = "debian" ]; then \
echo "Installing taskfile..."; \
sudo snap install task --classic; \
else \
echo "taskfile already installed."; \
fi
else
@echo "taskfile not supported."
endif
install: xcode asdf brew devbox pre-commit task ## install dependencies
help: ## show this help
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)