-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (41 loc) · 956 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
56
export GO111MODULE=on
SHELL := /bin/bash
NAME = osctrld
CODE = *.go
DEST ?= /usr/local/bin
OUTPUT = bin
STATIC_ARGS = -ldflags "-linkmode external -extldflags -static"
.PHONY: build static clean
# Build code according to caller OS and architecture
build:
go build -o $(OUTPUT)/$(NAME) $(CODE)
# Build everything statically
static:
go build $(STATIC_ARGS) -o $(OUTPUT)/$(NAME) -a $(CODE)
# Delete all compiled binaries
clean:
rm -rf $(OUTPUT)/$(NAME)
# Delete all dependencies go.sum files
clean_go:
find . -name "go.sum" -type f -exec rm -rf {} \;
# Remove all unused dependencies
tidy:
make clean
make clean_go
go mod tidy
# Install everything
# optional DEST=destination_path
install:
make clean
make build
sudo cp $(OUTPUT)/$(NAME) $(DEST)
# Auto-format and simplify the code
GOFMT_ARGS = -l -w -s
gofmt:
gofmt $(GOFMT_ARGS) ./$(TLS_CODE)
# Run all tests
test:
go test . -v
# Check test coverage
test_cover:
go test -cover .