1
-# Minimum version numbers for software required to build IPFS
2
-IPFS_MIN_GO_VERSION = 1.7
3
-IPFS_MIN_GX_VERSION = 0.6
4
-IPFS_MIN_GX_GO_VERSION = 1.1
1
+# General tools
2
6
-GOTAGS =
7
-GOTAGS += "" # we have to have always at least one tag, empty tag works well
3
+SHELL=PATH=$(PATH) /bin/sh
4
9
-GOFLAGS =
10
-GOTFLAGS =
5
+PROTOC = protoc --gogo_out=. --proto_path=.:/usr/local/opt/protobuf/include:$(dir $@) $<
6
12
-export IPFS_REUSEPORT=false
13
-export GOFLAGS
14
-export GOTFLAGS
7
+# enable second expansion
8
+.SECONDEXPANSION:
9
16
-GOFLAGS += -tags $(call join-with,$(comma),$(GOTAGS))
17
-
18
-ifeq ($(TEST_NO_FUSE),1)
19
- GOTAGS += nofuse
20
-endif
21
-
22
-ifeq ($(OS),Windows_NT)
23
- GOPATH_DELIMITER = ;
24
-else
25
- GOPATH_DELIMITER = :
26
-endif
27
-
28
-dist_root=/ipfs/QmNZL8wNsvAGdVYr8uGeUE9aGfHjFpHegAWywQFEdSaJbp
29
-gx_bin=bin/gx-v0.9.0
30
-gx-go_bin=bin/gx-go-v1.3.0
31
-
32
-
33
-# util functions
34
-
35
-space =
36
-space +=
37
-comma =,
38
-join-with = $(subst $(space),$1,$(strip $2))
39
-# use things in our bin before any other system binaries
40
-export PATH := bin:$(PATH)
41
-export IPFS_API ?= v04x.ipfs.io
42
-
43
-all: help
44
-
45
-godep:
46
- go get github.com/tools/godep
47
-
48
-go_check:
49
- @bin/check_go_version $(IPFS_MIN_GO_VERSION)
50
-
51
-bin/gx-v%:
52
- @echo "installing gx $(@:bin/gx-%=%)"
53
- @bin/dist_get ${dist_root} gx $@ $(@:bin/gx-%=%)
54
- rm -f bin/gx
55
- ln -s $(@:bin/%=%) bin/gx
56
-
57
-bin/gx-go-v%:
58
- @echo "installing gx-go $(@:bin/gx-go-%=%)"
59
- @bin/dist_get ${dist_root} gx-go $@ $(@:bin/gx-go-%=%)
60
- rm -f bin/gx-go
61
- ln -s $(@:bin/%=%) bin/gx-go
62
-
63
-gx_check: ${gx_bin} ${gx-go_bin}
64
-
65
-path_check:
66
- @bin/check_go_path $(realpath $(shell pwd)) $(realpath $(addsuffix /src/github.com/ipfs/go-ipfs,$(subst $(GOPATH_DELIMITER), ,$(GOPATH))))
67
-
68
-deps: go_check gx_check path_check $(covertools_rule)
69
- ${gx_bin} --verbose install --global
70
-
71
-deps_covertools:
72
- go get -u github.com/wadey/gocovmerge
73
- go get -u golang.org/x/tools/cmd/cover
74
-
75
-# saves/vendors third-party dependencies to Godeps/_workspace
76
-# -r flag rewrites import paths to use the vendored path
77
-# ./... performs operation on all packages in tree
78
-vendor: godep
79
- godep save -r ./...
80
-
81
-nofuse: GOTAGS += nofuse
82
-nofuse: deps
83
- $(MAKE) -C cmd/ipfs install
84
-
85
-install build: deps
86
- $(MAKE) -C cmd/ipfs $@
87
-
88
-clean:
89
- $(MAKE) -C cmd/ipfs clean
90
- $(MAKE) -C test clean
91
-
92
-uninstall:
93
- $(MAKE) -C cmd/ipfs uninstall
94
-
95
-PHONY += all help godep gx_check covertools
96
-PHONY += go_check deps vendor install build nofuse clean uninstall
97
-
98
-##############################################################
99
-# tests targets
100
-
101
-test: test_expensive
102
-
103
-test_short: test_go_fmt build test_go_short test_sharness_short
104
-
105
-test_expensive: test_go_fmt build test_go_expensive test_sharness_expensive windows_build_check
106
-
107
-test_3node:
108
- $(MAKE) -C test/3nodetest
109
-
110
-test_go_fmt:
111
- bin/test-go-fmt
112
-
113
-test_go_short: GOTFLAGS += -test.short
114
-test_go_race: GOTFLAGS += -race
115
-test_go_expensive test_go_short test_go_race:
116
- go test $(GOFLAGS) $(GOTFLAGS) ./...
117
-
118
-coverage: deps_covertools
119
- @echo Running coverage
120
- $(eval PKGS := $(shell go list -f '{{if (len .GoFiles)}}{{.ImportPath}}{{end}}' ./... | grep -v /vendor/ | grep -v /Godeps/))
121
-#$(eval PKGS_DELIM := $(call join-with,$(comma),$(PKGS)))
122
- @go list -f '{{if or (len .TestGoFiles) (len .XTestGoFiles)}}go test $(GOFLAGS) $(GOTFLAGS) -covermode=atomic -coverprofile={{.Name}}_{{len .Imports}}_{{len .Deps}}.coverprofile {{.ImportPath}}{{end}}' $(GOFLAGS) $(PKGS) | xargs -I {} bash -c {} 2>&1 | grep -v 'warning: no packages being tested depend on'
123
- gocovmerge `ls *.coverprofile` > coverage.txt
124
- rm *.coverprofile
125
- bash -c 'bash <(curl -s https://codecov.io/bash)'
126
-
127
-test_sharness_short:
128
- $(MAKE) -j1 -C test/sharness/
129
-
130
-test_sharness_expensive:
131
- TEST_EXPENSIVE=1 $(MAKE) -j1 -C test/sharness/
132
-
133
-test_all_commits:
134
- @echo "testing all commits between origin/master..HEAD"
135
- @echo "WARNING: this will 'git rebase --exec'."
136
- @test/bin/continueyn
137
- GIT_EDITOR=true git rebase -i --exec "$(MAKE) test" origin/master
138
-
139
-test_all_commits_travis:
140
- # these are needed because travis.
141
- # we don't use this yet because it takes way too long.
142
- git config --global user.email "nemo@ipfs.io"
143
- git config --global user.name "IPFS BOT"
144
- git fetch origin master:master
145
- GIT_EDITOR=true git rebase -i --exec "$(MAKE) test" master
146
-
147
-# since we have CI for osx and linux but not windows, this should help
148
-windows_build_check:
149
- GOOS=windows GOARCH=amd64 go build -o .test.ipfs.exe ./cmd/ipfs
150
- rm -f .test.ipfs.exe
151
-
152
-PHONY += test test_short test_expensive
153
-
154
-##############################################################
155
-# A semi-helpful help message
156
-
157
-help:
158
- @echo 'DEPENDENCY TARGETS:'
159
- @echo ''
160
- @echo ' gx_check - Installs or upgrades gx and gx-go'
161
- @echo ' deps - Download dependencies using gx'
162
- @echo ' vendor - Create a Godep workspace of 3rd party dependencies'
163
- @echo ''
164
- @echo 'BUILD TARGETS:'
165
- @echo ''
166
- @echo ' all - print this help message'
167
- @echo ' build - Build binary at ./cmd/ipfs/ipfs'
168
- @echo ' nofuse - Build binary with no fuse support'
169
- @echo ' install - Build binary and install into $$GOPATH/bin'
170
-# @echo ' dist_install - TODO: c.f. ./cmd/ipfs/dist/README.md'
171
- @echo ''
172
- @echo 'CLEANING TARGETS:'
173
- @echo ''
174
- @echo ' clean - Remove binary from build directory'
175
- @echo ' uninstall - Remove binary from $$GOPATH/bin'
176
- @echo ''
177
- @echo 'TESTING TARGETS:'
178
- @echo ''
179
- @echo ' test - Run expensive tests and Window$$ check'
180
- @echo ' test_short - Run short tests and sharness tests'
181
- @echo ' test_expensive - Run a few extras'
182
- @echo ' test_3node'
183
- @echo ' test_go_short'
184
- @echo ' test_go_expensive'
185
- @echo ' test_go_race'
186
- @echo ' test_sharness_short'
187
- @echo ' test_sharness_expensive'
188
- @echo ' test_all_commits'
189
- @echo " test_all_commits_travis - DON'T USE: takes way too long"
190
- @echo ' windows_build_check'
191
- @echo ''
192
-
193
-PHONY += help
194
-
195
-.PHONY: $(PHONY)
10
+include Rules.mk