forked from abstools/abstools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
75 lines (62 loc) · 2.48 KB
/
Makefile
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
.PHONY: help default frontend docker clean server
.DEFAULT_GOAL := default
# Check that given variables are set and all have non-empty values, die with
# an error otherwise. See
# https://stackoverflow.com/questions/10858261/abort-makefile-if-variable-not-set
#
# Params:
# 1. Variable name(s) to test.
# 2. (optional) Error message to print.
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))$(if $(value @), \
required by target `$@`)))
# https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile#18137056
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
ifneq (,$(findstring /cygdrive/,$(PATH)))
UNAME := Cygwin
else
ifneq (,$(findstring WINDOWS,$(PATH)))
UNAME := Windows
else
UNAME := $(shell uname -s)
endif
endif
ifeq (,$(DOCKER))
ifeq ($(UNAME), Linux)
DOCKER := "sudo docker"
else
DOCKER := docker
endif
endif
default: help frontend manual
frontend: ## Build ABS compiler (default)
$(MAKE) -C $(ROOT_DIR)/frontend
manual: ## Build the ABS manual
./gradlew asciidoc
@echo "Finished."
@echo "HTML: abs-docs/build/asciidoc/html5/index.html"
@echo "PDF: abs-docs/build/asciidoc/pdf/index.pdf"
docker: ## Build docker images for collaboratory and absc
$(DOCKER) pull erlang:24-alpine
$(DOCKER) pull php:7.4-apache-buster
$(DOCKER) build -t abslang/collaboratory -f docker/collaboratory.Dockerfile $(ROOT_DIR)
$(DOCKER) build -t abslang/absc -f docker/absc.Dockerfile $(ROOT_DIR)
@echo "Finished."
run-collaboratory: ## Run the collaboratory on port 8080
$(DOCKER) run -d -p 8080:80 --name collaboratory abslang/collaboratory
@echo "Collaboratory running on http://localhost:8080/"
server: ## Deploy development environment on Debian-based server
@:$(call check_defined, SERVER, server name or address as accepted by ssh)
ssh $(SERVER) sudo apt-get -y update
ssh $(SERVER) sudo apt-get -y install make openjdk-11-jdk openjdk-11-jre erlang maude emacs git
ssh $(SERVER) git clone https://github.com/abstools/abstools
ssh $(SERVER) make -f "~/abstools/Makefile" frontend
ssh $(SERVER) 'echo "PATH=\$$HOME/abstools/frontend/bin/bash:\$$PATH" >> ~/.bashrc'
clean: ## Remove all build artifacts
./gradlew clean
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'