-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (58 loc) · 1.52 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
ARCH=$(shell uname -m)
UNAME=$(shell uname | tr 'A-Z' 'a-z')
ifeq ($(UNAME), msys_nt-10.0-20348)
BDC_BINARY=C:\cabal\bin\BDC.exe
else
BDC_BINARY=$(HOME)/.cabal/bin/BDC
endif
BDC_TAG=v$(shell sed -n 's/^version: *//p' *.cabal)
BDC_PACKAGE=BDC-$(BDC_TAG)-$(UNAME)-$(ARCH)
UPX_VERSION=3.94
UPX_NAME=upx-$(UPX_VERSION)-amd64_$(UNAME)
UPX_BINARY=$(HOME)/.cabal/bin/upx
ifeq ($(UNAME), linux)
ARCHIVE=tar.gz
ARCHIVE_CREATE=tar czf
ARCHIVE_EXTRACT=tar xvzf
else
ARCHIVE=zip
ARCHIVE_CREATE=zip -r
ARCHIVE_EXTRACT=unzip
endif
ifeq ($(UNAME), linux)
COMPRESS_BIN_DEPS=$(UPX_BINARY)
COMPRESS_BIN=upx
else
COMPRESS_BIN_DEPS=
COMPRESS_BIN=ls
endif
CABAL=cabal
# Default target.
.PHONY: build
build: $(BDC_BINARY)
# When we want to do a release.
.PHONY: artifact
artifact: $(BDC_PACKAGE).$(ARCHIVE)
mkdir -p artifacts
cp $(BDC_PACKAGE).$(ARCHIVE) artifacts/
$(BDC_PACKAGE).$(ARCHIVE): $(BDC_BINARY) $(COMPRESS_BIN_DEPS)
mkdir -p $(BDC_PACKAGE)
cp $(BDC_BINARY) $(BDC_PACKAGE)/
$(COMPRESS_BIN) $(BDC_PACKAGE)/BDC
cp ChangeLog.md $(BDC_PACKAGE)/
cp LICENSE $(BDC_PACKAGE)/
cp -r data $(BDC_PACKAGE)/
$(ARCHIVE_CREATE) $(BDC_PACKAGE).$(ARCHIVE) $(BDC_PACKAGE)
$(BDC_BINARY):
$(CABAL) install
# UPX is used to compress the resulting binary. We currently don't use this on
# Mac OS.
$(UPX_BINARY):
curl -Lo /tmp/$(UPX_NAME).tar.xz \
https://github.com/upx/upx/releases/download/v$(UPX_VERSION)/$(UPX_NAME).tar.xz
cd /tmp && tar xf $(UPX_NAME).tar.xz
mv /tmp/$(UPX_NAME)/upx $(UPX_BINARY)
upx --version
.PHONY: test
test:
cabal build --test