blob: 877a8a20b123055b5c3c98b8723f1e1f2f53d683 [file] [log] [blame]
Eric Kunze3309a532020-10-01 18:50:46 -07001#
2# This confidential and proprietary software may be used only as
3# authorised by a licensing agreement from ARM Limited
Kevin Petita7ac3132024-01-08 15:27:25 +00004# (C) COPYRIGHT 2020-2024 ARM Limited
Eric Kunze3309a532020-10-01 18:50:46 -07005# ALL RIGHTS RESERVED
6# The entire notice above must be reproduced on all authorised
7# copies and copies may only be made to the extent permitted
8# by a licensing agreement from ARM Limited.
9#
10
Eric Kunze3309a532020-10-01 18:50:46 -070011MKDIR=mkdir -p
12ASCIIDOC=asciidoctor
Eric Kunzea3eded02021-12-13 15:40:04 -080013ASPELL=aspell
Eric Kunzea1ba6562022-03-31 09:53:16 -070014SHELL=/bin/bash -o pipefail
Eric Kunze58098a72022-08-05 15:40:12 -070015XMLLINT = xmllint
Eric Kunze3309a532020-10-01 18:50:46 -070016
17HTMLDIR=out/html
18PDFDIR=out/pdf
Eric Kunze58098a72022-08-05 15:40:12 -070019GENDIR=out/gen
Kevin Petita7ac3132024-01-08 15:27:25 +000020PSEUDOCODEDIR := pseudocode
Eric Kunze3309a532020-10-01 18:50:46 -070021
Kevin Petita7ac3132024-01-08 15:27:25 +000022COMMON_ARGS= -a generated="$(abspath $(GENDIR))" -a pseudocode="$(abspath $(PSEUDOCODEDIR))"
Eric Kunze3309a532020-10-01 18:50:46 -070023
24SPECSRC := tosa_spec.adoc
Eric Kunze58098a72022-08-05 15:40:12 -070025ADOCFILES = $(wildcard chapters/[A-Za-z]*.adoc) $(wildcard $(GENDIR)/*/*.adoc)
Kevin Petita7ac3132024-01-08 15:27:25 +000026PSEUDOCODEFILES = $(wildcard $(PSEUDOCODEDIR)/operators/*.tosac) $(wildcard $(PSEUDOCODEDIR)/operators/tables/*.tosac)
Eric Kunzea3eded02021-12-13 15:40:04 -080027SPECFILES = $(ADOCFILES) tosa.css
Eric Kunze44a13472021-08-12 11:01:14 -070028FIGURES = $(wildcard figures/*.svg)
Eric Kunze58098a72022-08-05 15:40:12 -070029SPECXML := tosa.xml
30SPECSCHEMA := tosa.xsd
31GENSCRIPTS := tools/tosa.py tools/genspec.py
32
33GEN := $(GENDIR)/gen.stamp
Eric Kunze3309a532020-10-01 18:50:46 -070034
35.DELETE_ON_ERROR:
36
Eric Kunze58098a72022-08-05 15:40:12 -070037.PHONY: all html pdf clean spell copy_html_figures lint
Eric Kunze3309a532020-10-01 18:50:46 -070038
Eric Kunzea3eded02021-12-13 15:40:04 -080039all: spell html pdf
Eric Kunze3309a532020-10-01 18:50:46 -070040
Eric Kunze58098a72022-08-05 15:40:12 -070041html: lint copy_html_figures $(HTMLDIR)/tosa_spec.html
Eric Kunze3309a532020-10-01 18:50:46 -070042
Eric Kunze58098a72022-08-05 15:40:12 -070043pdf: lint $(PDFDIR)/tosa_spec.pdf
Eric Kunze3309a532020-10-01 18:50:46 -070044
45clean:
46 $(RM) $(HTMLDIR)/tosa_spec.html
Eric Kunze58098a72022-08-05 15:40:12 -070047 $(RM) -rf $(HTMLDIR)/figures
Eric Kunze3309a532020-10-01 18:50:46 -070048 $(RM) $(PDFDIR)/tosa_spec.pdf
Eric Kunze58098a72022-08-05 15:40:12 -070049 $(RM) -r $(GENDIR)
50 $(RM) out/lint.txt
51
52lint: out/lint.txt
Eric Kunze3309a532020-10-01 18:50:46 -070053
Eric Kunzea3eded02021-12-13 15:40:04 -080054spell: out/spell.txt
55
Eric Kunze44a13472021-08-12 11:01:14 -070056copy_html_figures: $(FIGURES)
57 $(MKDIR) -p $(HTMLDIR)/figures
58 cp $(FIGURES) $(HTMLDIR)/figures
59
Eric Kunzea1ba6562022-03-31 09:53:16 -070060.PRECIOUS: out/spell.txt
Eric Kunzea3eded02021-12-13 15:40:04 -080061out/spell.txt: $(ADOCFILES) FORCE
62 @echo Running spell check
63 @mkdir -p $(@D)
64 @tools/get_descriptions.py $(ADOCFILES) \
65 | $(ASPELL) list -v -l en-US --encoding=UTF-8 --add-extra-dicts=./tools/dictionary.dic\
66 | sort -u > $@
Eric Kunzea1ba6562022-03-31 09:53:16 -070067 @if [ -s $@ ] ; then \
68 echo Spelling errors detected, check $@; exit 1; \
Eric Kunzea3eded02021-12-13 15:40:04 -080069 else echo No spelling errors found ; \
70 fi
71
Eric Kunze58098a72022-08-05 15:40:12 -070072.PRECIOUS: out/lint.txt
73out/lint.txt: $(SPECXML) $(SPECSCHEMA)
74 echo Linting XML
75 $(XMLLINT) --noout --schema $(SPECSCHEMA) $(SPECXML)
76
77$(GEN): $(SPECXML) $(GENSCRIPTS)
78 tools/genspec.py --xml $(SPECXML) --outdir $(GENDIR)
79 @touch $@
80
Kevin Petita7ac3132024-01-08 15:27:25 +000081$(HTMLDIR)/tosa_spec.html: $(SPECSRC) $(SPECFILES) $(GEN) $(PSEUDOCODEFILES)
Eric Kunze3309a532020-10-01 18:50:46 -070082 $(MKDIR) $(HTMLDIR)
83 $(ASCIIDOC) -b html5 -a stylesheet=tosa.css $(COMMON_ARGS) -o $@ $<
84
Kevin Petita7ac3132024-01-08 15:27:25 +000085$(PDFDIR)/tosa_spec.pdf: $(SPECSRC) $(SPECFILES) $(GEN) $(PSEUDOCODEFILES)
Eric Kunze3309a532020-10-01 18:50:46 -070086 $(MKDIR) $(PDFDIR)
87 $(ASCIIDOC) -r asciidoctor-pdf -b pdf $(COMMON_ARGS) -o $@ $(SPECSRC)
Eric Kunzea3eded02021-12-13 15:40:04 -080088
89.PHONY: FORCE
90FORCE: