blob: c294fbbc3ad8ed16990bf78cc3dee508ead6557c [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
Eric Kunzea3eded02021-12-13 15:40:04 -08004# (C) COPYRIGHT 2020-2022 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
Eric Kunze3309a532020-10-01 18:50:46 -070020
Kevin Petit36f2d642022-12-06 11:56:15 +000021COMMON_ARGS= -a generated="$(abspath $(GENDIR))"
Eric Kunze3309a532020-10-01 18:50:46 -070022
23SPECSRC := tosa_spec.adoc
Eric Kunze58098a72022-08-05 15:40:12 -070024ADOCFILES = $(wildcard chapters/[A-Za-z]*.adoc) $(wildcard $(GENDIR)/*/*.adoc)
Eric Kunzea3eded02021-12-13 15:40:04 -080025SPECFILES = $(ADOCFILES) tosa.css
Eric Kunze44a13472021-08-12 11:01:14 -070026FIGURES = $(wildcard figures/*.svg)
Eric Kunze58098a72022-08-05 15:40:12 -070027SPECXML := tosa.xml
28SPECSCHEMA := tosa.xsd
29GENSCRIPTS := tools/tosa.py tools/genspec.py
30
31GEN := $(GENDIR)/gen.stamp
Eric Kunze3309a532020-10-01 18:50:46 -070032
33.DELETE_ON_ERROR:
34
Eric Kunze58098a72022-08-05 15:40:12 -070035.PHONY: all html pdf clean spell copy_html_figures lint
Eric Kunze3309a532020-10-01 18:50:46 -070036
Eric Kunzea3eded02021-12-13 15:40:04 -080037all: spell html pdf
Eric Kunze3309a532020-10-01 18:50:46 -070038
Eric Kunze58098a72022-08-05 15:40:12 -070039html: lint copy_html_figures $(HTMLDIR)/tosa_spec.html
Eric Kunze3309a532020-10-01 18:50:46 -070040
Eric Kunze58098a72022-08-05 15:40:12 -070041pdf: lint $(PDFDIR)/tosa_spec.pdf
Eric Kunze3309a532020-10-01 18:50:46 -070042
43clean:
44 $(RM) $(HTMLDIR)/tosa_spec.html
Eric Kunze58098a72022-08-05 15:40:12 -070045 $(RM) -rf $(HTMLDIR)/figures
Eric Kunze3309a532020-10-01 18:50:46 -070046 $(RM) $(PDFDIR)/tosa_spec.pdf
Eric Kunze58098a72022-08-05 15:40:12 -070047 $(RM) -r $(GENDIR)
48 $(RM) out/lint.txt
49
50lint: out/lint.txt
Eric Kunze3309a532020-10-01 18:50:46 -070051
Eric Kunzea3eded02021-12-13 15:40:04 -080052spell: out/spell.txt
53
Eric Kunze44a13472021-08-12 11:01:14 -070054copy_html_figures: $(FIGURES)
55 $(MKDIR) -p $(HTMLDIR)/figures
56 cp $(FIGURES) $(HTMLDIR)/figures
57
Eric Kunzea1ba6562022-03-31 09:53:16 -070058.PRECIOUS: out/spell.txt
Eric Kunzea3eded02021-12-13 15:40:04 -080059out/spell.txt: $(ADOCFILES) FORCE
60 @echo Running spell check
61 @mkdir -p $(@D)
62 @tools/get_descriptions.py $(ADOCFILES) \
63 | $(ASPELL) list -v -l en-US --encoding=UTF-8 --add-extra-dicts=./tools/dictionary.dic\
64 | sort -u > $@
Eric Kunzea1ba6562022-03-31 09:53:16 -070065 @if [ -s $@ ] ; then \
66 echo Spelling errors detected, check $@; exit 1; \
Eric Kunzea3eded02021-12-13 15:40:04 -080067 else echo No spelling errors found ; \
68 fi
69
Eric Kunze58098a72022-08-05 15:40:12 -070070.PRECIOUS: out/lint.txt
71out/lint.txt: $(SPECXML) $(SPECSCHEMA)
72 echo Linting XML
73 $(XMLLINT) --noout --schema $(SPECSCHEMA) $(SPECXML)
74
75$(GEN): $(SPECXML) $(GENSCRIPTS)
76 tools/genspec.py --xml $(SPECXML) --outdir $(GENDIR)
77 @touch $@
78
79$(HTMLDIR)/tosa_spec.html: $(SPECSRC) $(SPECFILES) $(GEN)
Eric Kunze3309a532020-10-01 18:50:46 -070080 $(MKDIR) $(HTMLDIR)
81 $(ASCIIDOC) -b html5 -a stylesheet=tosa.css $(COMMON_ARGS) -o $@ $<
82
Eric Kunze58098a72022-08-05 15:40:12 -070083$(PDFDIR)/tosa_spec.pdf: $(SPECSRC) $(SPECFILES) $(GEN)
Eric Kunze3309a532020-10-01 18:50:46 -070084 $(MKDIR) $(PDFDIR)
85 $(ASCIIDOC) -r asciidoctor-pdf -b pdf $(COMMON_ARGS) -o $@ $(SPECSRC)
Eric Kunzea3eded02021-12-13 15:40:04 -080086
87.PHONY: FORCE
88FORCE: