16
16
# under the License.
17
17
#
18
18
19
+ BINDIR ?= /usr/local/bin
20
+ OBJDIR ?= build
21
+
22
+ TMP_GOPATH =$(OBJDIR ) /gopath
23
+ GOBIN =$(TMP_GOPATH ) /bin
24
+
19
25
GOTOOLS = golint govendor goimports protoc-gen-go ginkgo gocov gocov-xml
20
- GOTOOLS_BIN = $(patsubst % ,$(GOPATH ) /bin /% , $(GOTOOLS ) )
26
+ GOTOOLS_BIN = $(patsubst % ,$(GOBIN ) /% , $(GOTOOLS ) )
21
27
22
28
# go tool->path mapping
23
29
go.fqp.govendor := github.com/kardianos/govendor
@@ -29,23 +35,27 @@ go.fqp.gocov-xml := github.com/AlekSi/gocov-xml
29
35
30
36
all : $(GOTOOLS_BIN )
31
37
38
+ install : $(GOTOOLS_BIN )
39
+ @mkdir -p $(BINDIR )
40
+ cp $^ $(BINDIR )
41
+
32
42
# Special override for protoc-gen-go since we want to use the version vendored with the project
33
43
gotool.protoc-gen-go :
34
- mkdir -p $( GOPATH ) /src/ github.com/golang/protobuf/
35
- cp -R $(GOPATH ) /src/github.com/hyperledger/fabric/vendor/github.com/ golang/protobuf/ $( GOPATH ) /src/github.com/golang /
36
- go install github.com/golang/protobuf/protoc-gen-go
37
- rm -rf $( GOPATH ) /src/ github.com/golang/protobuf
44
+ @echo " Building github.com/golang/protobuf/protoc-gen-go -> protoc-gen-go "
45
+ @mkdir -p $(TMP_GOPATH ) /src/github.com/golang/protobuf/
46
+ @cp -R $( GOPATH ) /src/ github.com/hyperledger/fabric/vendor/github.com/ golang/protobuf/* $( TMP_GOPATH ) /src/github.com/golang/protobuf
47
+ @GOPATH= $( abspath $( TMP_GOPATH ) ) go install github.com/golang/protobuf/protoc-gen-go
38
48
39
49
# Default rule for gotools uses the name->path map for a generic 'go get' style build
40
50
gotool.% :
41
51
$(eval TOOL = ${subst gotool.,,${@}})
42
- @echo " Building $( TOOL) "
43
- go get ${go.fqp.${TOOL} }
52
+ @echo " Building ${go.fqp. ${TOOL} } -> $ ( TOOL) "
53
+ @GOPATH= $( abspath $( TMP_GOPATH ) ) go get ${go.fqp.${TOOL} }
44
54
45
- $(GOPATH ) /bin /% :
46
- $(eval TOOL = ${subst $(GOPATH ) /bin /,,${@}})
55
+ $(GOBIN ) /% :
56
+ $(eval TOOL = ${subst $(GOBIN ) /,,${@}})
47
57
@$(MAKE ) gotool.$(TOOL )
48
58
49
59
.PHONY : clean
50
60
clean :
51
- -@rm -f $(GOTOOLS_BIN ) || :
61
+ -@rm -rf $(OBJDIR )
0 commit comments