-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (52 loc) · 2.09 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
70
71
# Go itself
GOCMD=go
GOBUILD=$(GOCMD) build
GOINSTALL=$(GOCMD) install
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOMOD=$(GOCMD) mod
GOGENERATE=$(GOCMD) generate
# Flags for versioning
GGMANVERSIONFLAGS=-X 'github.com/tkw1536/ggman/constants.buildVersion=$(shell git describe --tags HEAD)' -X 'github.com/tkw1536/ggman/constants.buildTime=$(shell date +%s)'
# Binary paths
DIST_DIR=dist
BINARY_NAME=ggman
BINARY_UNIX=$(DIST_DIR)/$(BINARY_NAME)
BINARY_MACOS_INTEL=$(DIST_DIR)/$(BINARY_NAME)_mac_intel
BINARY_MACOS_SILICON=$(DIST_DIR)/$(BINARY_NAME)_mac_silicon
BINARY_MACOS_UNIVERSAL=$(DIST_DIR)/$(BINARY_NAME)_mac
BINARY_WINDOWS=$(DIST_DIR)/$(BINARY_NAME).exe
# the path to the ggman command sources
GGMAN_CMD_SRC=./cmd/ggman
# almost all the targets are phony
all: dist
.PHONY: all install test lint testdeps clean deps dist generate
$(BINARY_NAME): deps
CGO_ENABLED=0 $(GOBUILD) -ldflags="$(GGMANVERSIONFLAGS)" -o $(BINARY_NAME) $(GGMAN_CMD_SRC)
$(BINARY_UNIX): deps
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags="$(GGMANVERSIONFLAGS) -s -w" -o $(BINARY_UNIX) $(GGMAN_CMD_SRC)
$(BINARY_MACOS_INTEL): deps
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags="$(GGMANVERSIONFLAGS) -s -w" -o $(BINARY_MACOS_INTEL) $(GGMAN_CMD_SRC)
$(BINARY_MACOS_SILICON): deps
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(GOBUILD) -ldflags="$(GGMANVERSIONFLAGS) -s -w" -o $(BINARY_MACOS_SILICON) $(GGMAN_CMD_SRC)
$(BINARY_MACOS_UNIVERSAL): $(BINARY_MACOS_INTEL) $(BINARY_MACOS_SILICON)
lipo -output $(BINARY_MACOS_UNIVERSAL) -create $(BINARY_MACOS_SILICON) $(BINARY_MACOS_INTEL)
$(BINARY_WINDOWS): deps
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -ldflags="$(GGMANVERSIONFLAGS) -s -w" -o $(BINARY_WINDOWS) $(GGMAN_CMD_SRC)
dist: $(BINARY_UNIX) $(BINARY_MACOS_UNIVERSAL) $(BINARY_WINDOWS)
install:
CGO_ENABLED=0 $(GOINSTALL) -ldflags="$(GGMANVERSIONFLAGS)" $(GGMAN_CMD_SRC)
test: testdeps
$(GOTEST) -tags doccheck ./...
testdeps:
$(GOMOD) download
lint:
test -z $(shell gofmt -l .)
generate:
$(GOGENERATE) -v ./...
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -rf $(DIST_DIR)
deps:
$(GOMOD) download