diff options
author | Andrew Cady <d@cryptonomic.net> | 2022-09-23 10:39:51 -0400 |
---|---|---|
committer | Andrew Cady <d@cryptonomic.net> | 2022-09-23 10:40:05 -0400 |
commit | 259cd8442ca4132257c7699076c48a9dff376ee4 (patch) | |
tree | f94babe930d06eed0814555e91ac9a35657b990a | |
parent | 563497c8b6f194415faf5cb0e97040cc1db0695c (diff) |
Makefile: automatically install stack if needed
"install-stack" target will try more methods
-rw-r--r-- | Makefile | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -1,10 +1,9 @@ | |||
1 | all: | 1 | stack_path != which stack |
2 | |||
3 | all: $(if $(stack_path),,install-stack) | ||
2 | stack build | 4 | stack build |
3 | ln -sfT $$(stack path --local-install-root)/bin ./bin | 5 | ln -sfT $$(stack path --local-install-root)/bin ./bin |
4 | 6 | ||
5 | install-stack: | ||
6 | curl -sSL https://get.haskellstack.org/ | sh | ||
7 | |||
8 | .PHONY: all run install install-dev-tools | 7 | .PHONY: all run install install-dev-tools |
9 | 8 | ||
10 | run: all | 9 | run: all |
@@ -15,3 +14,20 @@ install: | |||
15 | 14 | ||
16 | install-dev-tools: | 15 | install-dev-tools: |
17 | stack install apply-refact hlint stylish-haskell hasktags hoogle | 16 | stack install apply-refact hlint stylish-haskell hasktags hoogle |
17 | |||
18 | become_root != [ "$$(id -u)" = 0 ] || echo sudo | ||
19 | install-stack: | ||
20 | ifneq (,$(shell which curl)) | ||
21 | curl -sSL https://get.haskellstack.org/ | sh | ||
22 | else | ||
23 | ifneq (,$(shell which wget)) | ||
24 | wget -qO- https://get.haskellstack.org/ | sh | ||
25 | else | ||
26 | ifneq (,$(shell which apt)) | ||
27 | $(become_root) apt install haskell-stack | ||
28 | else | ||
29 | $(error No stack binary found; and no known means of installing (no curl, wget, or apt).\ | ||
30 | Follow instructions at <https://haskellstack.org>) | ||
31 | endif | ||
32 | endif | ||
33 | endif | ||