-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (29 loc) · 900 Bytes
/
Makefile
File metadata and controls
40 lines (29 loc) · 900 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
# Build variables
BINARY_NAME=sera
GIT_VERSION=$(shell git describe --tags --always --dirty)
BUILD_DIR=.build
# Reduce binary size and strip local directory paths (from logging etc)
FLAGS=-ldflags "-s -w" -trimpath
LINUX_ARCHS=386 amd64 arm64
DARWIN_ARCHS=amd64 arm64
define build
GOOS=$(1) GOARCH=$(2) go build $(FLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)_$(GIT_VERSION)_$(1)_$(2) .
endef
.PHONY: all linux darwin clean compress
all: clean linux darwin compress
linux:
$(foreach arch,$(LINUX_ARCHS), \
$(call build,linux,$(arch)) \
)
darwin:
$(foreach arch,$(DARWIN_ARCHS), \
$(call build,darwin,$(arch)) \
)
clean:
rm -rf $(BUILD_DIR)
# Use consistent filename since it will be extracted to /usr/local/bin during bake.
compress:
cd $(BUILD_DIR) && \
for binary in $(BINARY_NAME)_*; do \
tar --transform='s|.*|sera|' --remove-files -czf $$binary.tar.gz $$binary; \
done && cd ..