1
- # Variables
2
- SPEC_TEX := riscv-trace-spec
3
- SPEC_PDF := $(SPEC_TEX ) .pdf
4
- INCLUDES_TEX := introduction.tex branchTrace.tex exampleAlgorithm.tex filtering.tex timestamping.tex ingressPort.tex payload.tex dataTracePayload.tex control.tex preamble.tex riscv-trace-spec.tex decoder.tex discovery.tex exampleCodeSnippets.tex fragmentCodeAndTransport.tex future.tex
1
+ # Makefile for RISC-V Doc Template
2
+ #
3
+ # This work is licensed under the Creative Commons Attribution-ShareAlike 4.0
4
+ # International License. To view a copy of this license, visit
5
+ # http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to
6
+ # Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
7
+ #
8
+ # SPDX-License-Identifier: CC-BY-SA-4.0
9
+ #
10
+ # Description:
11
+ #
12
+ # This Makefile is designed to automate the process of building and packaging
13
+ # the Doc Template for RISC-V Extensions.
5
14
6
- # Main Targets
7
- all : $(SPEC_PDF )
15
+ # DATE ?= $(shell date +%Y-%m-%d)
16
+ # VERSION ?= v0.0.0
17
+ # REVMARK ?= Draft
18
+ DOCKER_RUN := docker run --rm -v ${PWD}:/build -w /build \
19
+ riscvintl/riscv-docs-base-container-image:latest
8
20
9
- publish : $(SPEC_PDF )
10
- cp $< $(SPEC_TEX ) -` git rev-parse --abbrev-ref HEAD` .` git rev-parse --short HEAD` .pdf
21
+ HEADER_SOURCE := header.adoc
22
+ PDF_RESULT := riscv-trace-spec-asciidoc.pdf
23
+
24
+
25
+ ASCIIDOCTOR_PDF := asciidoctor-pdf
26
+ OPTIONS := --trace \
27
+ -a compress \
28
+ -a mathematical-format=svg \
29
+ --failure-level=ERROR
30
+ REQUIRES := --require=asciidoctor-diagram \
31
+ --require=asciidoctor-mathematical
32
+ # --require=~/bin/pdf-converter-colophon-placement.rb
33
+ # --require=asciidoctor-bibtex \
34
+
35
+ .PHONY : all build clean build-container build-no-container
36
+
37
+ all : build
38
+
39
+ build :
40
+ @echo " Checking if Docker is available..."
41
+ @if command -v docker > /dev/null 2>&1 ; then \
42
+ echo " Docker is available, building inside Docker container..." ; \
43
+ $(MAKE ) build-container; \
44
+ else \
45
+ echo " Docker is not available, building without Docker..." ; \
46
+ $(MAKE ) build-no-container; \
47
+ fi
48
+
49
+ build-container :
50
+ @echo " Starting build inside Docker container..."
51
+ $(DOCKER_RUN ) /bin/sh -c " $( ASCIIDOCTOR_PDF) $( OPTIONS) $( REQUIRES) --out-file=$( PDF_RESULT) $( HEADER_SOURCE) "
52
+ @echo " Build completed successfully inside Docker container."
53
+
54
+ build-no-container :
55
+ @echo " Starting build..."
56
+ $(ASCIIDOCTOR_PDF ) $(OPTIONS ) $(REQUIRES ) --out-file=$(PDF_RESULT ) $(HEADER_SOURCE )
57
+ @echo " Build completed successfully."
11
58
12
59
clean :
13
- rm -f $(SPEC_PDF ) * .aux * .toc * .log * .idx * .ilg * .ind * .lof * .lot * .out * .pdf
14
-
15
- # Recipe for building the PDF
16
- $(SPEC_PDF ) : $(SPEC_TEX ) .tex $(INCLUDES_TEX ) vc.tex
17
- echo $(SPEC_TEX )
18
- pdflatex -shell-escape $< && makeindex $(SPEC_TEX ) && pdflatex -shell-escape $<
19
-
20
- # Recipe for generating vc.tex with Git version control information
21
- vc.tex : .git/logs/HEAD
22
- echo " %%% This file is generated by Makefile." > vc.tex
23
- echo " %%% Do not edit this file!\n%%%" >> vc.tex
24
- git log -1 --format=" format:\
25
- \\ gdef\\ GITHash{%H}\
26
- \\ gdef\\ GITAbrHash{%h}\
27
- \\ gdef\\ GITAuthorDate{%ad}\
28
- \\ gdef\\ GITAuthorName{%an}" >> vc.tex
29
-
30
- # Recipe for generating changelog.tex from Git logs
31
- changelog.tex : .git/logs/HEAD Makefile
32
- echo " %%% This file is generated by Makefile." > changelog.tex
33
- echo " %%% Do not edit this file!\n%%%" >> changelog.tex
34
- git log --no-merges --date=short --pretty=" format:vhEntry{%h}{%ad}{%an}{%s}" | \
35
- sed -e " s,\\\\ ,{\\\\ textbackslash},g" -e " s,[_#^],\\\\ &,g" -e s/^/\\\\ / >> changelog.tex
60
+ @echo " Cleaning up generated files..."
61
+ rm -f $(PDF_RESULT )
62
+ @echo " Cleanup completed."
0 commit comments