-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
96 lines (79 loc) · 2.51 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
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
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
#
# Copyright 2019, Joyent, Inc.
# Copyright 2024 Oxide Computer Company
#
BOOKS = $(BOOKS_WITH_PDF) $(BOOKS_HTML_ONLY)
BOOKS_WITH_PDF = lgrps dtrace mdb zfs-admin wdd
#
# We are having some temporary issues building the PDF for these books:
#
BOOKS_HTML_ONLY = smb-admin
PDF_TYPES = print ebook
BUILD_FILES = $(shell find src/xslt src/dblatex -type f)
#
# For each book, generate the list of input files in a variable based on the
# book name; e.g., $(FILES_dtrace).
#
$(foreach b,$(BOOKS), \
$(eval FILES_$(b) = $$(shell find raw/$(b)/ -name \*.xml -o -name \*.eps)))
DBLATEX = dblatex
DBLATEX_OPTS = -p src/dblatex/params.xsl
DBLATEX_OPTS_print = -P latex.page.size=letter
DBLATEX_OPTS_ebook = -P latex.page.size=ebook
MOGRIFY = mogrify
MOGRIFY_OPTS = -density 150 -format png
OUTDIR = build
TARGETS_HTML = $(foreach b,$(BOOKS), \
$(OUTDIR)/$(b)/index.html)
TARGETS_PDF = $(foreach b,$(BOOKS_WITH_PDF), \
$(foreach t,$(PDF_TYPES), \
$(OUTDIR)/$(b)/$(b)-$(t).pdf))
.PHONY: all
all: $(TARGETS_HTML) $(TARGETS_PDF) $(OUTDIR)/index.html
.PHONY: html
html: $(TARGETS_HTML)
.PHONY: pdf
pdf: $(TARGETS_PDF)
$(OUTDIR)/index.html:
rm -f $@
cp index.html $@
$(OUTDIR)/%/index.html:
rm -rf $(OUTDIR)/$*
mkdir -p $(OUTDIR)/$*
mvn -Dtarget.outdir=$(OUTDIR) -Dtarget.book=$* xml:transform
cp src/xslt/style.css $(OUTDIR)/$*
mkdir $(OUTDIR)/$*/figures; \
cp src/xslt/phoenix.svg $(OUTDIR)/$*/figures
if [[ -d raw/$*/figures ]]; then \
$(MOGRIFY) $(MOGRIFY_OPTS) -path $(OUTDIR)/$*/figures \
raw/$*/figures/*.eps; \
fi
#
# pdf_template(book, pdf_type): emits a rule and recipe to generate the
# selected book (e.g., "lgrps") PDF of the selected type (e.g., "print").
#
define pdf_template
$$(OUTDIR)/$(1)/$(1)-$(2).pdf: raw/$(1)/$(1).book $$(FILES_$(1)) \
$$(BUILD_FILES) | $$(OUTDIR)/$(1)/index.html
$$(DBLATEX) $$(DBLATEX_OPTS) $$(DBLATEX_OPTS_$(2)) -o $$@ $$<
endef
#
# Construct a target for each of the cartesian product of all books and types:
#
$(foreach b,$(BOOKS_WITH_PDF), \
$(foreach t,$(PDF_TYPES), \
$(eval $(call pdf_template,$(b),$(t)))))
clean:
rm -rf $(OUTDIR)/
check:
mvn exec:java