-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (34 loc) · 862 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
SINGLETON =
COMMANDS = rew
ifndef GOAMD64
GOAMD64 = v2
endif
GOOS = $(shell uname -s | tr [A-Z] [a-z])
ifeq ($(GOOS), darwin)
GOBIN = /usr/local/go/bin/go
UPXBIN = /usr/local/bin/upx
else
GOBIN = /usr/local/bin/go
UPXBIN = /usr/bin/upx
endif
RELEASE = -s -w
GOARGS = GOOS=$(GOOS) GOARCH=amd64 GOAMD64=$(GOAMD64) CGO_ENABLED=1
GOBUILD = $(GOARGS) $(GOBIN) build -ldflags="$(RELEASE)"
BINFILES = $(SINGLETON) $(COMMANDS)
.PHONY: all build clean upx upxx $(BINFILES)
all: clean build
$(SINGLETON):
@echo "Compile $@ ..."
$(GOBUILD) -o ./bin/$@ *.go
$(COMMANDS):
@echo "Compile $@ ..."
$(GOBUILD) -o ./bin/$@ ./cmd/$@
build: $(BINFILES)
@echo "Build success."
clean:
rm -f $(BINFILES:%=./bin/%)
@echo "Remove old files."
upx: clean build
$(UPXBIN) $(BINFILES:%=./bin/%)
upxx: clean build
$(UPXBIN) --ultra-brute $(BINFILES:%=./bin/%)