-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
33 lines (26 loc) · 821 Bytes
/
Copy pathMakefile
File metadata and controls
33 lines (26 loc) · 821 Bytes
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
BINARY_NAME := camus
MAIN_GO_FILE := camus.go
VERSION := $(shell git describe --tags --always --dirty || echo "dev")
LDFLAGS := -ldflags="-X 'main.Version=$(VERSION)'"
TARGETS := \
linux/amd64 \
linux/arm64 \
windows/amd64 \
windows/arm64 \
darwin/amd64 \
darwin/arm64
build: | bin
@echo "Building for $$(go env GOOS)/$$(go env GOARCH)..."
go build $(LDFLAGS) -o bin/$(BINARY_NAME) $(MAIN_GO_FILE)
all: $(TARGETS)
$(TARGETS): | bin
$(eval GOOS := $(word 1,$(subst /, ,$@)))
$(eval GOARCH := $(word 2,$(subst /, ,$@)))
$(eval EXT := $(if $(findstring windows,$(GOOS)),.exe,))
@echo "Building for $(GOOS)/$(GOARCH)..."
GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(LDFLAGS) -o bin/$(BINARY_NAME)-$(GOOS)-$(GOARCH)$(EXT) $(MAIN_GO_FILE)
bin:
@mkdir -p bin
clean:
rm bin/*
.PHONY: all build clean $(TARGETS)