-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
40 lines (28 loc) · 1.32 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
.PHONY: all install test release
SOURCES = $(wildcard *.go) go.mod go.sum
# Experiment with go build -ldflags="-X 'main.Version=v1.0.0'"
GOFLAGS_debug = -ldflags '-X "main.Version=$(shell git rev-parse --short HEAD; [ -z "$$(git status --porcelain --untracked-files=no)" ] || echo 'with uncommitted changes')"'
GOFLAGS_release = -ldflags '-s -w -extldflags "-static" -X "main.Version=$(shell cat VERSION)"'
all: install
install:
go install $(GOFLAGS_debug) .
bin/darwin_amd64/dfm: $(SOURCES)
mkdir -p $(dir $@)
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o $@ $(GOFLAGS_release) .
bin/darwin_arm64/dfm: $(SOURCES)
mkdir -p $(dir $@)
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o $@ $(GOFLAGS_release) .
bin/linux_amd64/dfm: $(SOURCES)
mkdir -p $(dir $@)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ $(GOFLAGS_release) .
bin/linux_arm/dfm: $(SOURCES)
mkdir -p $(dir $@)
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -o $@ $(GOFLAGS_release) .
bin/linux_arm64/dfm: $(SOURCES)
mkdir -p $(dir $@)
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOARM=7 go build -o $@ $(GOFLAGS_release) .
bin/%.tar.gz: bin/%/dfm
tar -czf $@ -C $(dir $^) $(notdir $^)
release: bin/darwin_amd64.tar.gz bin/darwin_arm64.tar.gz bin/linux_amd64.tar.gz bin/linux_arm.tar.gz bin/linux_arm64.tar.gz
test: install
go test . -tags=integration