forked from ontio/ontology
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
94 lines (72 loc) · 2.76 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
GOFMT=gofmt
GC=go build
VERSION := $(shell git describe --always --tags --long)
BUILD_NODE_PAR = -ldflags "-X github.com/ontio/ontology/common/config.Version=$(VERSION)" #-race
ARCH=$(shell uname -m)
DBUILD=docker build
DRUN=docker run
DOCKER_NS ?= ontio
DOCKER_TAG=$(ARCH)-$(VERSION)
SRC_FILES = $(shell git ls-files | grep -e .go$ | grep -v _test.go)
TOOLS=./tools
ABI=$(TOOLS)/abi
NATIVE_ABI_SCRIPT=./cmd/abi/native_abi_script
ontology: $(SRC_FILES)
$(GC) $(BUILD_NODE_PAR) -o ontology main.go
sigsvr: $(SRC_FILES) abi
$(GC) $(BUILD_NODE_PAR) -o sigsvr sigsvr.go
@if [ ! -d $(TOOLS) ];then mkdir -p $(TOOLS) ;fi
@mv sigsvr $(TOOLS)
abi:
@if [ ! -d $(ABI) ];then mkdir -p $(ABI) ;fi
@cp $(NATIVE_ABI_SCRIPT)/*.json $(ABI)
tools: sigsvr abi
all: ontology tools
ontology-cross: ontology-windows ontology-linux ontology-darwin
ontology-windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o ontology-windows-amd64.exe main.go
ontology-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o ontology-linux-amd64 main.go
ontology-darwin:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o ontology-darwin-amd64 main.go
tools-cross: tools-windows tools-linux tools-darwin
tools-windows: abi
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o sigsvr-windows-amd64.exe sigsvr.go
@if [ ! -d $(TOOLS) ];then mkdir -p $(TOOLS) ;fi
@mv sigsvr-windows-amd64.exe $(TOOLS)
tools-linux: abi
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o sigsvr-linux-amd64 sigsvr.go
@if [ ! -d $(TOOLS) ];then mkdir -p $(TOOLS) ;fi
@mv sigsvr-linux-amd64 $(TOOLS)
tools-darwin: abi
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o sigsvr-darwin-amd64 sigsvr.go
@if [ ! -d $(TOOLS) ];then mkdir -p $(TOOLS) ;fi
@mv sigsvr-darwin-amd64 $(TOOLS)
all-cross: ontology-cross tools-cross abi
format:
$(GOFMT) -w main.go
docker/payload: docker/build/bin/ontology docker/Dockerfile
@echo "Building ontology payload"
@mkdir -p $@
@cp docker/Dockerfile $@
@cp docker/build/bin/ontology $@
@touch $@
docker/build/bin/%: Makefile
@echo "Building ontology in docker"
@mkdir -p docker/build/bin docker/build/pkg
@$(DRUN) --rm \
-v $(abspath docker/build/bin):/go/bin \
-v $(abspath docker/build/pkg):/go/pkg \
-v $(GOPATH)/src:/go/src \
-w /go/src/github.com/ontio/ontology \
golang:1.9.5-stretch \
$(GC) $(BUILD_NODE_PAR) -o docker/build/bin/ontology main.go
@touch $@
docker: Makefile docker/payload docker/Dockerfile
@echo "Building ontology docker"
@$(DBUILD) -t $(DOCKER_NS)/ontology docker/payload
@docker tag $(DOCKER_NS)/ontology $(DOCKER_NS)/ontology:$(DOCKER_TAG)
@touch $@
clean:
rm -rf *.8 *.o *.out *.6 *exe coverage
rm -rf ontology ontology-* tools docker/payload docker/build