-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (35 loc) · 994 Bytes
/
Makefile
File metadata and controls
46 lines (35 loc) · 994 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
34
35
36
37
38
39
40
41
42
43
44
45
BINARY_DIR = bin
BINARY_NAME = getstatus
RUN_ARCH = linux/amd64
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build
GOTEST = $(GOCMD) test
GOCLEAN = $(GOCMD) clean
CGO_ENABLED = 0
# Build flags and arguments
LDFLAGS = -ldflags="-s -w"
GCFLAGS = -gcflags="-m -l"
MODFLAGS = -mod=readonly
TRIMPATH = -trimpath
# Cross-compilation target architectures
TARGETS = \
linux/arm64 \
linux/amd64
.PHONY: all
all: build
# Build for all the configured target architectures (TARGETS)
build: $(TARGETS)
$(TARGETS):
GOOS=$(word 1, $(subst /, ,$@)) GOARCH=$(word 2, $(subst /, ,$@)) CGO_ENABLED=$(CGO_ENABLED)\
$(GOBUILD) $(LDFLAGS) $(GCFLAGS) $(MODFLAGS) $(TRIMPATH) \
-o $(BINARY_DIR)/$(BINARY_NAME)-$(word 1, $(subst /, ,$@))-$(word 2, $(subst /, ,$@))
# Clean builds
clean:
rm -f $(BINARY_DIR)/$(BINARY_NAME)-*
# Build and run
run: build
./$(BINARY_DIR)/$(BINARY_NAME)-$(word 1, $(subst /, ,$(RUN_ARCH)))-$(word 2, $(subst /, ,$(RUN_ARCH)))
# Includes race testing
test:
$(GOTEST) -v