-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.mak
107 lines (88 loc) · 3.15 KB
/
config.mak
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
NAME := typiskt
DESCRIPTION := terminal touch typing training
CREATED := 2020-06-08
UPDATED := 2022-06-30
VERSION := 2022.06.30.1
AUTHOR := budRich
ORGANISATION := budlabs
CONTACT := https://github.com/budlabs/typiskt
USAGE := $(NAME) [OPTIONS]
LICENSE := BSD-2-Clause
README_DEPS = \
$(DOCS_DIR)/readme_banner.md \
$(DOCS_DIR)/readme_install.md \
$(CACHE_DIR)/help_table.txt \
$(DOCS_DIR)/readme_description.md \
$(DOCS_DIR)/readme_footer.md \
README.md: $(README_DEPS)
@$(info making $@)
{
echo "# $(NAME) - $(DESCRIPTION)"
cat $(DOCS_DIR)/readme_banner.md
cat $(DOCS_DIR)/readme_install.md
echo "## usage"
echo " $(USAGE)"
sed 's/^/ /g' $(CACHE_DIR)/help_table.txt
cat $(DOCS_DIR)/readme_description.md
cat $(DOCS_DIR)/readme_footer.md
} > $@
MANPAGE_DEPS = \
$(CACHE_DIR)/synopsis.txt \
$(CACHE_DIR)/help_table.txt \
$(CACHE_DIR)/long_help.md \
$(DOCS_DIR)/readme_description.md \
$(DOCS_DIR)/manpage_environment.md \
$(CACHE_DIR)/copyright.txt
MANPAGE := $(NAME).1
.PHONY: manpage
manpage: $(MANPAGE)
$(MANPAGE): config.mak $(MANPAGE_DEPS)
@$(info making $@)
uppercase_name=$(NAME)
uppercase_name=$${uppercase_name^^}
{
# this first "<h1>" adds "corner" info to the manpage
echo "# $$uppercase_name " \
"$(manpage_section) $(UPDATED)" \
"$(ORGANISATION) \"User Manuals\""
# main sections (NAME|OPTIONS..) should be "<h2>" (##), sub (###) ...
printf '%s\n' '## NAME' \
'$(NAME) - $(DESCRIPTION)'
echo "## SYNOPSIS"
sed 's/^/ /g' $(CACHE_DIR)/synopsis.txt
echo "## USAGE"
cat $(DOCS_DIR)/readme_description.md
echo "## OPTIONS"
sed 's/^/ /g' $(CACHE_DIR)/help_table.txt
cat $(CACHE_DIR)/long_help.md
cat $(DOCS_DIR)/manpage_environment.md
printf '%s\n' '## CONTACT' \
"Send bugs and feature requests to: " "$(CONTACT)/issues"
printf '%s\n' '## COPYRIGHT'
cat $(CACHE_DIR)/copyright.txt
} | go-md2man > $@
# --- INSTALLATION RULES --- #
BINDIR ?= $(DESTDIR)$(PREFIX)/bin
SHRDIR ?= $(DESTDIR)$(PREFIX)/share
ASSETDIR = $(SHRDIR)/$(NAME)
installed_script := $(DESTDIR)$(PREFIX)/bin/$(NAME)
installed_license := $(DESTDIR)$(PREFIX)/share/licenses/$(NAME)/LICENSE
installed_manpage := \
$(DESTDIR)$(PREFIX)/share/man/man$(subst .,,$(suffix $(MANPAGE)))/$(MANPAGE)
_$(NAME).out: $(MONOLITH)
m4 -DETC_CONFIG_DIR=$(PREFIX)/share/$(NAME) $< >$@
install: _$(NAME).out all
install -Dm644 $(MANPAGE) $(installed_manpage)
install -Dm755 _$(NAME).out $(installed_script)
install -Dm644 LICENSE $(installed_license)
install -Dm755 config/exercises/add-gtypist-exercises.sh -t $(ASSETDIR)/exercises
install -Dm644 config/wordlists/* -t $(ASSETDIR)/wordlists
install -Dm644 config/exercises/README.md -t $(ASSETDIR)/exercises
install -Dm644 config/wordmasks -t $(ASSETDIR)
install -Dm644 config/config -t $(ASSETDIR)
uninstall:
rm $(installed_script)
rm -rf $(ASSETDIR)
rm $(installed_manpage)
rm $(installed_license)
rmdir $(dir $(installed_license))