-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathmakefile
38 lines (32 loc) · 793 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
37
38
# Go parameters
GO_CMD=go
GO_BUILD=$(GO_CMD) build
BINARY_NAME=GC2
# List of target OS/Arch combinations
TARGETS=\
linux/amd64 \
linux/arm64 \
windows/amd64 \
darwin/amd64 \
darwin/arm64
# Default target executed when no arguments are given to make.
.PHONY: all
all: build
# Cross compile for all targets
.PHONY: build
build: $(TARGETS)
# Pattern rule to build for each target
$(TARGETS):
@mkdir -p bin/$(subst /,_,$@)
GOOS=$(word 1,$(subst /, ,$@)) GOARCH=$(word 2,$(subst /, ,$@)) $(GO_BUILD) -o bin/$(subst /,_,$@)/$(BINARY_NAME)
# Clean build files
.PHONY: clean
clean:
rm -rf bin
# List of available targets
.PHONY: info
info:
@echo "Binaries will be created for the available build targets:"
@for target in $(TARGETS); do \
echo " $$target"; \
done