-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
37 lines (32 loc) · 1.02 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
APP_NAME = proq
VERSION ?= $(shell git describe --tags --always --dirty=-dev)
BUILD_DIR = bin
CMD_DIR = cmd
ENTRY_POINT = $(CMD_DIR)/main.go
# Supported GOOS and GOARCH combinations
PLATFORMS = \
linux/amd64 \
linux/arm64 \
linux/arm \
darwin/amd64 \
darwin/arm64 \
windows/amd64
# Build for all platforms
.PHONY: build
build: clean $(PLATFORMS)
$(PLATFORMS):
@mkdir -p $(BUILD_DIR)
@GOOS=$(word 1, $(subst /, ,$@)) GOARCH=$(word 2, $(subst /, ,$@)) \
go build -ldflags "-X main.Version=$(VERSION)" -o $(BUILD_DIR)/$(APP_NAME)-$(word 1, $(subst /, ,$@))-$(word 2, $(subst /, ,$@)) $(ENTRY_POINT)
@echo "Built $(APP_NAME) for $@ with version $(VERSION)"
# Clean build artifacts
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
@echo "Cleaned up build artifacts"
# Build for the current OS/Arch
.PHONY: build-local
build-local:
@mkdir -p $(BUILD_DIR)
@go build -ldflags "-X main.Version=$(VERSION)" -o $(BUILD_DIR)/$(APP_NAME) $(ENTRY_POINT)
@echo "Built $(APP_NAME) for local machine with version $(VERSION)"