-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathmakefile
More file actions
50 lines (37 loc) · 1.09 KB
/
Copy pathmakefile
File metadata and controls
50 lines (37 loc) · 1.09 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
.POSIX:
.PHONY: all build test fmt vet cross-build major-release minor-release patch-release install uninstall clean
VERSION = $(shell git describe --tags)
GO = go
GOFLAGS = -trimpath -tags netgo,osusergo -ldflags="-w -s -X main.progVersion=$(VERSION)"
RELEASE = ./release
PREFIX = /usr/local
PROGNAME = ytcast
CROSSTARGETS = linux-386 linux-amd64 linux-arm linux-arm64 darwin-amd64 darwin-arm64 windows-386 windows-amd64 windows-arm64
all: fmt vet test build
build:
$(GO) build $(GOFLAGS) -o $(PROGNAME)
test:
$(GO) test ./...
fmt:
$(GO) fmt ./...
vet:
$(GO) vet ./...
cross-build: all
for target in $(CROSSTARGETS); do \
env $$(echo "$$target" | awk -F '-' '{ print "GOOS="$$1, "GOARCH="$$2 }') \
$(GO) build $(GOFLAGS) -o "$(PROGNAME)-$(VERSION)-$$target"; \
done
major-release: all
$(RELEASE) major
minor-release: all
$(RELEASE) minor
patch-release: all
$(RELEASE) patch
install: all
mkdir -p $(DESTDIR)$(PREFIX)/bin
install -m 755 $(PROGNAME) $(DESTDIR)$(PREFIX)/bin
uninstall:
rm $(DESTDIR)$(PREFIX)/bin/$(PROGNAME)
clean:
$(GO) clean ./...
rm -rf *.tmp $(PROGNAME)-v*