-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (52 loc) · 1.64 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
SOURCE = source
BUILD = build
ARTICLES = $(patsubst $(SOURCE)/%.adoc, %, $(wildcard $(SOURCE)/*.adoc))
BUILT_HTML_ARTICLES = $(patsubst %, $(BUILD)/%.html, $(ARTICLES))
BUILT_PDF_ARTICLES = $(patsubst %, $(BUILD)/%.pdf, $(ARTICLES))
ifndef AUTHOR
$(error AUTHOR is not set)
endif
ifndef BASEURL
$(error BASEURL is not set)
endif
ifndef EMAIL
$(error EMAIL is not set)
endif
ifndef HOMEPAGE
$(error HOMEPAGE is not set)
endif
ifndef REVNUMBER
$(error REVNUMBER is not set)
endif
ASCIIDOCTOR_FLAGS = $\
--doctype article $\
--safe-mode server $\
--attribute source-highlighter=rouge $\
--attribute prewrap! $\
--attribute author="$(AUTHOR)" $\
--attribute email=$(EMAIL) $\
--attribute homepage="$(HOMEPAGE)" $\
--attribute revnumber=$(REVNUMBER)
ASCIIDOCTOR_HTML_FLAGS = $\
--out-file "$(BUILD)/$*.html" $\
--attribute imagesdir="$(BASEURL)/blog/raw/$*" $\
--backend html5 $\
--attribute nofooter $\
--attribute webfonts!
ASCIIDOCTOR_PDF_FLAGS = $\
--out-file "$(BUILD)/$*.pdf" $\
--attribute imagesdir="$*" $\
--backend pdf $\
--attribute pdf-theme="pdf-theme.yml"
# TODO: This has an optional pre-requisite `$(SOURCE)/%` producing the optional target `$(BUILD)/%`.
$(BUILT_HTML_ARTICLES): $(BUILD)/%.html: $(SOURCE)/%.adoc $(BUILD)
asciidoctor "$<" $(ASCIIDOCTOR_FLAGS) $(ASCIIDOCTOR_HTML_FLAGS)
sed -i 's/^<head>$$/<head>\n<base target="_parent">/' "$(BUILD)/$*.html"
if [ -d "$(SOURCE)/$*" ]; then cp --recursive "$(SOURCE)/$*" "$(BUILD)/$*"; fi
$(BUILT_PDF_ARTICLES): $(BUILD)/%.pdf: $(SOURCE)/%.adoc $(BUILD)
asciidoctor-pdf "$<" $(ASCIIDOCTOR_FLAGS) $(ASCIIDOCTOR_PDF_FLAGS)
$(BUILD):
mkdir -p $(BUILD)
.PHONY: clean
clean:
rm -r $(BUILD)