forked from cblomart/zwaymqtt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
53 lines (38 loc) · 1.47 KB
/
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
52
53
GOVERSION=$(shell go version)
GOOS=$(word 1,$(subst /, ,$(lastword $(GOVERSION))))
GOARCH=$(word 2,$(subst /, ,$(lastword $(GOVERSION))))
RELEASE_DIR=releases
SRC_FILES=$(wildcard *.go)
BUILD_FLAGS=-ldflags '-s -w -extldflags "-static"' -a
deps:
go get github.com/eclipse/paho.mqtt.golang
go get github.com/pkg/profile
build-windows-amd64:
@$(MAKE) build GOOS=windows GOARCH=amd64 CGO_ENABLED=0 SUFFIX=.exe
dist-windows-amd64:
@$(MAKE) dist GOOS=windows GOARCH=amd64 SUFFIX=.exe
build-linux-amd64:
@$(MAKE) build GOOS=linux GOARCH=amd64 CGO_ENABLED=0
dist-linux-amd64:
@$(MAKE) dist GOOS=linux GOARCH=amd64
build-darwin-amd64:
@$(MAKE) build GOOS=darwin GOARCH=amd64 CGO_ENABLED=0
dist-darwin-amd64:
@$(MAKE) dist GOOS=darwin GOARCH=amd64
build-linux-arm:
@$(MAKE) build GOOS=linux GOARCH=arm GOARM=5 CGO_ENABLED=0
dist-linux-arm:
@$(MAKE) dist GOOS=linux GOARCH=arm GOARM=5
$(RELEASE_DIR)/$(GOOS)/$(GOARCH)/zwaymqtt$(SUFFIX): $(SRC_FILES)
go build $(BUILD_FLAGS) -o $(RELEASE_DIR)/$(GOOS)/$(GOARCH)/zwaymqtt$(SUFFIX) .
$(RELEASE_DIR)/zwaymqtt_$(GOOS)_$(GOARCH).tgz: $(RELEASE_DIR)/$(GOOS)/$(GOARCH)/zwaymqtt$(SUFFIX)
cd $(RELEASE_DIR)/$(GOOS)/$(GOARCH); tar czf ../../zwaymqtt_$(GOOS)_$(GOARCH).tgz ./zwaymqtt$(SUFFIX)
dist: $(RELEASE_DIR)/zwaymqtt_$(GOOS)_$(GOARCH).tgz
build: $(RELEASE_DIR)/$(GOOS)/$(GOARCH)/zwaymqtt$(SUFFIX)
clean:
rm -rf $(RELEASE_DIR)
all:
@$(MAKE) dist-windows-amd64
@$(MAKE) dist-linux-amd64
@$(MAKE) dist-darwin-amd64
@$(MAKE) dist-linux-arm