Skip to content

Commit bcdddcf

Browse files
refactor: makefile
- check arch (used for linuxbrew) - call command directly with inversion operator - skip linuxbrew install on arch64 - install task via curl (instead of snap 👌 )
1 parent d504ae9 commit bcdddcf

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

Makefile

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
# ENV VARS
88
export SHELL := $(shell which sh)
9+
export ARCH := $(shell arch)
910
export UNAME := $(shell uname -s)
10-
export ASDF_VERSION := v0.13.1
11+
export ASDF_VERSION := v0.14.1
1112

1213
# check commands and OS
1314
ifeq ($(UNAME), Darwin)
@@ -26,7 +27,7 @@ RESET := $(shell tput -Txterm sgr0)
2627

2728
# Usage: $(call check_bin,command_name)
2829
define check_bin
29-
$(shell command -v $(1) 2>/dev/null)
30+
! command -v $(1) >/dev/null 2>&1
3031
endef
3132

3233
# Usage: $(call brew_install,package_name)
@@ -69,14 +70,16 @@ endif
6970

7071
brew: xcode ## install homebrew
7172
ifeq ($(UNAME), Darwin)
72-
@if [ -z "$(call check_bin,brew)" ]; then \
73+
@if $(call check_bin,brew); then \
7374
echo "Installing Homebrew..."; \
7475
/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
7576
else \
7677
echo "brew already installed."; \
7778
fi
7879
else ifeq ($(UNAME), Linux)
79-
@if [ -z "$(call check_bin,brew)" ] && [ "${ID_LIKE}" = "debian" ]; then \
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 \
8083
echo "Installing Homebrew..."; \
8184
/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
8285
else \
@@ -87,7 +90,7 @@ else
8790
endif
8891

8992
asdf: xcode ## install asdf
90-
@if [ -z "$(call check_bin,asdf)" ]; then \
93+
@if $(call check_bin,asdf); then \
9194
echo "Installing asdf..."; \
9295
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch ${ASDF_VERSION}; \
9396
echo "To use asdf, add the following to your shell rc (.bashrc/.zshrc):"; \
@@ -99,7 +102,7 @@ asdf: xcode ## install asdf
99102
fi
100103

101104
devbox: ## install devbox
102-
@if [ -z "$(call check_bin,devbox)" ]; then \
105+
@if $(call check_bin,devbox); then \
103106
echo "Installing devbox..."; \
104107
curl -fsSL https://get.jetpack.io/devbox | bash; \
105108
else \
@@ -115,8 +118,19 @@ pre-commit: brew ## install pre-commit
115118
sccache: brew ## install sccache
116119
$(call brew_install,sccache)
117120

118-
task: brew ## install taskfile
121+
task: ## install taskfile
122+
ifeq ($(UNAME), Darwin)
119123
$(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
120134

121135
help: ## show this help
122136
@echo ''

0 commit comments

Comments
 (0)