Makefile 4.23 KB
Newer Older
1 2 3 4
# Minimum version numbers for software required to build IPFS
IPFS_MIN_GO_VERSION = 1.5.2
IPFS_MIN_GX_VERSION = 0.6
IPFS_MIN_GX_GO_VERSION = 1.1
5 6

ifeq ($(TEST_NO_FUSE),1)
7
  go_test=IPFS_REUSEPORT=false go test -tags nofuse
8
else
9
  go_test=IPFS_REUSEPORT=false go test
10 11
endif

12

13
dist_root=/ipfs/QmXZQzBAFuoELw3NtjQZHkWSdA332PyQUj6pQjuhEukvg8
Jeromy's avatar
Jeromy committed
14
gx_bin=bin/gx-v0.7.0
Jeromy's avatar
Jeromy committed
15
gx-go_bin=bin/gx-go-v1.2.0
16 17 18

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

21
all: help
22 23 24 25

godep:
	go get github.com/tools/godep

26
go_check:
27
	@bin/check_go_version $(IPFS_MIN_GO_VERSION)
28

Jeromy's avatar
Jeromy committed
29
bin/gx-v%:
30
	@echo "installing gx $(@:bin/gx-%=%)"
31
	@bin/dist_get ${dist_root} gx $@ $(@:bin/gx-%=%)
Jeromy's avatar
Jeromy committed
32 33
	rm -f bin/gx
	ln -s $(@:bin/%=%) bin/gx
34

Jeromy's avatar
Jeromy committed
35
bin/gx-go-v%:
36
	@echo "installing gx-go $(@:bin/gx-go-%=%)"
37
	@bin/dist_get ${dist_root} gx-go $@ $(@:bin/gx-go-%=%)
38 39 40 41
	rm -f bin/gx-go
	ln -s $(@:bin/%=%) bin/gx-go

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

43
path_check:
44
	@bin/check_go_path $(realpath $(shell pwd)) $(realpath $(addsuffix /src/github.com/ipfs/go-ipfs,$(subst :, ,$(GOPATH))))
45

Jeromy's avatar
Jeromy committed
46
deps: go_check gx_check path_check
47
	${gx_bin} --verbose install --global
48

49 50 51 52 53
# 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 ./...
54

55
install: deps
Kevin Atkinson's avatar
Kevin Atkinson committed
56
	make -C cmd/ipfs install
57

Jeromy's avatar
Jeromy committed
58
build: deps
Kevin Atkinson's avatar
Kevin Atkinson committed
59
	make -C cmd/ipfs build
60

Jeromy's avatar
Jeromy committed
61
nofuse: deps
Kevin Atkinson's avatar
Kevin Atkinson committed
62
	make -C cmd/ipfs nofuse
Henry's avatar
Henry committed
63

64
clean:
Kevin Atkinson's avatar
Kevin Atkinson committed
65
	make -C cmd/ipfs clean
66 67

uninstall:
Kevin Atkinson's avatar
Kevin Atkinson committed
68
	make -C cmd/ipfs uninstall
69

70
PHONY += all help godep gx_check
71
PHONY += go_check deps vendor install build nofuse clean uninstall
72

73 74 75
##############################################################
# tests targets

76
test: test_expensive
77

78
test_short: build test_go_short test_sharness_short
79

80
test_expensive: build test_go_expensive test_sharness_expensive windows_build_check
81

82 83
test_3node:
	cd test/3nodetest && make
Brian Tiger Chow's avatar
Brian Tiger Chow committed
84

85
test_go_short:
86
	$(go_test) -test.short ./...
87 88

test_go_expensive:
89
	$(go_test) ./...
90

Brian Tiger Chow's avatar
Brian Tiger Chow committed
91
test_go_race:
92
	$(go_test) ./... -race
Brian Tiger Chow's avatar
Brian Tiger Chow committed
93

94
test_sharness_short:
95
	make -C test/sharness/
96 97

test_sharness_expensive:
98
	TEST_EXPENSIVE=1 make -C test/sharness/
99 100 101 102 103 104

test_all_commits:
	@echo "testing all commits between origin/master..HEAD"
	@echo "WARNING: this will 'git rebase --exec'."
	@test/bin/continueyn
	GIT_EDITOR=true git rebase -i --exec "make test" origin/master
105 106 107 108 109 110 111 112

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
	GIT_EDITOR=true git rebase -i --exec "make test" master
113 114 115

# since we have CI for osx and linux but not windows, this should help
windows_build_check:
116
	GOOS=windows GOARCH=amd64 go build -o .test.ipfs.exe ./cmd/ipfs
117
	rm .test.ipfs.exe
118 119 120 121 122 123 124 125 126

PHONY += test test_short test_expensive

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

help:
	@echo 'DEPENDENCY TARGETS:'
	@echo ''
127
	@echo '  gx_check        - Installs or upgrades gx and gx-go'
128 129
	@echo '  deps            - Download dependencies using gx'
	@echo '  vendor          - Create a Godep workspace of 3rd party dependencies'
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
	@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)