-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (43 loc) · 984 Bytes
/
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
.DEFAULT_GOAL = test
.PHONY: FORCE
# enable consistent Go 1.12/1.13 GOPROXY behavior.
export GOPROXY = https://proxy.golang.org
BINARY = dmt
ifeq ($(OS),Windows_NT)
BINARY := $(BINARY).exe
endif
# Build
build: $(BINARY)
.PHONY: build
build_race:
go build -race -o $(BINARY) ./cmd/dmt
.PHONY: build_race
clean:
rm -f $(BINARY)
.PHONY: clean
# Test
test:
go test -v -parallel 2 ./...
.PHONY: test
# Non-PHONY targets (real files)
$(BINARY): FORCE
go build -o $@ ./cmd/dmt
go.mod: FORCE
go mod tidy
go mod verify
go.sum: go.mod
# Functions
# Check that given variables are set and all have non-empty values,
# die with an error otherwise.
#
# Params:
# 1. Variable name(s) to test.
# 2. (optional) Error message to print.
#
# https://stackoverflow.com/a/10858332/8228109
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))