Makefile 4.84 KB
Newer Older
1
# Minimum version numbers for software required to build IPFS
Jeromy's avatar
Jeromy committed
2
IPFS_MIN_GO_VERSION = 1.7
3 4
IPFS_MIN_GX_VERSION = 0.6
IPFS_MIN_GX_GO_VERSION = 1.1
5

6 7 8 9 10

export IPFS_REUSEPORT=false

ifneq ($(COVERALLS_TOKEN), )
  covertools_rule = covertools
11
  GOT = overalls -project=github.com/ipfs/go-ipfs -covermode atomic -ignore=.git,Godeps,thirdparty,test,core/commands -- $(GOTFLAGS)
12
else
13 14 15 16 17 18
  covertools_rule = $()
  GOT = go test $(GOTFLAGS) ./...
endif

ifeq ($(TEST_NO_FUSE),1)
  GOTFLAGS += -tags nofuse
19 20
endif

Dominic Della Valle's avatar
Dominic Della Valle committed
21 22 23 24 25
ifeq ($(OS),Windows_NT)
  GOPATH_DELIMITER = ;
else
  GOPATH_DELIMITER = :
endif
26

Jeromy's avatar
Jeromy committed
27 28 29
dist_root=/ipfs/QmNZL8wNsvAGdVYr8uGeUE9aGfHjFpHegAWywQFEdSaJbp
gx_bin=bin/gx-v0.9.0
gx-go_bin=bin/gx-go-v1.3.0
30 31 32

# use things in our bin before any other system binaries
export PATH := bin:$(PATH)
33
export IPFS_API ?= v04x.ipfs.io
34

35
all: help
36 37 38 39

godep:
	go get github.com/tools/godep

40
go_check:
41
	@bin/check_go_version $(IPFS_MIN_GO_VERSION)
42

Jeromy's avatar
Jeromy committed
43
bin/gx-v%:
44
	@echo "installing gx $(@:bin/gx-%=%)"
45
	@bin/dist_get ${dist_root} gx $@ $(@:bin/gx-%=%)
Jeromy's avatar
Jeromy committed
46 47
	rm -f bin/gx
	ln -s $(@:bin/%=%) bin/gx
48

Jeromy's avatar
Jeromy committed
49
bin/gx-go-v%:
50
	@echo "installing gx-go $(@:bin/gx-go-%=%)"
51
	@bin/dist_get ${dist_root} gx-go $@ $(@:bin/gx-go-%=%)
52 53 54 55
	rm -f bin/gx-go
	ln -s $(@:bin/%=%) bin/gx-go

gx_check: ${gx_bin} ${gx-go_bin}
56

57
path_check:
Dominic Della Valle's avatar
Dominic Della Valle committed
58
	@bin/check_go_path $(realpath $(shell pwd)) $(realpath $(addsuffix /src/github.com/ipfs/go-ipfs,$(subst $(GOPATH_DELIMITER), ,$(GOPATH))))
59

60
deps: go_check gx_check path_check $(covertools_rule)
61
	${gx_bin} --verbose install --global
62

63 64 65 66 67
covertools:
	go get -u github.com/mattn/goveralls
	go get -u golang.org/x/tools/cmd/cover
	go get -u github.com/Kubuxu/overalls

68 69 70 71 72
# saves/vendors third-party dependencies to Godeps/_workspace
# -r flag rewrites import paths to use the vendored path
# ./... performs operation on all packages in tree
vendor: godep
	godep save -r ./...
73

74 75
install build nofuse: deps
	$(MAKE) -C cmd/ipfs $@
Henry's avatar
Henry committed
76

77
clean:
78
	$(MAKE) -C cmd/ipfs clean
79
	$(MAKE) -C test clean
80 81

uninstall:
82
	$(MAKE) -C cmd/ipfs uninstall
83

Jakub Sztandera's avatar
Jakub Sztandera committed
84
PHONY += all help godep gx_check covertools
85
PHONY += go_check deps vendor install build nofuse clean uninstall
86

87 88 89
##############################################################
# tests targets

90
test: test_expensive
91

Jakub Sztandera's avatar
Jakub Sztandera committed
92
test_short: test_go_fmt build test_go_short test_sharness_short
93

Jakub Sztandera's avatar
Jakub Sztandera committed
94
test_expensive: test_go_fmt build test_go_expensive test_sharness_expensive windows_build_check
95

96
test_3node:
97
	$(MAKE) -C test/3nodetest
Brian Tiger Chow's avatar
Brian Tiger Chow committed
98

Jakub Sztandera's avatar
Jakub Sztandera committed
99 100 101
test_go_fmt:
	bin/test-go-fmt

102

103 104 105 106 107 108 109
test_go_short: GOTFLAGS += -test.short
test_go_race: GOTFLAGS += -race
test_go_expensive test_go_short test_go_race:
	$(GOT)
ifneq ($(COVERALLS_TOKEN), )
	goveralls -coverprofile=overalls.coverprofile -service $(SERVICE)
endif
Brian Tiger Chow's avatar
Brian Tiger Chow committed
110

111
test_sharness_short:
112
	$(MAKE) -j1 -C test/sharness/
113 114

test_sharness_expensive:
115
	TEST_EXPENSIVE=1 $(MAKE) -j1 -C test/sharness/
116 117 118 119 120

test_all_commits:
	@echo "testing all commits between origin/master..HEAD"
	@echo "WARNING: this will 'git rebase --exec'."
	@test/bin/continueyn
121
	GIT_EDITOR=true git rebase -i --exec "$(MAKE) test" origin/master
122 123 124 125 126 127 128

test_all_commits_travis:
	# these are needed because travis.
	# we don't use this yet because it takes way too long.
	git config --global user.email "nemo@ipfs.io"
	git config --global user.name "IPFS BOT"
	git fetch origin master:master
129
	GIT_EDITOR=true git rebase -i --exec "$(MAKE) test" master
130 131 132

# since we have CI for osx and linux but not windows, this should help
windows_build_check:
133
	GOOS=windows GOARCH=amd64 go build -o .test.ipfs.exe ./cmd/ipfs
Jakub Sztandera's avatar
Jakub Sztandera committed
134
	rm -f .test.ipfs.exe
135 136 137 138 139 140 141 142 143

PHONY += test test_short test_expensive

##############################################################
# A semi-helpful help message

help:
	@echo 'DEPENDENCY TARGETS:'
	@echo ''
144
	@echo '  gx_check        - Installs or upgrades gx and gx-go'
145 146
	@echo '  deps            - Download dependencies using gx'
	@echo '  vendor          - Create a Godep workspace of 3rd party dependencies'
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
	@echo ''
	@echo 'BUILD TARGETS:'
	@echo ''
	@echo '  all          - print this help message'
	@echo '  build        - Build binary at ./cmd/ipfs/ipfs'
	@echo '  nofuse       - Build binary with no fuse support'
	@echo '  install      - Build binary and install into $$GOPATH/bin'
#	@echo '  dist_install - TODO: c.f. ./cmd/ipfs/dist/README.md'
	@echo ''
	@echo 'CLEANING TARGETS:'
	@echo ''
	@echo '  clean        - Remove binary from build directory'
	@echo '  uninstall    - Remove binary from $$GOPATH/bin'
	@echo ''
	@echo 'TESTING TARGETS:'
	@echo ''
	@echo '  test                    - Run expensive tests and Window$$ check'
	@echo '  test_short              - Run short tests and sharness tests'
	@echo '  test_expensive          - Run a few extras'
	@echo '  test_3node'
	@echo '  test_go_short'
	@echo '  test_go_expensive'
	@echo '  test_go_race'
	@echo '  test_sharness_short'
	@echo '  test_sharness_expensive'
	@echo '  test_all_commits'
	@echo "  test_all_commits_travis - DON'T USE: takes way too long"
	@echo '  windows_build_check'
	@echo ''

PHONY += help

.PHONY: $(PHONY)