blob: 7fe0f6f0ade4fbf1064c697b9e2359cde62dcaa6 (
plain)
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
|
# Makefile for RISC-V ISA Manuals
#
# This work is licensed under the Creative Commons Attribution-ShareAlike 4.0
# International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
#
# SPDX-License-Identifier: CC-BY-SA-4.0
#
# Description:
#
# This Makefile is designed to automate the process of building and packaging
# the documentation for RISC-V ISA Manuals. It supports multiple build targets
# for generating documentation in various formats (PDF, HTML).
# Build Targets
TARGETS := priv unpriv priv-html unpriv-html priv-latex
# Declare phony targets
.PHONY: all $(TARGETS) clean
# Default target builds all
all: $(TARGETS)
# Asciidoctor options
ASCIIDOCTOR_OPTS := --attribute=mathematical-format=svg \
--failure-level=ERROR \
--require=asciidoctor-bibtex \
--require=asciidoctor-diagram \
--require=asciidoctor-mathematical \
--trace
# Source directory
SRCDIR := ../src
# LaTeX source and related files
SRCS := $(wildcard $(SRCDIR)/latex/*.tex)
FIGS := $(wildcard $(SRCDIR)/latex/figs/*)
BIBS := $(SRCDIR)/latex/riscv-spec.bib
# LaTeX build tools
PDFLATEX := TEXINPUTS=$(SRCDIR)/latex: pdflatex -interaction=nonstopmode -halt-on-error
BIBTEX := BIBINPUTS=$(SRCDIR)/latex: bibtex
# Temporary files to clean up for LaTeX build
JUNK := *.pdf *.aux *.log *.bbl *.blg *.toc *.out *.fdb_latexmk *.fls *.synctex.gz
# Privileged ISA build
priv: priv-isa-asciidoc.pdf
priv-isa-asciidoc.pdf: $(SRCDIR)/riscv-privileged.adoc $(SRCDIR)/*.adoc
@echo "Building Privileged ISA"
rm -f $@.tmp
asciidoctor-pdf $(ASCIIDOCTOR_OPTS) --out-file=$@.tmp $<
mv $@.tmp $@
# Unprivileged ISA build
unpriv: unpriv-isa-asciidoc.pdf
unpriv-isa-asciidoc.pdf: $(SRCDIR)/riscv-unprivileged.adoc $(SRCDIR)/*.adoc
@echo "Building Unprivileged ISA"
rm -f $@.tmp
asciidoctor-pdf $(ASCIIDOCTOR_OPTS) --out-file=$@.tmp $<
mv $@.tmp $@
# Privileged ISA HTML build
priv-html: priv-isa-asciidoc.html
priv-isa-asciidoc.html: $(SRCDIR)/riscv-privileged.adoc
@echo "Building Privileged ISA HTML"
asciidoctor $(ASCIIDOCTOR_OPTS) --out-file=$@ $<
# Unprivileged ISA HTML build
unpriv-html: unpriv-isa-asciidoc.html
unpriv-isa-asciidoc.html: $(SRCDIR)/riscv-unprivileged.adoc
@echo "Building Unprivileged ISA HTML"
asciidoctor $(ASCIIDOCTOR_OPTS) --out-file=$@ $<
# LaTeX build for Privileged ISA
priv-latex: riscv-privileged.pdf
riscv-privileged.pdf: $(SRCDIR)/latex/riscv-privileged.tex $(SRCS) $(FIGS) $(BIBS)
$(PDFLATEX) riscv-privileged
$(BIBTEX) riscv-privileged
$(PDFLATEX) riscv-privileged
$(PDFLATEX) riscv-privileged
clean:
@if [ -f priv-isa-asciidoc.pdf ]; then \
echo "Removing priv-isa-asciidoc.pdf"; \
rm -f priv-isa-asciidoc.pdf; \
fi
@if [ -f unpriv-isa-asciidoc.pdf ]; then \
echo "Removing unpriv-isa-asciidoc.pdf"; \
rm -f unpriv-isa-asciidoc.pdf; \
fi
@if [ -f priv-isa-asciidoc.html ]; then \
echo "Removing priv-isa-asciidoc.html"; \
rm -f priv-isa-asciidoc.html; \
fi
@if [ -f unpriv-isa-asciidoc.html ]; then \
echo "Removing unpriv-isa-asciidoc.html"; \
rm -f unpriv-isa-asciidoc.html; \
fi
@echo "Cleaning up files from LaTeX build"
@cd $(SRCDIR)/latex; \
for file in $(JUNK); do \
if [ -f "$$file" ]; then \
echo "Removing $$file"; \
rm -f "$$file"; \
fi; \
done
|