aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorRafael Sene <rafael@riscv.org>2023-03-22 11:17:53 -0300
committerGitHub <noreply@github.com>2023-03-22 11:17:53 -0300
commit9dd53c7241eed36b717ab39f4bf96e75e5e9855a (patch)
treeefa73056945d837e60d78a681774ab19b8a0b043 /build
parent7b7c78c361e3c77865a10c8622ca713dfd40fec6 (diff)
downloadriscv-isa-manual-9dd53c7241eed36b717ab39f4bf96e75e5e9855a.zip
riscv-isa-manual-9dd53c7241eed36b717ab39f4bf96e75e5e9855a.tar.gz
riscv-isa-manual-9dd53c7241eed36b717ab39f4bf96e75e5e9855a.tar.bz2
Add specific targets for priv and unpriv build
This changes adds the following: * Use the := assignment operator for immediate assignment, to avoid unnecessary recomputations. * Extract common asciidoctor-pdf options into a single variable (ASCIIDOCTOR_OPTS) to avoid redundancy. * Define a SRCDIR variable for the source directory path to simplify changes. * Use pattern rules to generate PDFs and make the target depend on the source file, so the build is only triggered when the source file has been modified. * Add a clean target to remove generated PDFs. Signed-off-by: Rafael Sene <rafael@riscv.org>
Diffstat (limited to 'build')
-rw-r--r--build/Makefile63
1 files changed, 41 insertions, 22 deletions
diff --git a/build/Makefile b/build/Makefile
index e5903ec..34bc234 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -1,22 +1,41 @@
-#HEADER_SOURCE := ../src/riscv-privileged.adoc
-HEADER_SOURCE := ../src/riscv-isa-unpr-conv-review.adoc
-#PDF_RESULT := priv-isa-asciidoc.pdf
-PDF_RESULT := unpriv-isa-asciidoc.pdf
-# Not all document sources are yet listed here. Not just adoc files but
-# images/ and resources/ content. Once they are the target can remove the
-# phony use.
-SOURCES := $(HEADER_SOURCE)
-
-all: $(PDF_RESULT)
-
-.PHONY: $(PDF_RESULT)
-$(PDF_RESULT): $(SOURCES)
- asciidoctor-pdf \
- --attribute=mathematical-format=svg \
- --failure-level=ERROR \
- --require=asciidoctor-bibtex \
- --require=asciidoctor-diagram \
- --require=asciidoctor-mathematical \
- --trace \
- --out-file=$@ \
- $(HEADER_SOURCE)
+# Makefile
+
+# Build Targets
+TARGETS := priv unpriv
+
+.PHONY: all $(TARGETS)
+
+all: $(TARGETS)
+
+ASCIIDOCTOR_OPTS := --attribute=mathematical-format=svg \
+ --failure-level=ERROR \
+ --require=asciidoctor-bibtex \
+ --require=asciidoctor-diagram \
+ --require=asciidoctor-mathematical \
+ --trace
+
+SRCDIR := ../src
+
+# Privilege ISA
+priv: priv-isa-asciidoc.pdf
+
+priv-isa-asciidoc.pdf: $(SRCDIR)/riscv-isa-unpr-conv-review.adoc
+ @echo "Building Privilege ISA"
+ asciidoctor-pdf $(ASCIIDOCTOR_OPTS) --out-file=$@ $<
+
+# Unprivilege ISA
+unpriv: unpriv-isa-asciidoc.pdf
+
+unpriv-isa-asciidoc.pdf: $(SRCDIR)/riscv-isa-unpr-conv-review.adoc
+ @echo "Building Unprivilege ISA"
+ asciidoctor-pdf $(ASCIIDOCTOR_OPTS) --out-file=$@ $<
+
+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