-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.mak
100 lines (81 loc) · 2.7 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
NAME := bashbud
DESCRIPTION := make(1) bash scripting better
UPDATED := 2022-06-06
CREATED := 2022-04-05
VERSION := 2.2
AUTHOR := bud
ORGANISATION := budlabs
LICENSE := MIT
CONTACT := https://github.com/budlabs/bashbud
USAGE := bashbud --template TEMPLATE [OPTIONS] [DIRECTORY]
.PHONY: makefile
makefile: data/default/GNUmakefile
CUSTOM_TARGETS += makefile
data/default/GNUmakefile: $(wildcard Makefile.d/*)
@$(info genearating Makefile from Makefile.d)
cat $^ > $@
all: $(CUSTOM_TARGETS) $(MONOLITH) $(BASE)
MANPAGE_DEPS = \
$(CACHE_DIR)/help_table.txt \
$(CACHE_DIR)/long_help.md \
$(DOCS_DIR)/description.md \
$(CACHE_DIR)/copyright.txt
MANPAGE_OUT = $(MANPAGE)
$(MANPAGE_OUT): config.mak $(MANPAGE_DEPS)
@$(info making $@)
uppercase_name=$(NAME)
uppercase_name=$${uppercase_name^^}
{
echo "# $$uppercase_name " \
"$(manpage_section) $(UPDATED)" \
"$(ORGANISATION) \"User Manuals\""
printf '%s\n' '## NAME' \
'$(NAME) - $(DESCRIPTION)'
printf '%s\n' "## USAGE" "$(USAGE)"
cat $(DOCS_DIR)/description.md
echo "## OPTIONS"
sed 's/^/ /g' $(CACHE_DIR)/help_table.txt
cat $(CACHE_DIR)/long_help.md
printf '%s\n' '## CONTACT' \
"Send bugs and feature requests to: " "$(CONTACT)/issues"
printf '%s\n' '## COPYRIGHT'
cat $(CACHE_DIR)/copyright.txt
} | go-md2man > $@
README.md:
@$(making $@)
{
# cat $(DOCS_DIR)/reame_banner.md
# cat $(DOCS_DIR)/reame_install.md
# cat $(DOCS_DIR)/reame_usage.md
cat $(CACHE_DIR)/help_table.txt
} > $@
# README_LAYOUT = \
# $(DOCS_DIR)/readme_banner.md \
# $(DOCS_DIR)/readme_install.md \
# $(DOCS_DIR)/readme_usage.md \
# $(CACHE_DIR)/help_table.txt \
# $(DOCS_DIR)/readme_footer.md
.PHONY: check install uninstall manpage
manpage: $(MANPAGE)
check: all
shellcheck $(MONOLITH)
SHARE_DIR := $(DESTDIR)$(PREFIX)/share
ASSET_DIR := $(SHARE_DIR)/$(NAME)
installed_manpage = $(SHARE_DIR)/man/man$(manpage_section)/$(MANPAGE)
installed_script := $(DESTDIR)$(PREFIX)/bin/$(NAME)
installed_license := $(SHARE_DIR)/licenses/$(NAME)/LICENSE
$(CACHE_DIR)/$(NAME).out: $(MONOLITH)
m4 -DETC_CONFIG_DIR=$(PREFIX)/share/$(NAME) $< >$@
install: all $(CACHE_DIR)/$(NAME).out
install -Dm644 $(MANPAGE_OUT) $(installed_manpage)
install -Dm644 LICENSE $(installed_license)
install -Dm755 $(CACHE_DIR)/$(NAME).out $(installed_script)
mkdir -p $(ASSET_DIR)
cp -r data/* -t $(ASSET_DIR)
uninstall:
@for f in $(installed_script) $(installed_manpage) $(installed_license); do
[[ -f $$f ]] || continue
echo "rm $$f"
rm "$$f"
done
[[ -d $(ASSET_DIR) ]] && rm -r $(ASSET_DIR)