From 259cd8442ca4132257c7699076c48a9dff376ee4 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Fri, 23 Sep 2022 10:39:51 -0400 Subject: Makefile: automatically install stack if needed "install-stack" target will try more methods --- Makefile | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b082c3d..1303b5e 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,9 @@ -all: +stack_path != which stack + +all: $(if $(stack_path),,install-stack) stack build ln -sfT $$(stack path --local-install-root)/bin ./bin -install-stack: - curl -sSL https://get.haskellstack.org/ | sh - .PHONY: all run install install-dev-tools run: all @@ -15,3 +14,20 @@ install: install-dev-tools: stack install apply-refact hlint stylish-haskell hasktags hoogle + +become_root != [ "$$(id -u)" = 0 ] || echo sudo +install-stack: +ifneq (,$(shell which curl)) + curl -sSL https://get.haskellstack.org/ | sh +else +ifneq (,$(shell which wget)) + wget -qO- https://get.haskellstack.org/ | sh +else +ifneq (,$(shell which apt)) + $(become_root) apt install haskell-stack +else + $(error No stack binary found; and no known means of installing (no curl, wget, or apt).\ + Follow instructions at ) +endif +endif +endif -- cgit v1.2.3