-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
68 lines (56 loc) · 1.63 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 static-build release clean help run
.DEFAULT_GOAL = help
PROJECT_NAME ?= $(shell grep "^name" njusko.cabal | cut -d " " -f17)
VERSION ?= $(shell grep "^version:" njusko.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_ROOT = $(shell stack path --local-install-root)
export BINARY_PATH = $(shell echo ${BINARY_ROOT}/bin/${PROJECT_NAME})
## Build project
build:
@stack build
@echo "\nBinary available at:\n"
@echo ${BINARY_PATH}
# TODO: Doesn't work. Fix it.
# static-build: clean
# @mkdir -p release/build
# @stack ghc -- \
# app/Main.hs \
# src/Network/Njusko/Lib.hs \
# src/Network/Njusko/Options.hs \
# src/Network/Njusko/Types.hs \
# -static \
# -rtsopts=all \
# -optl-pthread \
# -optl-static \
# -O2 \
# -threaded \
# -odir release/build \
# -hidir release/build \
# -o release/${PROJECT_NAME}-${VERSION}-linux-${ARCH}
## Clean
clean:
@rm -rf release
## Cut new release
release:
@git tag ${VERSION} && git push --tags
## Helper for running locally once built
run:
@${BINARY_PATH} \
--url-file urls.txt \
--type APT \
--notify [email protected] \
--debug
## 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)