-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (71 loc) · 2.34 KB
/
Makefile
File metadata and controls
92 lines (71 loc) · 2.34 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
GO = go
GOFLAGS =
LDFLAGS = -s -w
TAGS =
PKG = ./...
SRCDIR = dnscrypt-proxy
BIN = dnscrypt-proxy
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
INSTALL = install
.PHONY: all build install uninstall test test-short test-race test-suite \
bench fmt vet tidy vendor staticcheck lint clean distclean run \
version help
all: build
help:
@echo "Available targets:"
@echo " build Build the $(BIN) binary"
@echo " install Install $(BIN) to \$$PREFIX/bin (default /usr/local/bin)"
@echo " uninstall Remove the installed binary"
@echo " test Run the full test suite"
@echo " test-short Run tests with -short"
@echo " test-race Run tests with the race detector"
@echo " test-suite Run the categorized test script (run_tests.sh)"
@echo " bench Run benchmarks"
@echo " fmt Format the code with gofmt"
@echo " vet Run go vet"
@echo " staticcheck Run staticcheck (must be installed)"
@echo " lint Run fmt, vet and staticcheck"
@echo " tidy Run go mod tidy"
@echo " vendor Refresh the vendor directory"
@echo " run Build and run the binary in place"
@echo " version Print the application version"
@echo " clean Remove build artifacts"
@echo " distclean clean + remove the vendor directory"
build:
cd $(SRCDIR) && $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -tags "$(TAGS)" -o $(BIN) .
install: build
$(INSTALL) -d $(DESTDIR)$(BINDIR)
$(INSTALL) -m 0755 $(SRCDIR)/$(BIN) $(DESTDIR)$(BINDIR)/$(BIN)
uninstall:
rm -f $(DESTDIR)$(BINDIR)/$(BIN)
test:
cd $(SRCDIR) && $(GO) test $(GOFLAGS) -tags "$(TAGS)" $(PKG)
test-short:
cd $(SRCDIR) && $(GO) test $(GOFLAGS) -short -tags "$(TAGS)" $(PKG)
test-race:
cd $(SRCDIR) && $(GO) test $(GOFLAGS) -race -tags "$(TAGS)" $(PKG)
test-suite:
cd $(SRCDIR) && sh ./run_tests.sh
bench:
cd $(SRCDIR) && $(GO) test $(GOFLAGS) -run=^$$ -bench=. -benchmem $(PKG)
fmt:
$(GO) fmt ./...
vet:
cd $(SRCDIR) && $(GO) vet $(PKG)
staticcheck:
cd $(SRCDIR) && staticcheck $(PKG)
lint: fmt vet staticcheck
tidy:
$(GO) mod tidy
vendor:
$(GO) mod vendor
run: build
cd $(SRCDIR) && ./$(BIN)
version: build
@$(SRCDIR)/$(BIN) -version
clean:
rm -f $(SRCDIR)/$(BIN)
cd $(SRCDIR) && $(GO) clean $(PKG)
distclean: clean
rm -rf vendor