-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (51 loc) · 2.04 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
.PHONY := help
.DEFAULT_GOAL := help
# Directory structure
BINDIR := bin
LIBDIR := lib
MANDIR := man
WIKIDIR := wiki
# List scripts and libraries
ifneq ($(wildcard $(BINDIR)/),)
WIKI_DEPS += $(BINDIR)
SCRIPTS := $(sort $(shell find $(BINDIR) -type f -executable 2>/dev/null | sed "s/^$(BINDIR)\///"))
endif
ifneq ($(wildcard $(LIBDIR)/),)
WIKI_DEPS += $(LIBDIR)
LIBRARIES := $(sort $(shell find $(LIBDIR) -name '*.sh' 2>/dev/null | sed "s/^$(LIBDIR)\///"))
endif
# Deduce manpages and wikipages names from scripts and libraries
MANPAGES := $(addprefix $(MANDIR)/,$(addsuffix .1,$(SCRIPTS)) $(addsuffix .3,$(LIBRARIES)))
WIKIPAGES := $(addprefix $(WIKIDIR)/,$(addsuffix .md,$(SCRIPTS)) $(addsuffix .md,$(LIBRARIES)))
all: check-quality test ## Run quality and unit tests.
$(MANDIR)/%.1: $(BINDIR)/%
shellman -tmanpage $< -o $@
$(MANDIR)/%.sh.3: $(LIBDIR)/%.sh
shellman -tmanpage $< -o $@
$(WIKIDIR)/home.md: templates/wiki_home.md $(WIKI_DEPS)
shellman -tpath:$< -o $@ \
--context scripts="$(SCRIPTS)" \
libraries="$(LIBRARIES)"
$(WIKIDIR)/_sidebar.md: templates/wiki_sidebar.md $(WIKI_DEPS)
shellman -tpath:$< -o $@ \
--context scripts="$(SCRIPTS)" \
libraries="$(LIBRARIES)"
$(WIKIDIR)/%.md: $(BINDIR)/%
shellman -twikipage $< -o $@
$(WIKIDIR)/%.sh.md: $(LIBDIR)/%.sh
shellman -twikipage $< -o $@
man: $(MANPAGES) ## Generate man pages.
wiki: $(WIKIPAGES) $(WIKIDIR)/home.md $(WIKIDIR)/_sidebar.md ## Generate wiki pages.
doc: man wiki ## Generate man pages and wiki pages.
readme: templates/readme* .shellman.json ## Generate the README.
shellman -tpath:templates/readme.md -o README.md
check-style: ## Run the style tests.
bats tests/quality/test_shellcheck.bats
check-documentation: ## Run the documentation tests.
bats tests/quality/test_shellman.bats
check-quality: ## Run the quality tests.
bats tests/quality/*.bats
test: ## Run the unit tests.
bats tests/*.bats
help: ## Print this help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort