-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (57 loc) · 1.54 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
.PHONY: build run static-build clean release
.DEFAULT_GOAL = help
PROJECT_NAME ?= $(shell grep "^name" s2hl.cabal | cut -d " " -f17)
VERSION ?= $(shell grep "^version:" s2hl.cabal | cut -d " " -f14)
RESOLVER ?= $(shell grep "^resolver:" stack.yaml | cut -d " " -f2)
GHC_VERSION ?= $(shell stack ghc -- --version | cut -d " " -f8)
ARCH=$(shell uname -m)
export BINARY_PATH = `stack path --local-install-root`/bin/${PROJECT_NAME}
BINARY_NAME = ${PROJECT_NAME}-exe
## Build binary
build:
@stack build
@echo "\nBinary available at:\n"
@echo ${BINARY_PATH}
## Helper for local testing
run:
@${BINARY_PATH} \
--statements-dir `pwd`/statements \
--output-dir `pwd`/out \
--currency USD \
--currency HRK \
--debug
## Build static binary
static-build: clean
@mkdir -p release/build
@stack ghc -- \
app/Main.hs \
src/S2HL/Lib.hs \
src/S2HL/Options.hs \
src/S2HL/Types.hs \
-static \
-rtsopts=all \
-optl-pthread \
-optl-static \
-O2 \
-threaded \
-odir release/build \
-hidir release/build \
-o release/${BINARY_NAME}-${VERSION}-linux-${ARCH}
## Clean
clean:
@rm -rf release
## Cut new release
release:
@git tag ${VERSION} && git push --tags
## Show help screen.
help:
@echo "Please use \`make <target>' where <target> is one of\n\n"
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf "%-30s %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)