-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (38 loc) · 946 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
39
40
41
42
43
44
45
46
47
48
49
50
51
# settings
IS_RELEASE = false
GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH)
# tools
GO = go
WINRES = $(GO) run github.com/tc-hib/go-winres@latest
# output
BINARY = ./bin/$(GOOS)-$(GOARCH)
EXE = $(BINARY)/gophengine$(shell go env GOEXE)
# flags
UPX_FLAGS = --best --lzma
GO_GCFLAGS =
GO_LDFLAGS =
GO_FLAGS = -v
ifeq ($(IS_RELEASE),true)
GO_GCFLAGS += -dwarf=false
GO_LDFLAGS += -s -w -H windowsgui
endif
GO_FLAGS += -gcflags="$(GO_GCFLAGS)" -ldflags="$(GO_LDFLAGS)" -buildvcs=true -buildmode=pie
.PHONY: all
all: build upx
.PHONY: build
build: clean
mkdir -p $(BINARY)
# $(GO) get
$(WINRES) make --out ./cmd/gophengine/rsrc
GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) build $(GO_FLAGS) -o $(EXE) ./cmd/gophengine
.PHONY: upx
upx: build
ifeq ($(IS_RELEASE),true)
upx $(UPX_FLAGS) $(EXE)
endif
.PHONY: clean
clean:
rm -rf $(BINARY)
rm -f ./cmd/gophengine/rsrc_windows_386.syso
rm -f ./cmd/gophengine/rsrc_windows_amd64.syso