-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.mak
111 lines (93 loc) · 3.04 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
108
109
110
111
NAME := i3term
CREATED := 2022-07-14
UPDATED := 2022-07-28
VERSION := 0.2
DESCRIPTION := launch terminals with i3run
AUTHOR := budRich
CONTACT := https://github.com/budlabs/i3term
ORGANISATION := budlabs
LICENSE := 0BSD
USAGE := $(NAME) [OPTIONS]
PREFIX ?= /usr
MANPAGE_DEPS = \
$(CACHE_DIR)/help_table.txt \
$(CACHE_DIR)/long_help.md \
$(wildcard $(DOCS_DIR)/examples/*) \
$(DOCS_DIR)/description.md \
$(DOCS_DIR)/links.md \
$(CACHE_DIR)/copyright.txt
manpage_section = 1
MANPAGE = $(NAME).$(manpage_section)
.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 "## USAGE"
echo '`$(USAGE)` '
cat $(DOCS_DIR)/description.md
echo "## OPTIONS"
sed 's/^/ /g' $(CACHE_DIR)/help_table.txt
cat $(CACHE_DIR)/long_help.md
echo "## EXAMPLES"
cat $(DOCS_DIR)/examples/*
printf '%s\n' '## CONTACT' \
"Send bugs and feature requests to: " "$(CONTACT)/issues"
printf '%s\n' '## COPYRIGHT'
cat $(CACHE_DIR)/copyright.txt
cat $(DOCS_DIR)/links.md
} | go-md2man > $@
README_DEPS = \
$(CACHE_DIR)/help_table.txt \
$(CACHE_DIR)/long_help.md \
$(wildcard $(DOCS_DIR)/examples/*) \
$(DOCS_DIR)/links.md \
$(DOCS_DIR)/readme_install.md \
$(DOCS_DIR)/readme_banner.md \
$(DOCS_DIR)/description.md \
$(DOCS_DIR)/links.md
README.md: $(README_DEPS)
@$(making $@)
{
cat $(DOCS_DIR)/readme_banner.md
echo "## installation"
cat $(DOCS_DIR)/readme_install.md
echo "## usage"
cat $(DOCS_DIR)/description.md
echo '```'
echo '$(USAGE)'
cat "$(CACHE_DIR)/help_table.txt"
echo '```'
echo "## examples"
cat $(DOCS_DIR)/examples/*
cat $(DOCS_DIR)/links.md
} > $@
$(CACHE_DIR)/_$(NAME).out: $(MONOLITH)
sed 's|@@DATA_DIR@@|$(PREFIX)/share/$(NAME)|' $< >$@
.PHONY: install uninstall
installed_script := $(DESTDIR)$(PREFIX)/bin/$(NAME)
installed_license := $(DESTDIR)$(PREFIX)/share/licenses/$(NAME)/LICENSE
installed_manpage := \
$(DESTDIR)$(PREFIX)/share/man/man$(manpage_section)/$(MANPAGE)
DATA_DIR := $(DESTDIR)$(PREFIX)/share/$(NAME)
install: $(CACHE_DIR)/_$(NAME).out all
install -Dm644 $(MANPAGE) $(installed_manpage)
install -Dm755 $(CACHE_DIR)/_$(NAME).out $(installed_script)
install -Dm644 LICENSE $(installed_license)
install -Dm644 data/palettes/* -t $(DATA_DIR)/palettes
install -Dm644 data/config -t $(DATA_DIR)
uninstall:
rm $(installed_script)
rm -rf $(DATA_DIR)
rm $(installed_manpage)
rm $(installed_license)
rmdir $(dir $(installed_license))