6
6
7
7
# ENV VARS
8
8
export SHELL := $(shell which sh)
9
- export ARCH := $(shell arch)
10
9
export UNAME := $(shell uname -s)
11
- export ASDF_VERSION := v0.14 .1
10
+ export ASDF_VERSION := v0.13 .1
12
11
13
12
# check commands and OS
14
13
ifeq ($(UNAME ) , Darwin)
@@ -26,8 +25,9 @@ CYAN := $(shell tput -Txterm setaf 6)
26
25
RESET := $(shell tput -Txterm sgr0)
27
26
28
27
# Usage: $(call check_bin,command_name)
28
+ # Returns empty string if command not found, command path if found
29
29
define check_bin
30
- ! command -v $(1 ) >/dev/null 2>&1
30
+ $( shell which $(1 ) 2 >/dev/null)
31
31
endef
32
32
33
33
# Usage: $(call brew_install,package_name)
@@ -39,7 +39,7 @@ define brew_install
39
39
"go-task") binary_name="task" ;; \
40
40
*) binary_name="$(1 ) " ;; \
41
41
esac; \
42
- if [ -z " $( call check_bin,$$ binary_name) " ] ; then \
42
+ if ! command -v $$ binary_name >/dev/null 2>&1 ; then \
43
43
echo "Installing $(1 ) ..."; \
44
44
brew install $(1 ) ; \
45
45
else \
52
52
53
53
# targets
54
54
.PHONY : all
55
- all : help install # # run all targets
56
-
57
- install : xcode asdf brew devbox jq pre-commit sccache task # # install dependencies
55
+ all : help asdf xcode brew jq pre-commit sccache task yq # # run all targets
58
56
59
57
xcode : # # install xcode command line tools
60
58
ifeq ($(UNAME ) , Darwin)
@@ -70,27 +68,34 @@ endif
70
68
71
69
brew : xcode # # install homebrew
72
70
ifeq ($(UNAME ) , Darwin)
73
- @if $(call check_bin, brew) ; then \
71
+ @if ! command -v brew >/dev/null 2>&1 ; then \
74
72
echo "Installing Homebrew..."; \
75
73
/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
76
74
else \
77
75
echo "brew already installed."; \
78
76
fi
79
77
else ifeq ($(UNAME), Linux)
80
- @if [ "$(ARCH)" = "aarch64" ]; then \
81
- echo "Homebrew on Linux is not supported on ARM processors."; \
82
- elif $(call check_bin,brew) && [ "$(ID_LIKE)" = "debian" ]; then \
83
- echo "Installing Homebrew..."; \
84
- /bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
78
+ @if [ "${ID_LIKE}" = "debian" ]; then \
79
+ if ! command -v brew >/dev/null 2>&1; then \
80
+ echo "Installing Homebrew..."; \
81
+ /bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
82
+ echo ""; \
83
+ echo "To add Homebrew to your PATH, run these commands:"; \
84
+ echo 'eval "$$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'; \
85
+ echo 'Add to ~/.profile or ~/.bashrc:'; \
86
+ echo 'eval "$$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'; \
87
+ else \
88
+ echo "brew already installed."; \
89
+ fi \
85
90
else \
86
- echo "brew already installed ."; \
91
+ echo "brew not supported on this Linux distribution ."; \
87
92
fi
88
93
else
89
94
@echo "brew not supported."
90
95
endif
91
96
92
97
asdf : xcode # # install asdf
93
- @if $( call check_bin, asdf) ; then \
98
+ @if ! command -v asdf > /dev/null 2>&1 ; then \
94
99
echo " Installing asdf..." ; \
95
100
git clone https://github.com/asdf-vm/asdf.git ~ /.asdf --branch ${ASDF_VERSION} ; \
96
101
echo " To use asdf, add the following to your shell rc (.bashrc/.zshrc):" ; \
@@ -101,14 +106,6 @@ asdf: xcode ## install asdf
101
106
echo " asdf already installed." ; \
102
107
fi
103
108
104
- devbox : # # install devbox
105
- @if $(call check_bin,devbox) ; then \
106
- echo " Installing devbox..." ; \
107
- curl -fsSL https://get.jetpack.io/devbox | bash; \
108
- else \
109
- echo " devbox already installed." ; \
110
- fi
111
-
112
109
jq : brew # # install jq
113
110
$(call brew_install,jq)
114
111
@@ -118,19 +115,13 @@ pre-commit: brew ## install pre-commit
118
115
sccache : brew # # install sccache
119
116
$(call brew_install,sccache)
120
117
121
- task : # # install taskfile
122
- ifeq ($(UNAME ) , Darwin)
118
+ task : brew # # install taskfile
123
119
$(call brew_install,go-task)
124
- else ifeq ($(UNAME), Linux)
125
- @if $(call check_bin,task); then \
126
- echo "Installing task..."; \
127
- sh -c "$$(curl -sl https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin; \
128
- else \
129
- echo "task already installed."; \
130
- fi
131
- else
132
- @echo "task installation not supported on this OS."
133
- endif
120
+
121
+ yq : brew # # install yq
122
+ $(call brew_install,yq)
123
+
124
+ install : xcode asdf brew jq pre-commit sccache task yq # # install dependencies
134
125
135
126
help : # # show this help
136
127
@echo ' '
0 commit comments