-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (120 loc) · 4.28 KB
/
Makefile
File metadata and controls
151 lines (120 loc) · 4.28 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# *── Makefile ── Makefile for deimonn.dev ──*
# │
# │ Copyright (c) 2025-2026 Deimonn
# │
# │ This file is licensed under the MIT License.
# │
# │ See https://deimonn.dev/license.txt for license information.
# │
# *
# SPDX-License-Identifier: MIT
.DEFAULT_GOAL = all
# Create build directories.
$(shell mkdir -p dist/assets obj)
# *─────────*
# │ Options
# *
# Node command line to use to run scripts.
NODE ?= node
# Path to the `void-guides` submodule.
VOID_GUIDES ?= src/submodules/void-guides
# *─────────*
# │ Targets
# *
# List of all targets.
targets =
# Licenses.
dist/license.txt: LICENSE
cp -f $< $@
dist/code-re2c/license.txt:
mkdir -p dist/code-re2c && curl -Lo $@ https://raw.githubusercontent.com/deimonn/code-re2c/master/LICENSE
dist/oro-theme/license.txt:
mkdir -p dist/oro-theme && curl -Lo $@ https://raw.githubusercontent.com/deimonn/oro-theme/master/LICENSE
targets += \
dist/license.txt \
dist/code-re2c/license.txt \
dist/oro-theme/license.txt
# Scripts.
dist/main.js: src/main.js
cp -f $< $@
targets += dist/main.js
# Oro theme.
obj/oro-theme.zip:
curl -Lo $@ https://github.com/deimonn/oro-theme/releases/download/v2.8.0/oro-theme-2.8.0.vsix
obj/oro-theme.json: obj/oro-theme.zip
unzip -p $< extension/dist/mainTheme.json > $@
# 404 page.
dist/404.html: src/templates/error.html src/main.html
# Generate intermediate.
TEMPLATE_NAME=error \
TEMPLATE_HTML=$$(cat $<) \
PAGE_ICON=/assets/icons/error.png \
PAGE_TITLE="404 Not Found - deimonn.dev" \
envsubst '$$TEMPLATE_NAME,$$TEMPLATE_HTML,$$PAGE_ICON,$$PAGE_TITLE' \
< src/main.html > obj/404.html.in
# Generate final.
ERROR_TITLE="404 Not Found" \
ERROR_DESCRIPTION="The page you're trying to access could not be found" \
envsubst '$$ERROR_TITLE,$$ERROR_DESCRIPTION' \
< obj/404.html.in > $@
targets += dist/404.html
# Home page.
dist/index.html: src/templates/home.html src/main.html
TEMPLATE_NAME=home \
TEMPLATE_HTML=$$(cat $<) \
PAGE_ICON=/assets/icons/home.png \
PAGE_TITLE=deimonn.dev \
envsubst '$$TEMPLATE_NAME,$$TEMPLATE_HTML,$$PAGE_ICON,$$PAGE_TITLE' \
< src/main.html > $@
targets += dist/index.html
# Documentation for 'void-guides'.
void_guides_sources = \
$(VOID_GUIDES)/index.md \
$(wildcard $(VOID_GUIDES)/*/*.md)
void_guides_outputs = \
$(patsubst $(VOID_GUIDES)/%.md,dist/void-guides/%.html,$(void_guides_sources))
dist/void-guides/search-db.json obj/void-guides/nav-db.json: \
compile-db.js $(void_guides_sources)
mkdir -p dist/void-guides obj/void-guides
$(NODE) compile-db.js \
'$(VOID_GUIDES)' void-guides void-guides/ \
$(sort $(void_guides_sources))
dist/void-guides/%.html: \
src/templates/docs.html src/main.html \
$(VOID_GUIDES)/%.md $(VOID_GUIDES)/categories.json \
compile-markdown.js obj/oro-theme.json obj/void-guides/nav-db.json
# Create directories.
mkdir -p "$$(dirname $(subst dist/void-guides/,obj/void-guides/,$@))"
mkdir -p "$$(dirname $@)"
# Compile markdown.
$(NODE) compile-markdown.js \
'$(VOID_GUIDES)' void-guides void-guides/ \
$(patsubst dist/void-guides/%.html,%,$@)
# Generate page from template.
TEMPLATE_NAME="docs" \
TEMPLATE_HTML="$$(cat $<)" \
PAGE_ICON="/assets/icons/void.png" \
envsubst '$$TEMPLATE_NAME,$$TEMPLATE_HTML,$$PAGE_ICON' \
< src/main.html > $(patsubst dist/void-guides/%.html,obj/void-guides/%.in.html,$@)
PAGE_TITLE="$$(cat $(patsubst dist/void-guides/%.html,obj/void-guides/%.name.txt,$@)) - void-guides - deimonn.dev" \
DOCS_REPO="void-guides" \
DOCS_MAINHTML="$$(cat $(patsubst dist/void-guides/%.html,obj/void-guides/%.html,$@))" \
DOCS_NAVHTML="$$(cat $(patsubst dist/void-guides/%.html,obj/void-guides/%.nav.html,$@))" \
DOCS_TOCHTML="$$(cat $(patsubst dist/void-guides/%.html,obj/void-guides/%.toc.html,$@))" \
envsubst '$$PAGE_TITLE,$$DOCS_REPO,$$DOCS_MAINHTML,$$DOCS_NAVHTML,$$DOCS_TOCHTML' \
< $(patsubst dist/void-guides/%.html,obj/void-guides/%.in.html,$@) > $@
targets += dist/void-guides/search-db.json $(void_guides_outputs)
# *───────*
# │ Phony
# *
# Build.
.PHONY: all
all: assets $(targets)
# Clean up artifacts.
.PHONY: clean
clean: ; -rm -rf dist/ obj/
# Copy assets.
.PHONY: assets
assets: ; cp -ruf src/assets/* dist/assets/
# Debugging utility.
debug-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true