-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
50 lines (35 loc) · 1.16 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
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:
APP := networkqualityd
GIT_VERSION := $(shell git describe --always --long)
PKG := github.com/network-quality/goserver
LDFLAGS := -ldflags "-w -X $(PKG).GitVersion=$(GIT_VERSION)"
GO ?= go
COMMON_GO_FILES := *.go go.mod go.sum
CMD_SOURCES := $(shell find cmd -name main.go)
DEV_TARGETS := $(patsubst cmd/%/main.go,%,$(CMD_SOURCES))
all: networkqualityd
ci: networkqualityd.darwin networkqualityd.windows networkqualityd.linux
test: $(APP)
$(GO) test -cover ./...
vet:
$(GO) vet ./...
test-race: $(APP)
$(GO) test -race -cover ./...
lint:
golangci-lint run
clean:
@rm -f $(DEV_TARGETS)
%: CWD=$(PWD)
%: cmd/%/*.go $(COMMON_GO_FILES)
cd cmd/$@ && $(GO) build -o $(CWD)/$@ $(LDFLAGS) .
$(APP).darwin: GOOS=darwin
$(APP).darwin:
cd cmd/$(APP) && env GOOS=$(GOOS) $(GO) build -o $(APP).$(GOOS) $(LDFLAGS) .
$(APP).windows: GOOS=windows
$(APP).windows:
cd cmd/$(APP) && env GOOS=$(GOOS) $(GO) build -o $(APP).$(GOOS) $(LDFLAGS) .
$(APP).linux: GOOS=linux
$(APP).linux:
cd cmd/$(APP) && env GOOS=$(GOOS) $(GO) build -o $(APP).$(GOOS) $(LDFLAGS) .
.PHONY: all test vet test-race lint clean