Skip to content

Commit daa6ffa

Browse files
authored
Merge pull request #10608 from cabalism/doc/makefile-10596
Add help target to the makefile
2 parents 1f52963 + cf22b10 commit daa6ffa

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

Makefile

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,55 @@ DOCTEST := cabal doctest --allow-newer=False
1212
# default rules
1313

1414
.PHONY: all
15-
all : exe lib
15+
all: help-banner exe lib ## Build the Cabal libraries and cabal-install executables.
1616

1717
.PHONY: lib
18-
lib :
18+
lib: ## Builds the Cabal libraries.
1919
$(CABALBUILD) Cabal:libs
2020

2121
.PHONY: exe
22-
exe :
22+
exe: ## Builds the cabal-install executables.
2323
$(CABALBUILD) cabal-install:exes
2424

2525
.PHONY: init
26-
init: ## Set up git hooks and ignored revisions
26+
init: ## Set up git hooks and ignored revisions.
2727
@git config core.hooksPath .githooks
2828
## TODO
2929

3030
.PHONY: style
31-
style: ## Run the code styler
31+
style: ## Run the code styler.
3232
@fourmolu -q -i Cabal Cabal-syntax cabal-install cabal-validate
3333

3434
.PHONY: style-modified
35-
style-modified: ## Run the code styler on modified files
35+
style-modified: ## Run the code styler on modified files.
3636
@git ls-files --modified Cabal Cabal-syntax cabal-install cabal-validate \
3737
| grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {}
3838

3939
.PHONY: style-commit
40-
style-commit: ## Run the code styler on the previous commit
40+
style-commit: ## Run the code styler on the previous commit.
4141
@git diff --name-only HEAD $(COMMIT) Cabal Cabal-syntax cabal-install cabal-validate \
4242
| grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {}
4343

4444
.PHONY: whitespace
45-
whitespace: ## Run fix-whitespace in check mode
45+
whitespace: ## Run fix-whitespace in check mode.
4646
fix-whitespace --check --verbose
4747

4848
.PHONY: fix-whitespace
49-
fix-whitespace: ## Run fix-whitespace in fix mode
49+
fix-whitespace: ## Run fix-whitespace in fix mode.
5050
fix-whitespace --verbose
5151

5252
.PHONY: lint
53-
lint: ## Run HLint
53+
lint: ## Run HLint.
5454
hlint -j .
5555

5656
.PHONY: lint-json
57-
lint-json: ## Run HLint in JSON mode
57+
lint-json: ## Run HLint in JSON mode.
5858
hlint -j --json -- .
5959

6060
# local checks
6161

6262
.PHONY: checks
63-
checks: whitespace users-guide-typos markdown-typos style lint-json
63+
checks: whitespace users-guide-typos markdown-typos style lint-json ## Run all local checks; whitespace, typos, style, and lint.
6464

6565
# source generation: SPDX
6666

@@ -116,15 +116,15 @@ analyse-imports :
116116
# ghcid
117117

118118
.PHONY: ghcid-lib
119-
ghcid-lib :
119+
ghcid-lib: ## Run ghcid for the Cabal library.
120120
ghcid -c 'cabal repl Cabal'
121121

122122
.PHONY: ghcid-cli
123-
ghcid-cli :
123+
ghcid-cli: ## Run ghcid for the cabal-install executable.
124124
ghcid -c 'cabal repl cabal-install'
125125

126126
.PHONY: doctest
127-
doctest :
127+
doctest: ## Run doctests.
128128
cd Cabal-syntax && $(DOCTEST)
129129
cd Cabal-described && $(DOCTEST)
130130
cd Cabal && $(DOCTEST)
@@ -137,7 +137,7 @@ doctest-cli :
137137
doctest -D__DOCTEST__ --fast cabal-install/src cabal-install-solver/src cabal-install-solver/src-assertion
138138

139139
.PHONY: doctest-install
140-
doctest-install:
140+
doctest-install: ## Install doctest tool needed for running doctests.
141141
cabal install doctest --overwrite-policy=always --ignore-project --flag cabal-doctest
142142

143143
# tests
@@ -234,7 +234,7 @@ validate-via-docker-old:
234234

235235
# tags
236236
.PHONY : tags
237-
tags :
237+
tags: ## Generate editor tags, vim ctags and emacs etags.
238238
hasktags -b Cabal-syntax/src Cabal/src Cabal-described/src cabal-install/src cabal-testsuite/src
239239

240240
# bootstrapping
@@ -256,11 +256,11 @@ bootstrap-jsons: $(BOOTSTRAP_GHC_VERSIONS:%=bootstrap-json-%)
256256
##############################################################################
257257

258258
.PHONY: users-guide
259-
users-guide:
259+
users-guide: ## Build the users guide.
260260
$(MAKE) -C doc users-guide
261261

262262
.PHONY: users-guide-requirements
263-
users-guide-requirements:
263+
users-guide-requirements: ## Install the requirements for building the users guide.
264264
$(MAKE) -C doc users-guide-requirements
265265

266266
ifeq ($(shell uname), Darwin)
@@ -269,6 +269,18 @@ else
269269
PROCS := $(shell nproc)
270270
endif
271271

272+
PHONY: help
273+
help: ## Show the commented targets.
274+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
275+
sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
276+
277+
PHONY: help-banner
278+
help-banner: ## Show the help banner.
279+
@echo "===================================================================="
280+
@echo "§ all make with no arguments also shows this banner"
281+
@echo "§ help make help will list targets with descriptions"
282+
@echo "===================================================================="
283+
272284
.PHONY: typos-install
273285
typos-install: ## Install typos-cli for typos target using cargo
274286
cargo install typos-cli

0 commit comments

Comments
 (0)