Skip to content

Commit b3a6572

Browse files
caseyloverjan90
andauthored
chore: add help target to Makefile to display the usage of all targets (#12812)
chore: add help target to Makefile to display the usage of all targets Co-authored-by: Phi-rjan <[email protected]>
1 parent f422705 commit b3a6572

File tree

1 file changed

+71
-67
lines changed

1 file changed

+71
-67
lines changed

Makefile

Lines changed: 71 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SHELL=/usr/bin/env bash
22

3-
all: build
3+
all: build ## Build all main binaries (default target)
4+
45
.PHONY: all
56

67
unexport GOFLAGS
@@ -46,13 +47,13 @@ MODULES+=$(FFI_PATH)
4647
BUILD_DEPS+=build/.filecoin-install
4748
CLEAN+=build/.filecoin-install
4849

49-
ffi-version-check:
50+
ffi-version-check: ## Check FFI version compatibility
5051
@[[ "$$(awk '/const Version/{print $$5}' extern/filecoin-ffi/version.go)" -eq 3 ]] || (echo "FFI version mismatch, update submodules"; exit 1)
5152
BUILD_DEPS+=ffi-version-check
5253

5354
.PHONY: ffi-version-check
5455

55-
$(MODULES): build/.update-modules ;
56+
$(MODULES): build/.update-modules ; ## Update git submodules
5657
# dummy file that marks the last time modules were updated
5758
build/.update-modules:
5859
git submodule update --init --recursive
@@ -64,169 +65,169 @@ build/.update-modules:
6465

6566
CLEAN+=build/.update-modules
6667

67-
deps: $(BUILD_DEPS)
68+
deps: $(BUILD_DEPS) ## Install build dependencies
6869
.PHONY: deps
6970

70-
build-devnets: build lotus-seed lotus-shed
71+
build-devnets: build lotus-seed lotus-shed ## Build binaries for development networks
7172
.PHONY: build-devnets
7273

7374
debug: GOFLAGS+=-tags=debug
74-
debug: build-devnets
75+
debug: build-devnets ## Build with debug tags
7576

7677
2k: GOFLAGS+=-tags=2k
77-
2k: build-devnets
78+
2k: build-devnets ## Build for 2k network
7879

7980
calibnet: GOFLAGS+=-tags=calibnet
80-
calibnet: build-devnets
81+
calibnet: build-devnets ## Build for calibnet network
8182

8283
butterflynet: GOFLAGS+=-tags=butterflynet
83-
butterflynet: build-devnets
84+
butterflynet: build-devnets ## Build for butterflynet network
8485

8586
interopnet: GOFLAGS+=-tags=interopnet
86-
interopnet: build-devnets
87+
interopnet: build-devnets ## Build for interopnet network
8788

88-
lotus: $(BUILD_DEPS)
89+
lotus: $(BUILD_DEPS) ## Build the main Lotus binary
8990
rm -f lotus
9091
$(GOCC) build $(GOFLAGS) -o lotus ./cmd/lotus
9192

9293
.PHONY: lotus
9394
BINS+=lotus
9495

95-
lotus-miner: $(BUILD_DEPS)
96+
lotus-miner: $(BUILD_DEPS) ## Build the Lotus miner binary
9697
rm -f lotus-miner
9798
$(GOCC) build $(GOFLAGS) -o lotus-miner ./cmd/lotus-miner
9899
.PHONY: lotus-miner
99100
BINS+=lotus-miner
100101

101-
lotus-worker: $(BUILD_DEPS)
102+
lotus-worker: $(BUILD_DEPS) ## Build the Lotus worker binary
102103
rm -f lotus-worker
103104
$(GOCC) build $(GOFLAGS) -o lotus-worker ./cmd/lotus-worker
104105
.PHONY: lotus-worker
105106
BINS+=lotus-worker
106107

107-
lotus-shed: $(BUILD_DEPS)
108+
lotus-shed: $(BUILD_DEPS) ## Build the Lotus shed tool
108109
rm -f lotus-shed
109110
$(GOCC) build $(GOFLAGS) -o lotus-shed ./cmd/lotus-shed
110111
.PHONY: lotus-shed
111112
BINS+=lotus-shed
112113

113-
lotus-gateway: $(BUILD_DEPS)
114+
lotus-gateway: $(BUILD_DEPS) ## Build the Lotus gateway
114115
rm -f lotus-gateway
115116
$(GOCC) build $(GOFLAGS) -o lotus-gateway ./cmd/lotus-gateway
116117
.PHONY: lotus-gateway
117118
BINS+=lotus-gateway
118119

119-
build: lotus lotus-miner lotus-worker
120+
build: lotus lotus-miner lotus-worker ## Build all main binaries
120121
@[[ $$(type -P "lotus") ]] && echo "Caution: you have \
121122
an existing lotus binary in your PATH. This may cause problems if you don't run 'sudo make install'" || true
122123

123124
.PHONY: build
124125

125-
install: install-daemon install-miner install-worker
126+
install: install-daemon install-miner install-worker ## Install all binaries
126127

127-
install-daemon:
128+
install-daemon: ## Install the Lotus daemon
128129
install -C ./lotus /usr/local/bin/lotus
129130

130-
install-miner:
131+
install-miner: ## Install the Lotus miner
131132
install -C ./lotus-miner /usr/local/bin/lotus-miner
132133

133-
install-worker:
134+
install-worker: ## Install the Lotus worker
134135
install -C ./lotus-worker /usr/local/bin/lotus-worker
135136

136-
install-app:
137+
install-app: ## Install a specified app
137138
install -C ./$(APP) /usr/local/bin/$(APP)
138139

139-
uninstall: uninstall-daemon uninstall-miner uninstall-worker
140+
uninstall: uninstall-daemon uninstall-miner uninstall-worker ## Uninstall all binaries
140141
.PHONY: uninstall
141142

142-
uninstall-daemon:
143+
uninstall-daemon: ## Uninstall the Lotus daemon
143144
rm -f /usr/local/bin/lotus
144145

145-
uninstall-miner:
146+
uninstall-miner: ## Uninstall the Lotus miner
146147
rm -f /usr/local/bin/lotus-miner
147148

148-
uninstall-worker:
149+
uninstall-worker: ## Uninstall the Lotus worker
149150
rm -f /usr/local/bin/lotus-worker
150151

151152
# TOOLS
152153

153-
lotus-seed: $(BUILD_DEPS)
154+
lotus-seed: $(BUILD_DEPS) ## Build the Lotus seed tool
154155
rm -f lotus-seed
155156
$(GOCC) build $(GOFLAGS) -o lotus-seed ./cmd/lotus-seed
156157

157158
.PHONY: lotus-seed
158159
BINS+=lotus-seed
159160

160-
benchmarks:
161+
benchmarks: ## Run benchmarks and submit results
161162
$(GOCC) run github.com/whyrusleeping/bencher ./... > bench.json
162163
@echo Submitting results
163164
@curl -X POST 'http://benchmark.kittyhawk.wtf/benchmark' -d '@bench.json' -u "${benchmark_http_cred}"
164165
.PHONY: benchmarks
165166

166-
lotus-fountain:
167+
lotus-fountain: ## Build the Lotus fountain tool
167168
rm -f lotus-fountain
168169
$(GOCC) build $(GOFLAGS) -o lotus-fountain ./cmd/lotus-fountain
169170
$(GOCC) run github.com/GeertJohan/go.rice/rice append --exec lotus-fountain -i ./cmd/lotus-fountain -i ./build
170171
.PHONY: lotus-fountain
171172
BINS+=lotus-fountain
172173

173-
lotus-bench:
174+
lotus-bench: ## Build the Lotus bench tool
174175
rm -f lotus-bench
175176
$(GOCC) build $(GOFLAGS) -o lotus-bench ./cmd/lotus-bench
176177
.PHONY: lotus-bench
177178
BINS+=lotus-bench
178179

179-
lotus-stats:
180+
lotus-stats: ## Build the Lotus stats tool
180181
rm -f lotus-stats
181182
$(GOCC) build $(GOFLAGS) -o lotus-stats ./cmd/lotus-stats
182183
.PHONY: lotus-stats
183184
BINS+=lotus-stats
184185

185-
lotus-pcr:
186+
lotus-pcr: ## Build the Lotus PCR tool
186187
rm -f lotus-pcr
187188
$(GOCC) build $(GOFLAGS) -o lotus-pcr ./cmd/lotus-pcr
188189
.PHONY: lotus-pcr
189190
BINS+=lotus-pcr
190191

191-
lotus-health:
192+
lotus-health: ## Build the Lotus health tool
192193
rm -f lotus-health
193194
$(GOCC) build -o lotus-health ./cmd/lotus-health
194195
.PHONY: lotus-health
195196
BINS+=lotus-health
196197

197-
lotus-wallet: $(BUILD_DEPS)
198+
lotus-wallet: $(BUILD_DEPS) ## Build the Lotus wallet tool
198199
rm -f lotus-wallet
199200
$(GOCC) build $(GOFLAGS) -o lotus-wallet ./cmd/lotus-wallet
200201
.PHONY: lotus-wallet
201202
BINS+=lotus-wallet
202203

203-
lotus-keygen:
204+
lotus-keygen: ## Build the Lotus keygen tool
204205
rm -f lotus-keygen
205206
$(GOCC) build -o lotus-keygen ./cmd/lotus-keygen
206207
.PHONY: lotus-keygen
207208
BINS+=lotus-keygen
208209

209-
testground:
210+
testground: ## Build for testground
210211
$(GOCC) build -tags testground -o /dev/null ./cmd/lotus
211212
.PHONY: testground
212213
BINS+=testground
213214

214215

215-
tvx:
216+
tvx: ## Build the TVX tool
216217
rm -f tvx
217218
$(GOCC) build -o tvx ./cmd/tvx
218219
.PHONY: tvx
219220
BINS+=tvx
220221

221-
lotus-sim: $(BUILD_DEPS)
222+
lotus-sim: $(BUILD_DEPS) ## Build the Lotus simulator
222223
rm -f lotus-sim
223224
$(GOCC) build $(GOFLAGS) -o lotus-sim ./cmd/lotus-sim
224225
.PHONY: lotus-sim
225226
BINS+=lotus-sim
226227

227228
# SYSTEMD
228229

229-
install-daemon-service: install-daemon
230+
install-daemon-service: install-daemon ## Install systemd service for Lotus daemon
230231
mkdir -p /etc/systemd/system
231232
mkdir -p /var/log/lotus
232233
install -C -m 0644 ./scripts/lotus-daemon.service /etc/systemd/system/lotus-daemon.service
@@ -236,7 +237,7 @@ install-daemon-service: install-daemon
236237
@echo "To start the service, run: 'sudo systemctl start lotus-daemon'"
237238
@echo "To enable the service on startup, run: 'sudo systemctl enable lotus-daemon'"
238239

239-
install-miner-service: install-miner install-daemon-service
240+
install-miner-service: install-miner install-daemon-service ## Install systemd service for Lotus miner
240241
mkdir -p /etc/systemd/system
241242
mkdir -p /var/log/lotus
242243
install -C -m 0644 ./scripts/lotus-miner.service /etc/systemd/system/lotus-miner.service
@@ -246,81 +247,80 @@ install-miner-service: install-miner install-daemon-service
246247
@echo "To start the service, run: 'sudo systemctl start lotus-miner'"
247248
@echo "To enable the service on startup, run: 'sudo systemctl enable lotus-miner'"
248249

249-
install-main-services: install-miner-service
250+
install-main-services: install-miner-service ## Install main systemd services
250251

251-
install-all-services: install-main-services
252+
install-all-services: install-main-services ## Install all systemd services
252253

253-
install-services: install-main-services
254+
install-services: install-main-services ## Alias for installing main services
254255

255-
clean-daemon-service: clean-miner-service
256+
clean-daemon-service: clean-miner-service ## Clean systemd service for Lotus daemon
256257
-systemctl stop lotus-daemon
257258
-systemctl disable lotus-daemon
258259
rm -f /etc/systemd/system/lotus-daemon.service
259260
systemctl daemon-reload
260261

261-
clean-miner-service:
262+
clean-miner-service: ## Clean systemd service for Lotus miner
262263
-systemctl stop lotus-miner
263264
-systemctl disable lotus-miner
264265
rm -f /etc/systemd/system/lotus-miner.service
265266
systemctl daemon-reload
266267

267-
clean-main-services: clean-daemon-service
268+
clean-main-services: clean-daemon-service ## Clean main systemd services
268269

269-
clean-all-services: clean-main-services
270+
clean-all-services: clean-main-services ## Clean all systemd services
270271

271-
clean-services: clean-all-services
272+
clean-services: clean-all-services ## Alias for cleaning all services
272273

273274
# MISC
275+
buildall: $(BINS) ## Build all binaries
274276

275-
buildall: $(BINS)
276-
277-
install-completions:
277+
install-completions: ## Install shell completions
278278
mkdir -p /usr/share/bash-completion/completions /usr/local/share/zsh/site-functions/
279279
install -C ./scripts/bash-completion/lotus /usr/share/bash-completion/completions/lotus
280280
install -C ./scripts/zsh-completion/lotus /usr/local/share/zsh/site-functions/_lotus
281281

282-
unittests:
282+
unittests: ## Run unit tests
283283
@$(GOCC) test $(shell go list ./... | grep -v /lotus/itests)
284284
.PHONY: unittests
285285

286-
clean:
286+
clean: ## Clean build artifacts
287287
rm -rf $(CLEAN) $(BINS)
288288
-$(MAKE) -C $(FFI_PATH) clean
289289
.PHONY: clean
290290

291-
dist-clean:
291+
dist-clean: ## Thoroughly clean, including git submodules
292292
git clean -xdff
293293
git submodule deinit --all -f
294294
.PHONY: dist-clean
295295

296-
type-gen: api-gen
296+
type-gen: api-gen ## Generate type information
297297
$(GOCC) run ./gen/main.go
298298
$(GOCC) generate -x ./...
299299
$(FIX_IMPORTS)
300300

301-
actors-code-gen:
301+
actors-code-gen: ## Generate actor code
302302
$(GOCC) run ./gen/inline-gen . gen/inlinegen-data.json
303303
$(GOCC) run ./chain/actors/agen
304304
$(GOCC) fmt ./...
305305

306-
actors-gen: actors-code-gen
306+
actors-gen: actors-code-gen ## Generate actors
307307
$(GOCC) run ./scripts/fiximports
308308
.PHONY: actors-gen
309309

310-
bundle-gen:
310+
bundle-gen: ## Generate bundle
311311
$(GOCC) run ./gen/bundle $(VERSION) $(RELEASE) $(RELEASE_OVERRIDES)
312312
$(GOCC) fmt ./build/...
313313
.PHONY: bundle-gen
314314

315-
api-gen:
315+
api-gen: ## Generate API
316316
$(GOCC) run ./gen/api
317317
$(FIX_IMPORTS)
318318
.PHONY: api-gen
319319

320-
cfgdoc-gen:
320+
cfgdoc-gen: ## Generate configuration documentation
321321
$(GOCC) run ./node/config/cfgdocgen > ./node/config/doc_gen.go
322322

323-
appimage: lotus
323+
appimage: lotus ## Build AppImage
324324
rm -rf appimage-builder-cache || true
325325
rm AppDir/io.filecoin.lotus.desktop || true
326326
rm AppDir/icon.svg || true
@@ -329,29 +329,33 @@ appimage: lotus
329329
cp ./lotus AppDir/usr/bin/
330330
appimage-builder
331331

332-
docsgen: fiximports
332+
docsgen: fiximports ## Generate documentation
333333
$(GOCC) run ./gen/docs
334334
.PHONY: docsgen
335335

336-
fiximports:
336+
fiximports: ## Fix imports
337337
$(FIX_IMPORTS)
338338
.PHONY: fiximports
339339

340-
gen: actors-code-gen type-gen cfgdoc-gen docsgen api-gen
340+
gen: actors-code-gen type-gen cfgdoc-gen docsgen api-gen ## Run all generation tasks
341341
$(GOCC) run ./scripts/fiximports
342342
@echo ">>> IF YOU'VE MODIFIED THE CLI OR CONFIG, REMEMBER TO ALSO RUN 'make docsgen-cli'"
343343
.PHONY: gen
344344

345-
jen: gen
345+
jen: gen ## Alias for gen
346346

347-
snap: lotus lotus-miner lotus-worker
347+
snap: lotus lotus-miner lotus-worker ## Build snap package
348348
snapcraft
349349
# snapcraft upload ./lotus_*.snap
350350

351-
docsgen-cli:
351+
# separate from gen because it needs binaries
352+
docsgen-cli: lotus lotus-miner lotus-worker ## Generate CLI documentation
352353
$(GOCC) run ./scripts/docsgen-cli
353354
.PHONY: docsgen-cli
354355

355-
print-%:
356+
print-%: ## Print variable value
356357
@echo $*=$($*)
357358

359+
help: ## Display this help message
360+
@echo "Available targets:"
361+
@awk 'BEGIN {FS = ":.*?## "}; /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

0 commit comments

Comments
 (0)