forked from akadatalimited/breathgslb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.patch
More file actions
131 lines (110 loc) · 5.77 KB
/
Copy pathmake.patch
File metadata and controls
131 lines (110 loc) · 5.77 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
diff --git a/Makefile b/Makefile
index 589d12b6c31c1aded270946171b49bfec6847063..c83a7558cf0d5e8d7db444a967f411547d402def 100644
--- a/Makefile
+++ b/Makefile
@@ -16,104 +16,120 @@ MODFLAG := -mod=vendor
endif
# Version injection
GIT_TAG := $(shell git describe --tags --always --dirty 2>/dev/null)
BUILD_LDFLAGS := $(LDFLAGS) -X 'main.version=$(GIT_TAG)'
# Paths
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
SYSD_PREFIX ?= /etc/systemd/system
ORC_PREFIX ?= /etc/init.d
LOGDIR ?= /var/log/breathgslb
CFGDIR ?= /etc/breathgslb
KEYDIR ?= $(CFGDIR)/keys
DISTDIR ?= dist
# Utils
MKDIR_P := mkdir -p
TAR ?= tar
ZIP ?= zip -9
SHA256 := $(shell command -v sha256sum 2>/dev/null || command -v shasum 2>/dev/null)
SHA256FLAGS := $(shell [ "$$(basename $(SHA256))" = "shasum" ] && echo -a || echo )
# -------------------- standard targets --------------------
.PHONY: all build vendor clean fmt vet test help \
- release release-linux release-musl release-macos release-freebsd release-windows \
- package install install-systemd install-openrc uninstall
+ release release-linux release-musl release-macos release-freebsd release-bsd release-windows \
+ package install install-systemd install-openrc uninstall
all: build
help:
@echo "Available targets:"
- @grep -E '^[a-zA-Z_-]+:' $(MAKEFILE_LIST) | grep -v '^\.PHONY' | cut -d: -f1 | sort | uniq | sed 's/^/ /'
+ @echo " build build the $(BINARY) binary"
+ @echo " test run tests with the race detector"
+ @echo " release build release binaries for all supported platforms"
+ @echo " release-linux build release binaries for Linux"
+ @echo " release-musl build static Linux binaries (musl)"
+ @echo " release-macos build release binaries for macOS"
+ @echo " release-freebsd build release binaries for FreeBSD"
+ @echo " release-bsd build release binaries for OpenBSD and NetBSD"
+ @echo " release-windows build release binaries for Windows"
+ @echo " package archive release binaries and generate checksums"
build:
@echo "==> building ($(BINARY)) with GOFLAGS='$(GOFLAGS)' CGO_ENABLED=$(CGO_ENABLED)"
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(BINARY)
vendor:
$(GO) mod tidy
$(GO) mod vendor
clean:
rm -f $(BINARY)
rm -rf $(DISTDIR)
fmt:
$(GO) fmt ./...
vet:
$(GO) vet ./...
test:
- $(GO) test ./...
+ $(GO) test -race ./...
# -------------------- release matrices --------------------
-release: clean release-linux release-musl release-macos release-freebsd release-windows
+release: clean release-linux release-musl release-macos release-freebsd release-bsd release-windows
release-linux:
$(MKDIR_P) $(DISTDIR)
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-linux-amd64
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-linux-arm64
# Static-ish MUSL builds for Alpine (no cgo)
release-musl:
$(MKDIR_P) $(DISTDIR)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO) build -tags netgo -trimpath -ldflags "$(BUILD_LDFLAGS) -extldflags '-static'" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-linux-amd64-musl
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 $(GO) build -tags netgo -trimpath -ldflags "$(BUILD_LDFLAGS) -extldflags '-static'" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-linux-arm64-musl
release-macos:
$(MKDIR_P) $(DISTDIR)
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-darwin-amd64
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-darwin-arm64
release-freebsd:
$(MKDIR_P) $(DISTDIR)
GOOS=freebsd GOARCH=amd64 CGO_ENABLED=1 $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-freebsd-amd64
GOOS=freebsd GOARCH=arm64 CGO_ENABLED=1 $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-freebsd-arm64
+release-bsd:
+ $(MKDIR_P) $(DISTDIR)
+ GOOS=openbsd GOARCH=amd64 CGO_ENABLED=1 $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-openbsd-amd64
+ GOOS=openbsd GOARCH=arm64 CGO_ENABLED=1 $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-openbsd-arm64
+ GOOS=netbsd GOARCH=amd64 CGO_ENABLED=1 $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-netbsd-amd64
+ GOOS=netbsd GOARCH=arm64 CGO_ENABLED=1 $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-netbsd-arm64
+
release-windows:
$(MKDIR_P) $(DISTDIR)
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-windows-amd64.exe
GOOS=windows GOARCH=arm64 CGO_ENABLED=1 $(GO) build -trimpath -ldflags "$(BUILD_LDFLAGS)" $(MODFLAG) $(GOFLAGS) -o $(DISTDIR)/$(BINARY)-windows-arm64.exe
# -------------------- packaging --------------------
package: release
@echo "==> packaging archives"
cd $(DISTDIR) && \
for f in *; do \
base="$${f%.*}"; \
case "$$f" in \
*.exe) $(ZIP) "$$f.zip" "$$f" >/dev/null && rm -f "$$f";; \
*) $(TAR) -czf "$$f.tar.gz" "$$f" && rm -f "$$f";; \
esac; \
done
@# checksums
@if [ -n "$(SHA256)" ]; then \
(cd $(DISTDIR) && $(SHA256) $(SHA256FLAGS) * > SHA256SUMS); \
echo "==> wrote $(DISTDIR)/SHA256SUMS"; \
else \
echo "!! sha256 tool not found; skipping sums"; \
fi
# -------------------- install targets --------------------