-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (54 loc) · 2.74 KB
/
Makefile
File metadata and controls
69 lines (54 loc) · 2.74 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
.PHONY: all clean
.PHONY: goracle_linux goracle-linux-amd64 goracle-darwin-amd64
.PHONY: goracle-darwin goracle-darwin-amd64
.PHONY: goracle-windows goracle-windows-386 goracle-windows-amd64
.PHONY: goraclec_linux goraclec-linux-amd64 goraclec-darwin-amd64
.PHONY: goraclec-darwin goraclec-darwin-amd64
.PHONY: goraclec-windows goraclec-windows-386 goraclec-windows-amd64
# Check for required command tools to build or stop immediately
EXECUTABLES = git go find pwd
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH)))
GO ?= latest
SERVERBINARY = goracle
SERVERMAIN = $(shell pwd)/cmd/server/main.go
BUILDDIR = $(shell pwd)/build
VERSION = 0.0.1
GITREV = $(shell git rev-parse --short HEAD)
BUILDTIME = $(shell date +'%Y-%m-%d_%T')
LDFLAGS=-ldflags "-X main.version=${VERSION} -X main.sha1ver=${GITREV} -X main.buildTime=${BUILDTIME}"
build: update-version
go build -v -i -o $(BUILDDIR)/$(SERVERBINARY) $(SERVERMAIN)
@echo "Build server done."
@echo "Run \"$(BUILDDIR)/$(SERVERBINARY)\" to start qlc oracle server."
all: goracle-windows goracle-darwin goracle-linux
update-version:
@echo "package qlcchain" > $(shell pwd)/version.go
@echo "">> $(shell pwd)/version.go
@echo "const GITREV = \""$(GITREV)"\"" >> $(shell pwd)/version.go
@echo "const VERSION = \""$(VERSION)"\"" >> $(shell pwd)/version.go
@echo "const BUILDTIME = \""$(BUILDTIME)"\"" >> $(shell pwd)/version.go
clean:
rm -rf $(BUILDDIR)/
# qlc oracle server
goracle-linux: goracle-linux-amd64
@echo "Linux cross compilation done."
goracle-linux-amd64: update-version
env GOOS=linux GOARCH=amd64 go build -i -o $(BUILDDIR)/$(SERVERBINARY)-linux-amd64-v$(VERSION)-$(GITREV) $(SERVERMAIN)
@echo "Build linux server done."
@ls -ld $(BUILDDIR)/$(SERVERBINARY)-linux-amd64-v$(VERSION)-$(GITREV)
goracle-darwin: update-version
env GOOS=darwin GOARCH=amd64 go build -i -o $(BUILDDIR)/$(SERVERBINARY)-darwin-amd64-v$(VERSION)-$(GITREV) $(SERVERMAIN)
@echo "Build darwin server done."
@ls -ld $(BUILDDIR)/$(SERVERBINARY)-darwin-amd64-v$(VERSION)-$(GITREV)
goracle-windows: goracle-windows-amd64 goracle-windows-386
@echo "Windows cross compilation done:"
@ls -ld $(BUILDDIR)/$(SERVERBINARY)-windows-*
goracle-windows-386: update-version
env GOOS=windows GOARCH=386 go build -i -o $(BUILDDIR)/$(SERVERBINARY)-windows-386-v$(VERSION)-$(GITREV).exe $(SERVERMAIN)
@echo "Build windows x86 server done."
@ls -ld $(BUILDDIR)/$(SERVERBINARY)-windows-386-v$(VERSION)-$(GITREV).exe
goracle-windows-amd64: update-version
env GOOS=windows GOARCH=amd64 go build -i -o $(BUILDDIR)/$(SERVERBINARY)-windows-amd64-v$(VERSION)-$(GITREV).exe $(SERVERMAIN)
@echo "Build windows server done."
@ls -ld $(BUILDDIR)/$(SERVERBINARY)-windows-amd64-v$(VERSION)-$(GITREV).exe