master
mk 148 lines 4.06 KB
Raw
1 TGT_BIN :=
2 CLEAN :=
3 COVERAGE :=
4 DISTCLEAN :=
5 TEST :=
6 TEST_SHORT :=
7 GOCC ?= go
8 PROTOC ?= protoc
9
10 all: help # all has to be first defined target
11 .PHONY: all
12
13 include mk/git.mk # has to be before tarball.mk
14 include mk/tarball.mk
15 include mk/util.mk
16 include mk/golang.mk
17
18 # -------------------- #
19 # extra properties #
20 # -------------------- #
21
22 ifeq ($(TEST_FUSE),0)
23 GOTAGS += nofuse
24 endif
25 export LIBP2P_TCP_REUSEPORT=false
26
27 # -------------------- #
28 # sub-files #
29 # -------------------- #
30 dir := bin
31 include $(dir)/Rules.mk
32
33 # tests need access to rules from plugin
34 dir := plugin
35 include $(dir)/Rules.mk
36
37 dir := test
38 include $(dir)/Rules.mk
39
40 dir := cmd/ipfs
41 include $(dir)/Rules.mk
42
43 # include this file only if coverage target is executed
44 # it is quite expensive
45 ifneq ($(filter coverage% clean distclean test/unit/gotest.junit.xml,$(MAKECMDGOALS)),)
46 # has to be after cmd/ipfs due to PATH
47 dir := coverage
48 include $(dir)/Rules.mk
49 endif
50
51 # -------------------- #
52 # universal rules #
53 # -------------------- #
54
55 %.pb.go: %.proto bin/protoc-gen-gogofaster
56 $(PROTOC) --gogofaster_out=. --proto_path=.:$(GOPATH)/src:$(dir $@) $<
57
58 # -------------------- #
59 # core targets #
60 # -------------------- #
61
62 build: $(TGT_BIN)
63 .PHONY: build
64
65 clean:
66 rm -rf $(CLEAN)
67 .PHONY: clean
68
69 mod_tidy:
70 @find . -name go.mod -execdir $(GOCC) mod tidy \;
71 .PHONY: mod_tidy
72
73 coverage: $(COVERAGE)
74 .PHONY: coverage
75
76 distclean: clean
77 rm -rf $(DISTCLEAN)
78 git clean -ffxd
79 .PHONY: distclean
80
81 test: $(TEST)
82 .PHONY: test
83
84 test_short: $(TEST_SHORT)
85 .PHONY: test_short
86
87 deps:
88 .PHONY: deps
89
90 nofuse: GOTAGS += nofuse
91 nofuse: build
92 .PHONY: nofuse
93
94 install: cmd/ipfs-install
95 .PHONY: install
96
97 install_unsupported: install
98 @echo "/=======================================================================\\"
99 @echo '| |'
100 @echo '| `make install_unsupported` is deprecated, use `make install` instead. |'
101 @echo '| |'
102 @echo "\\=======================================================================/"
103 .PHONY: install_unsupported
104
105 uninstall:
106 $(GOCC) clean -i ./cmd/ipfs
107 .PHONY: uninstall
108
109 supported:
110 @echo "Currently supported platforms (from .github/build-platforms.yml):"
111 @grep '^ - ' .github/build-platforms.yml | sed 's/^ - //' || (echo "Error: .github/build-platforms.yml not found"; exit 1)
112 .PHONY: supported
113
114 help:
115 @echo 'DEPENDENCY TARGETS:'
116 @echo ''
117 @echo ' deps - Download dependencies using bundled gx'
118 @echo ' test_sharness_deps - Download and build dependencies for sharness'
119 @echo ''
120 @echo 'BUILD TARGETS:'
121 @echo ''
122 @echo ' all - print this help message'
123 @echo ' build - Build binary at ./cmd/ipfs/ipfs'
124 @echo ' nofuse - Build binary with no fuse support'
125 @echo ' install - Build binary and install into $$GOBIN'
126 @echo ' mod_tidy - Remove unused dependencies from go.mod files'
127 # @echo ' dist_install - TODO: c.f. ./cmd/ipfs/dist/README.md'
128 @echo ''
129 @echo 'CLEANING TARGETS:'
130 @echo ''
131 @echo ' clean - Remove files generated by build'
132 @echo ' distclean - Remove files that are no part of a repository'
133 @echo ' uninstall - Remove binary from $$GOPATH/bin'
134 @echo ''
135 @echo 'TESTING TARGETS:'
136 @echo ''
137 @echo ' test - Run all tests (test_go_fmt, test_unit, test_cli, test_sharness)'
138 @echo ' test_short - Run fast tests (test_go_fmt, test_unit)'
139 @echo ' test_unit - Run unit tests with coverage (excludes test/cli)'
140 @echo ' test_cli - Run CLI integration tests (requires built binary)'
141 @echo ' test_fuse - Run FUSE tests (requires /dev/fuse and fusermount)'
142 @echo ' test_go_fmt - Check Go source formatting'
143 @echo ' test_go_build - Build kubo for all platforms from .github/build-platforms.yml'
144 @echo ' test_go_lint - Run golangci-lint'
145 @echo ' test_sharness - Run sharness tests'
146 @echo ' coverage - Collect coverage info from unit tests and sharness'
147 @echo
148 .PHONY: help