-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
36 lines (28 loc) · 916 Bytes
/
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
GOCMD=go
BINARY_NAME=whatip
VERSION?=0.1.0
OUTDIR=./out/bin
LDFLAGS=-ldflags '-X main.VERSION=${VERSION}'
.PHONY: vendor clean
.SILENT: build version
.DEFAULT_GOAL: build
## Build:
build: ## Build your project and put the output binary in out/bin/ | TODO: Iterate & Compress using tar
mkdir -p $(OUTDIR)/$(VERSION);
rm -rf $(OUTDIR)/$(VERSION)/*; \
for OS in darwin linux; do \
for ARCH in amd64 arm64 arm; do \
GOOS=$$OS GOARCH=$$ARCH GO111MODULE=on $(GOCMD) build -mod vendor ${LDFLAGS} -o $(OUTDIR)/$(VERSION)/$(BINARY_NAME)-$(VERSION)-$$OS-$$ARCH .; \
done; \
done; \
for file in $(OUTDIR)/$(VERSION)/*; do \
tar -cf "$$file.tar.gz" "$$file"; \
rm $$file; \
done;
clean: ## Remove build related file
rm -fr ./bin
rm -fr ./out
vendor: ## Copy of all packages needed to support builds and tests in the vendor directory
$(GOCMD) mod vendor
version: ## Output version
echo $(VERSION)