1e5c31af7Sopenharmony_ci# Copyright 2014-2024 The Khronos Group Inc.
2e5c31af7Sopenharmony_ci#
3e5c31af7Sopenharmony_ci# SPDX-License-Identifier: Apache-2.0
4e5c31af7Sopenharmony_ci
5e5c31af7Sopenharmony_ci# Vulkan Specification makefile
6e5c31af7Sopenharmony_ci#
7e5c31af7Sopenharmony_ci# To build the spec with a specific version included, set the
8e5c31af7Sopenharmony_ci# $(VERSIONS) variable on the make command line to a space-separated
9e5c31af7Sopenharmony_ci# list of version names (e.g. VK_VERSION_1_3) *including all previous
10e5c31af7Sopenharmony_ci# versions of the API* (e.g. VK_VERSION_1_1 must also include
11e5c31af7Sopenharmony_ci# VK_VERSION_1_0 and VKSC_VERSION_1_0 must also include VK_VERSION_1_2,
12e5c31af7Sopenharmony_ci# VK_VERSION_1_1 & VK_VERSION_1_0). $(VERSIONS) is converted into generator
13e5c31af7Sopenharmony_ci# script arguments $(VERSIONOPTIONS) and into $(ATTRIBFILE)
14e5c31af7Sopenharmony_ci#
15e5c31af7Sopenharmony_ci# To build the specification / reference pages (refpages) with optional
16e5c31af7Sopenharmony_ci# extensions included, set the $(EXTENSIONS) variable on the make
17e5c31af7Sopenharmony_ci# command line to a space-separated list of extension names.
18e5c31af7Sopenharmony_ci# $(EXTENSIONS) is converted into generator script
19e5c31af7Sopenharmony_ci# arguments $(EXTOPTIONS) and into $(ATTRIBFILE)
20e5c31af7Sopenharmony_ci
21e5c31af7Sopenharmony_ci# If a recipe fails, delete its target file. Without this cleanup, the leftover
22e5c31af7Sopenharmony_ci# file from the failed recipe can falsely satisfy dependencies on subsequent
23e5c31af7Sopenharmony_ci# runs of `make`.
24e5c31af7Sopenharmony_ci.DELETE_ON_ERROR:
25e5c31af7Sopenharmony_ci
26e5c31af7Sopenharmony_ci# Support building both Vulkan and Vulkan SC APIs
27e5c31af7Sopenharmony_ci# Allow the API to be overridden by the VULKAN_API environment variable
28e5c31af7Sopenharmony_ci# supported options are 'vulkan' and 'vulkansc' or unset
29e5c31af7Sopenharmony_ci# default to 'vulkan'
30e5c31af7Sopenharmony_ciVULKAN_API ?= vulkan
31e5c31af7Sopenharmony_ciifeq ($(VULKAN_API),vulkan)
32e5c31af7Sopenharmony_ciVERSIONS := VK_VERSION_1_0 VK_VERSION_1_1 VK_VERSION_1_2 VK_VERSION_1_3
33e5c31af7Sopenharmony_cielse
34e5c31af7Sopenharmony_ciVERSIONS := VK_VERSION_1_0 VK_VERSION_1_1 VK_VERSION_1_2 VKSC_VERSION_1_0
35e5c31af7Sopenharmony_ciendif
36e5c31af7Sopenharmony_ciVERSIONOPTIONS := $(foreach version,$(VERSIONS),-feature $(version))
37e5c31af7Sopenharmony_ci
38e5c31af7Sopenharmony_ciEXTS := $(sort $(EXTENSIONS) $(DIFFEXTENSIONS))
39e5c31af7Sopenharmony_ciEXTOPTIONS := $(foreach ext,$(EXTS),-extension $(ext))
40e5c31af7Sopenharmony_ci
41e5c31af7Sopenharmony_ci# APITITLE can be set to extra text to append to the document title,
42e5c31af7Sopenharmony_ci# normally used when building with extensions included.
43e5c31af7Sopenharmony_ciAPITITLE =
44e5c31af7Sopenharmony_ci
45e5c31af7Sopenharmony_ci# IMAGEOPTS is normally set to generate inline SVG images, but can be
46e5c31af7Sopenharmony_ci# overridden to an empty string, since the inline option does not work
47e5c31af7Sopenharmony_ci# well with our HTML diffs.
48e5c31af7Sopenharmony_ciIMAGEOPTS = inline
49e5c31af7Sopenharmony_ci
50e5c31af7Sopenharmony_ci# The default 'all' target builds the following sub-targets:
51e5c31af7Sopenharmony_ci#  html - HTML single-page API specification
52e5c31af7Sopenharmony_ci#  pdf - PDF single-page API specification
53e5c31af7Sopenharmony_ci#  styleguide - HTML5 single-page "Documentation and Extensions" guide
54e5c31af7Sopenharmony_ci#  registry - HTML5 single-page XML Registry Schema documentation
55e5c31af7Sopenharmony_ci#  manhtml - HTML5 single-page reference guide - NOT SUPPORTED
56e5c31af7Sopenharmony_ci#  manpdf - PDF reference guide - NOT SUPPORTED
57e5c31af7Sopenharmony_ci#  manhtmlpages - HTML5 separate per-feature refpages
58e5c31af7Sopenharmony_ci#  allchecks - checks for style guide compliance, XML consistency,
59e5c31af7Sopenharmony_ci#   internal link validity, and other easy to catch errors.
60e5c31af7Sopenharmony_ci
61e5c31af7Sopenharmony_ciall: alldocs allchecks
62e5c31af7Sopenharmony_ci
63e5c31af7Sopenharmony_cialldocs: allspecs allman proposals
64e5c31af7Sopenharmony_ci
65e5c31af7Sopenharmony_ciallspecs: html pdf styleguide registry
66e5c31af7Sopenharmony_ci
67e5c31af7Sopenharmony_ciallman: manhtmlpages
68e5c31af7Sopenharmony_ci
69e5c31af7Sopenharmony_ci# Invokes all the automated checks, but CHECK_XREFS can be set to empty
70e5c31af7Sopenharmony_ci# on the command line to avoid building an HTML spec target.
71e5c31af7Sopenharmony_ciCHECK_XREFS = check-xrefs
72e5c31af7Sopenharmony_ciifeq ($(VULKAN_API),vulkansc)
73e5c31af7Sopenharmony_ciCHECK_XREFS =
74e5c31af7Sopenharmony_ciendif
75e5c31af7Sopenharmony_ciallchecks: check-copyright-dates \
76e5c31af7Sopenharmony_ci    check-contractions \
77e5c31af7Sopenharmony_ci    check-spelling \
78e5c31af7Sopenharmony_ci    check-writing \
79e5c31af7Sopenharmony_ci    check-bullets \
80e5c31af7Sopenharmony_ci    check-reflow \
81e5c31af7Sopenharmony_ci    check-links \
82e5c31af7Sopenharmony_ci    check-consistency \
83e5c31af7Sopenharmony_ci    check-undefined \
84e5c31af7Sopenharmony_ci    check-txtfiles \
85e5c31af7Sopenharmony_ci    $(CHECK_XREFS)
86e5c31af7Sopenharmony_ci
87e5c31af7Sopenharmony_ciQUIET	 ?= @
88e5c31af7Sopenharmony_ciVERYQUIET?= @
89e5c31af7Sopenharmony_ciPYTHON	 ?= python3
90e5c31af7Sopenharmony_ciASCIIDOC ?= asciidoctor
91e5c31af7Sopenharmony_ciRUBY	 = ruby
92e5c31af7Sopenharmony_ciNODEJS	 = node
93e5c31af7Sopenharmony_ciPATCH	 = patch
94e5c31af7Sopenharmony_ciRM	 = rm -f
95e5c31af7Sopenharmony_ciRMRF	 = rm -rf
96e5c31af7Sopenharmony_ciMKDIR	 = mkdir -p
97e5c31af7Sopenharmony_ciCP	 = cp
98e5c31af7Sopenharmony_ciECHO	 = echo
99e5c31af7Sopenharmony_ci
100e5c31af7Sopenharmony_ci# Where the repo root is
101e5c31af7Sopenharmony_ciROOTDIR        = $(CURDIR)
102e5c31af7Sopenharmony_ci# Where the spec files are
103e5c31af7Sopenharmony_ciSPECDIR        = $(CURDIR)
104e5c31af7Sopenharmony_ci
105e5c31af7Sopenharmony_ci# Path to scripts used in generation
106e5c31af7Sopenharmony_ciSCRIPTS  = $(ROOTDIR)/scripts
107e5c31af7Sopenharmony_ci# Path to configs and asciidoc extensions used in generation
108e5c31af7Sopenharmony_ciCONFIGS  = $(ROOTDIR)/config
109e5c31af7Sopenharmony_ci
110e5c31af7Sopenharmony_ci# Target directories for output files
111e5c31af7Sopenharmony_ci# HTMLDIR - 'html' target
112e5c31af7Sopenharmony_ci# PDFDIR - 'pdf' target
113e5c31af7Sopenharmony_ciOUTDIR	  = $(GENERATED)/out
114e5c31af7Sopenharmony_ciHTMLDIR   = $(OUTDIR)/html
115e5c31af7Sopenharmony_ciVUDIR	  = $(OUTDIR)/validation
116e5c31af7Sopenharmony_ciPDFDIR	  = $(OUTDIR)/pdf
117e5c31af7Sopenharmony_ciPROPOSALDIR = $(OUTDIR)/proposals
118e5c31af7Sopenharmony_ciJSAPIMAP  = $(GENERATED)/apimap.cjs
119e5c31af7Sopenharmony_ciPYAPIMAP  = $(GENERATED)/apimap.py
120e5c31af7Sopenharmony_ciRBAPIMAP  = $(GENERATED)/apimap.rb
121e5c31af7Sopenharmony_ci
122e5c31af7Sopenharmony_ci# PDF Equations are written to SVGs, this dictates the location to store those files (temporary)
123e5c31af7Sopenharmony_ciPDFMATHDIR = $(OUTDIR)/equations_temp
124e5c31af7Sopenharmony_ci
125e5c31af7Sopenharmony_ci# Set VERBOSE to -v to see what asciidoc is doing.
126e5c31af7Sopenharmony_ciVERBOSE =
127e5c31af7Sopenharmony_ci
128e5c31af7Sopenharmony_ci# asciidoc attributes to set (defaults are usually OK)
129e5c31af7Sopenharmony_ci# NOTEOPTS sets options controlling which NOTEs are generated
130e5c31af7Sopenharmony_ci# PATCHVERSION must equal VK_HEADER_VERSION from vk.xml
131e5c31af7Sopenharmony_ci# SCPATCHVERSION is specific to the Vulkan SC spec
132e5c31af7Sopenharmony_ci# ATTRIBOPTS sets the API revision and enables KaTeX generation
133e5c31af7Sopenharmony_ci# EXTRAATTRIBS sets additional attributes, if passed to make
134e5c31af7Sopenharmony_ci# ADOCMISCOPTS miscellaneous options controlling error behavior, etc.
135e5c31af7Sopenharmony_ci# ADOCEXTS asciidoctor extensions to load
136e5c31af7Sopenharmony_ci# ADOCOPTS options for asciidoc->HTML5 output
137e5c31af7Sopenharmony_ci
138e5c31af7Sopenharmony_ciNOTEOPTS     = -a editing-notes -a implementation-guide
139e5c31af7Sopenharmony_ciPATCHVERSION = 275
140e5c31af7Sopenharmony_ciBASEOPTS     =
141e5c31af7Sopenharmony_ci
142e5c31af7Sopenharmony_ciifneq (,$(findstring VKSC_VERSION_1_0,$(VERSIONS)))
143e5c31af7Sopenharmony_ciVKSPECREVISION := 1.2.$(PATCHVERSION)
144e5c31af7Sopenharmony_ciSCPATCHVERSION = 14
145e5c31af7Sopenharmony_ciSPECREVISION = 1.0.$(SCPATCHVERSION)
146e5c31af7Sopenharmony_ciBASEOPTS = -a baserevnumber="$(VKSPECREVISION)"
147e5c31af7Sopenharmony_cielse
148e5c31af7Sopenharmony_ci
149e5c31af7Sopenharmony_ciifneq (,$(findstring VK_VERSION_1_3,$(VERSIONS)))
150e5c31af7Sopenharmony_ciSPECMINOR = 3
151e5c31af7Sopenharmony_cielse
152e5c31af7Sopenharmony_ciifneq (,$(findstring VK_VERSION_1_2,$(VERSIONS)))
153e5c31af7Sopenharmony_ciSPECMINOR = 2
154e5c31af7Sopenharmony_cielse
155e5c31af7Sopenharmony_ciifneq (,$(findstring VK_VERSION_1_1,$(VERSIONS)))
156e5c31af7Sopenharmony_ciSPECMINOR = 1
157e5c31af7Sopenharmony_cielse
158e5c31af7Sopenharmony_ciSPECMINOR = 0
159e5c31af7Sopenharmony_ciendif
160e5c31af7Sopenharmony_ciendif
161e5c31af7Sopenharmony_ciendif
162e5c31af7Sopenharmony_ci
163e5c31af7Sopenharmony_ciSPECREVISION = 1.$(SPECMINOR).$(PATCHVERSION)
164e5c31af7Sopenharmony_ciendif
165e5c31af7Sopenharmony_ci
166e5c31af7Sopenharmony_ci# Spell out ISO 8601 format as not all date commands support --rfc-3339
167e5c31af7Sopenharmony_ciSPECDATE     = $(shell echo `date -u "+%Y-%m-%d %TZ"`)
168e5c31af7Sopenharmony_ci
169e5c31af7Sopenharmony_ci# Generate Asciidoc attributes for spec remark
170e5c31af7Sopenharmony_ci# Could use `git log -1 --format="%cd"` to get branch commit date
171e5c31af7Sopenharmony_ci# This used to be a dependency in the spec html/pdf targets,
172e5c31af7Sopenharmony_ci# but that is likely to lead to merge conflicts. Just regenerate
173e5c31af7Sopenharmony_ci# when pushing a new spec for review to the sandbox.
174e5c31af7Sopenharmony_ci# The dependency on HEAD is per the suggestion in
175e5c31af7Sopenharmony_ci# http://neugierig.org/software/blog/2014/11/binary-revisions.html
176e5c31af7Sopenharmony_ciSPECREMARK = from git branch: $(shell echo `git symbolic-ref --short HEAD 2> /dev/null || echo Git branch not available`) \
177e5c31af7Sopenharmony_ci	     commit: $(shell echo `git log -1 --format="%H" 2> /dev/null || echo Git commit not available`)
178e5c31af7Sopenharmony_ci
179e5c31af7Sopenharmony_ci# Some of the attributes used in building all spec documents:
180e5c31af7Sopenharmony_ci#   chapters - absolute path to chapter sources
181e5c31af7Sopenharmony_ci#   appendices - absolute path to appendix sources
182e5c31af7Sopenharmony_ci#   proposals - absolute path to proposal sources
183e5c31af7Sopenharmony_ci#   images - absolute path to images
184e5c31af7Sopenharmony_ci#   generated - absolute path to generated sources
185e5c31af7Sopenharmony_ci#   refprefix - controls which generated extension metafiles are
186e5c31af7Sopenharmony_ci#	included at build time. Must be empty for specification,
187e5c31af7Sopenharmony_ci#	'refprefix.' for refpages (see ADOCREFOPTS below).
188e5c31af7Sopenharmony_ciATTRIBOPTS   = -a revnumber="$(SPECREVISION)" $(BASEOPTS) \
189e5c31af7Sopenharmony_ci	       -a revdate="$(SPECDATE)" \
190e5c31af7Sopenharmony_ci	       -a revremark="$(SPECREMARK)" \
191e5c31af7Sopenharmony_ci	       -a apititle="$(APITITLE)" \
192e5c31af7Sopenharmony_ci	       -a stem=latexmath \
193e5c31af7Sopenharmony_ci	       -a imageopts="$(IMAGEOPTS)" \
194e5c31af7Sopenharmony_ci	       -a config=$(ROOTDIR)/config \
195e5c31af7Sopenharmony_ci	       -a appendices=$(SPECDIR)/appendices \
196e5c31af7Sopenharmony_ci	       -a proposals=$(SPECDIR)/proposals \
197e5c31af7Sopenharmony_ci	       -a chapters=$(SPECDIR)/chapters \
198e5c31af7Sopenharmony_ci	       -a images=$(IMAGEPATH) \
199e5c31af7Sopenharmony_ci	       -a generated=$(GENERATED) \
200e5c31af7Sopenharmony_ci	       -a refprefix \
201e5c31af7Sopenharmony_ci	       $(EXTRAATTRIBS)
202e5c31af7Sopenharmony_ciADOCMISCOPTS = --failure-level ERROR
203e5c31af7Sopenharmony_ci# Non target-specific Asciidoctor extensions and options
204e5c31af7Sopenharmony_ci# Look in $(GENERATED) for explicitly required non-extension Ruby, such
205e5c31af7Sopenharmony_ci# as apimap.rb
206e5c31af7Sopenharmony_ciADOCEXTS     = -I$(GENERATED) \
207e5c31af7Sopenharmony_ci	       -r $(CONFIGS)/spec-macros.rb \
208e5c31af7Sopenharmony_ci	       -r $(CONFIGS)/open_listing_block.rb \
209e5c31af7Sopenharmony_ci	       -r $(CONFIGS)/ifdef-mismatch.rb
210e5c31af7Sopenharmony_ciADOCOPTS     = -d book $(ADOCMISCOPTS) $(ATTRIBOPTS) $(NOTEOPTS) $(VERBOSE) $(ADOCEXTS)
211e5c31af7Sopenharmony_ci
212e5c31af7Sopenharmony_ci# HTML target-specific Asciidoctor extensions and options
213e5c31af7Sopenharmony_ciADOCHTMLEXTS = -r $(CONFIGS)/katex_replace.rb \
214e5c31af7Sopenharmony_ci	       -r $(CONFIGS)/loadable_html.rb \
215e5c31af7Sopenharmony_ci	       -r $(CONFIGS)/vuid-expander.rb \
216e5c31af7Sopenharmony_ci	       -r $(CONFIGS)/rouge-extend-css.rb \
217e5c31af7Sopenharmony_ci	       -r $(CONFIGS)/genanchorlinks.rb
218e5c31af7Sopenharmony_ci
219e5c31af7Sopenharmony_ci# ADOCHTMLOPTS relies on the relative runtime path from the output HTML
220e5c31af7Sopenharmony_ci# file to the katex scripts being set with KATEXDIR. This is overridden
221e5c31af7Sopenharmony_ci# by some targets.
222e5c31af7Sopenharmony_ci# KaTeX source is copied from KATEXSRCDIR in the repository to
223e5c31af7Sopenharmony_ci# KATEXINSTDIR in the output directory.
224e5c31af7Sopenharmony_ci# KATEXDIR is the relative path from a target to KATEXINSTDIR, since
225e5c31af7Sopenharmony_ci# that is coded into CSS, and set separately for each HTML target.
226e5c31af7Sopenharmony_ci# ADOCHTMLOPTS also relies on the absolute build-time path to the
227e5c31af7Sopenharmony_ci# 'stylesdir' containing our custom CSS.
228e5c31af7Sopenharmony_ciKATEXSRCDIR  = $(ROOTDIR)/katex
229e5c31af7Sopenharmony_ciKATEXINSTDIR = $(OUTDIR)/katex
230e5c31af7Sopenharmony_ciADOCHTMLOPTS = $(ADOCHTMLEXTS) -a katexpath=$(KATEXDIR) \
231e5c31af7Sopenharmony_ci	       -a stylesheet=khronos.css \
232e5c31af7Sopenharmony_ci	       -a stylesdir=$(ROOTDIR)/config \
233e5c31af7Sopenharmony_ci	       -a sectanchors
234e5c31af7Sopenharmony_ci
235e5c31af7Sopenharmony_ci# PDF target-specific Asciidoctor extensions and options
236e5c31af7Sopenharmony_ciADOCPDFEXTS  = -r asciidoctor-pdf \
237e5c31af7Sopenharmony_ci	       -r asciidoctor-mathematical \
238e5c31af7Sopenharmony_ci	       -r $(CONFIGS)/asciidoctor-mathematical-ext.rb \
239e5c31af7Sopenharmony_ci	       -r $(CONFIGS)/vuid-expander.rb
240e5c31af7Sopenharmony_ciADOCPDFOPTS  = $(ADOCPDFEXTS) -a mathematical-format=svg \
241e5c31af7Sopenharmony_ci	       -a imagesoutdir=$(PDFMATHDIR) \
242e5c31af7Sopenharmony_ci	       -a pdf-fontsdir=$(CONFIGS)/fonts,GEM_FONTS_DIR \
243e5c31af7Sopenharmony_ci	       -a pdf-stylesdir=$(CONFIGS)/themes -a pdf-style=pdf
244e5c31af7Sopenharmony_ci
245e5c31af7Sopenharmony_ci# Valid usage-specific Asciidoctor extensions and options
246e5c31af7Sopenharmony_ciADOCVUEXTS = -r $(CONFIGS)/vu-to-json.rb -r $(CONFIGS)/quiet-include-failure.rb
247e5c31af7Sopenharmony_ci# {vuprefix} precedes some anchors which are otherwise encountered twice
248e5c31af7Sopenharmony_ci# by the validusage extractor.
249e5c31af7Sopenharmony_ci# {attribute-missing} overrides the global setting, since the extractor
250e5c31af7Sopenharmony_ci# reports a lot of false-flag warnings otherwise.
251e5c31af7Sopenharmony_ciADOCVUOPTS = $(ADOCVUEXTS) -a vuprefix=vu- -a attribute-missing=skip
252e5c31af7Sopenharmony_ci
253e5c31af7Sopenharmony_ci.PHONY: directories
254e5c31af7Sopenharmony_ci
255e5c31af7Sopenharmony_ci# Images used by the spec. These are included in generated HTML now.
256e5c31af7Sopenharmony_ciIMAGEPATH = $(SPECDIR)/images
257e5c31af7Sopenharmony_ciSVGFILES  = $(wildcard $(IMAGEPATH)/*.svg)
258e5c31af7Sopenharmony_ci
259e5c31af7Sopenharmony_ci# Top-level spec source file
260e5c31af7Sopenharmony_ciSPECSRC        = $(SPECDIR)/vkspec.adoc
261e5c31af7Sopenharmony_ci# Static files making up sections of the API spec.
262e5c31af7Sopenharmony_ciSPECFILES = $(wildcard $(SPECDIR)/chapters/[A-Za-z]*.adoc $(SPECDIR)/chapters/*/[A-Za-z]*.adoc $(SPECDIR)/appendices/[A-Za-z]*.adoc)
263e5c31af7Sopenharmony_ci# Shorthand for where different types generated files go.
264e5c31af7Sopenharmony_ci# All can be relocated by overriding GENERATED in the make invocation.
265e5c31af7Sopenharmony_ciGENERATED      = $(CURDIR)/gen
266e5c31af7Sopenharmony_ciREFPATH        = $(GENERATED)/refpage
267e5c31af7Sopenharmony_ciAPIPATH        = $(GENERATED)/api
268e5c31af7Sopenharmony_ciVALIDITYPATH   = $(GENERATED)/validity
269e5c31af7Sopenharmony_ciHOSTSYNCPATH   = $(GENERATED)/hostsynctable
270e5c31af7Sopenharmony_ciMETAPATH       = $(GENERATED)/meta
271e5c31af7Sopenharmony_ciINTERFACEPATH  = $(GENERATED)/interfaces
272e5c31af7Sopenharmony_ciSPIRVCAPPATH   = $(GENERATED)/spirvcap
273e5c31af7Sopenharmony_ciFORMATSPATH    = $(GENERATED)/formats
274e5c31af7Sopenharmony_ciSYNCPATH       = $(GENERATED)/sync
275e5c31af7Sopenharmony_ciPROPOSALPATH   = $(SPECDIR)/proposals
276e5c31af7Sopenharmony_ci# timeMarker is a proxy target created when many generated files are
277e5c31af7Sopenharmony_ci# made at once
278e5c31af7Sopenharmony_ciAPIDEPEND      = $(APIPATH)/timeMarker
279e5c31af7Sopenharmony_ciVALIDITYDEPEND = $(VALIDITYPATH)/timeMarker
280e5c31af7Sopenharmony_ciHOSTSYNCDEPEND = $(HOSTSYNCPATH)/timeMarker
281e5c31af7Sopenharmony_ciMETADEPEND     = $(METAPATH)/timeMarker
282e5c31af7Sopenharmony_ciINTERFACEDEPEND = $(INTERFACEPATH)/timeMarker
283e5c31af7Sopenharmony_ciSPIRVCAPDEPEND = $(SPIRVCAPPATH)/timeMarker
284e5c31af7Sopenharmony_ciFORMATSDEPEND = $(FORMATSPATH)/timeMarker
285e5c31af7Sopenharmony_ciSYNCDEPEND = $(SYNCPATH)/timeMarker
286e5c31af7Sopenharmony_ciRUBYDEPEND     = $(RBAPIMAP)
287e5c31af7Sopenharmony_ciATTRIBFILE     = $(GENERATED)/specattribs.adoc
288e5c31af7Sopenharmony_ci# All generated dependencies
289e5c31af7Sopenharmony_ciGENDEPENDS     = $(APIDEPEND) $(VALIDITYDEPEND) $(HOSTSYNCDEPEND) $(METADEPEND) $(INTERFACEDEPEND) $(SPIRVCAPDEPEND) $(FORMATSDEPEND) $(SYNCDEPEND) $(RUBYDEPEND) $(ATTRIBFILE)
290e5c31af7Sopenharmony_ci# All non-format-specific dependencies
291e5c31af7Sopenharmony_ciCOMMONDOCS     = $(SPECFILES) $(GENDEPENDS)
292e5c31af7Sopenharmony_ci
293e5c31af7Sopenharmony_ci# Script to translate math on build time
294e5c31af7Sopenharmony_ciTRANSLATEMATH = $(NODEJS) $(SCRIPTS)/translate_math.js $(KATEXSRCDIR)/katex.min.js
295e5c31af7Sopenharmony_ci
296e5c31af7Sopenharmony_ci# Install katex in KATEXINSTDIR ($(OUTDIR)/katex) to be shared by all
297e5c31af7Sopenharmony_ci# HTML targets.
298e5c31af7Sopenharmony_ci# We currently only need the css and fonts, but copy all of KATEXSRCDIR anyway.
299e5c31af7Sopenharmony_ci$(KATEXINSTDIR): $(KATEXSRCDIR)
300e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(KATEXINSTDIR)
301e5c31af7Sopenharmony_ci	$(QUIET)$(RMRF)  $(KATEXINSTDIR)
302e5c31af7Sopenharmony_ci	$(QUIET)$(CP) -rf $(KATEXSRCDIR) $(KATEXINSTDIR)
303e5c31af7Sopenharmony_ci
304e5c31af7Sopenharmony_ci# Spec targets
305e5c31af7Sopenharmony_ci# There is some complexity to try and avoid short virtual targets like 'html'
306e5c31af7Sopenharmony_ci# causing specs to *always* be regenerated.
307e5c31af7Sopenharmony_ci
308e5c31af7Sopenharmony_ciCHUNKER = $(SCRIPTS)/asciidoctor-chunker/asciidoctor-chunker.js
309e5c31af7Sopenharmony_ciCHUNKINDEX = $(CONFIGS)/chunkindex
310e5c31af7Sopenharmony_ci# Only the $(CHUNKER) step is required unless the search index is to be
311e5c31af7Sopenharmony_ci# generated and incorporated into the chunked spec.
312e5c31af7Sopenharmony_ci#
313e5c31af7Sopenharmony_ci# Dropped $(QUIET) for now
314e5c31af7Sopenharmony_ci# Should set NODE_PATH=/usr/local/lib/node_modules or wherever, outside Makefile
315e5c31af7Sopenharmony_ci# Copying chunked.js into target avoids a warning from the chunker
316e5c31af7Sopenharmony_cichunked: $(HTMLDIR)/vkspec.html $(SPECSRC) $(COMMONDOCS)
317e5c31af7Sopenharmony_ci	$(QUIET)$(CHUNKINDEX)/addscripts.sh $(HTMLDIR)/vkspec.html $(HTMLDIR)/prechunked.html
318e5c31af7Sopenharmony_ci	$(QUIET)$(CP) $(CHUNKINDEX)/chunked.css $(CHUNKINDEX)/chunked.js \
319e5c31af7Sopenharmony_ci	    $(CHUNKINDEX)/lunr.js $(HTMLDIR)
320e5c31af7Sopenharmony_ci	$(QUIET)$(NODEJS) $(CHUNKER) $(HTMLDIR)/prechunked.html -o $(HTMLDIR)
321e5c31af7Sopenharmony_ci	$(QUIET)$(RM) $(HTMLDIR)/prechunked.html
322e5c31af7Sopenharmony_ci	$(QUIET)$(RUBY) $(CHUNKINDEX)/generate-index.rb $(HTMLDIR)/chap*html | \
323e5c31af7Sopenharmony_ci	    $(NODEJS) $(CHUNKINDEX)/build-index.js > $(HTMLDIR)/search.index.js
324e5c31af7Sopenharmony_ci
325e5c31af7Sopenharmony_ci# This is a temporary target while the new chunker is pre-release.
326e5c31af7Sopenharmony_ci# Eventually we will either pull the chunker into CI, or permanently
327e5c31af7Sopenharmony_ci# store a copy of the short JavaScript chunker in this repository.
328e5c31af7Sopenharmony_ciCHUNKERVERSION = asciidoctor-chunker_v1.0.0
329e5c31af7Sopenharmony_ciCHUNKURL = https://github.com/wshito/asciidoctor-chunker/releases/download/v1.0.0/$(CHUNKERVERSION).zip
330e5c31af7Sopenharmony_cigetchunker:
331e5c31af7Sopenharmony_ci	wget $(CHUNKURL) -O $(CHUNKERVERSION).zip
332e5c31af7Sopenharmony_ci	unzip $(CHUNKERVERSION).zip
333e5c31af7Sopenharmony_ci	mv $(CHUNKERVERSION)/* scripts/asciidoctor-chunker/
334e5c31af7Sopenharmony_ci	$(RMRF) $(CHUNKERVERSION).zip $(CHUNKERVERSION)
335e5c31af7Sopenharmony_ci
336e5c31af7Sopenharmony_cihtml: $(HTMLDIR)/vkspec.html $(SPECSRC) $(COMMONDOCS)
337e5c31af7Sopenharmony_ci
338e5c31af7Sopenharmony_ci$(HTMLDIR)/vkspec.html: KATEXDIR = ../katex
339e5c31af7Sopenharmony_ci$(HTMLDIR)/vkspec.html: $(SPECSRC) $(COMMONDOCS) $(KATEXINSTDIR)
340e5c31af7Sopenharmony_ci	$(QUIET)$(ASCIIDOC) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(SPECSRC)
341e5c31af7Sopenharmony_ci	$(QUIET)$(TRANSLATEMATH) $@
342e5c31af7Sopenharmony_ci
343e5c31af7Sopenharmony_cidiff_html: $(HTMLDIR)/diff.html $(SPECSRC) $(COMMONDOCS)
344e5c31af7Sopenharmony_ci
345e5c31af7Sopenharmony_ci$(HTMLDIR)/diff.html: KATEXDIR = ../katex
346e5c31af7Sopenharmony_ci$(HTMLDIR)/diff.html: $(SPECSRC) $(COMMONDOCS) $(KATEXINSTDIR)
347e5c31af7Sopenharmony_ci	$(QUIET)$(ASCIIDOC) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) \
348e5c31af7Sopenharmony_ci	    -a diff_extensions="$(DIFFEXTENSIONS)" \
349e5c31af7Sopenharmony_ci	    -r $(CONFIGS)/extension-highlighter.rb --trace \
350e5c31af7Sopenharmony_ci	    -o $@ $(SPECSRC)
351e5c31af7Sopenharmony_ci	$(QUIET)$(TRANSLATEMATH) $@
352e5c31af7Sopenharmony_ci
353e5c31af7Sopenharmony_ci# PDF optimizer - usage $(OPTIMIZEPDF) in.pdf out.pdf
354e5c31af7Sopenharmony_ci# OPTIMIZEPDFOPTS=--compress-pages is slightly better, but much slower
355e5c31af7Sopenharmony_ciOPTIMIZEPDF = hexapdf optimize $(OPTIMIZEPDFOPTS)
356e5c31af7Sopenharmony_ci
357e5c31af7Sopenharmony_cipdf: $(PDFDIR)/vkspec.pdf $(SPECSRC) $(COMMONDOCS)
358e5c31af7Sopenharmony_ci
359e5c31af7Sopenharmony_ci$(PDFDIR)/vkspec.pdf: $(SPECSRC) $(COMMONDOCS)
360e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(PDFDIR)
361e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(PDFMATHDIR)
362e5c31af7Sopenharmony_ci	$(QUIET)$(ASCIIDOC) -b pdf $(ADOCOPTS) $(ADOCPDFOPTS) -o $@ $(SPECSRC)
363e5c31af7Sopenharmony_ci	$(QUIET)$(OPTIMIZEPDF) $@ $@.out.pdf && mv $@.out.pdf $@
364e5c31af7Sopenharmony_ci	$(QUIET)$(RMRF) $(PDFMATHDIR)
365e5c31af7Sopenharmony_ci
366e5c31af7Sopenharmony_civalidusage: $(VUDIR)/validusage.json $(SPECSRC) $(COMMONDOCS)
367e5c31af7Sopenharmony_ci
368e5c31af7Sopenharmony_ci$(VUDIR)/validusage.json: $(SPECSRC) $(COMMONDOCS)
369e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(VUDIR)
370e5c31af7Sopenharmony_ci	$(QUIET)$(ASCIIDOC) $(ADOCOPTS) $(ADOCVUOPTS) --trace \
371e5c31af7Sopenharmony_ci	    -a json_output=$@ -o $@ $(SPECSRC)
372e5c31af7Sopenharmony_ci
373e5c31af7Sopenharmony_ci# Vulkan Documentation and Extensions, a.k.a. "Style Guide" documentation
374e5c31af7Sopenharmony_ci
375e5c31af7Sopenharmony_ciSTYLESRC = styleguide.adoc
376e5c31af7Sopenharmony_ciSTYLEFILES = $(wildcard $(SPECDIR)/style/[A-Za-z]*.adoc)
377e5c31af7Sopenharmony_ci
378e5c31af7Sopenharmony_cistyleguide: $(OUTDIR)/styleguide.html
379e5c31af7Sopenharmony_ci
380e5c31af7Sopenharmony_ci$(OUTDIR)/styleguide.html: KATEXDIR = katex
381e5c31af7Sopenharmony_ci$(OUTDIR)/styleguide.html: $(STYLESRC) $(STYLEFILES) $(GENDEPENDS) $(KATEXINSTDIR)
382e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(OUTDIR)
383e5c31af7Sopenharmony_ci	$(QUIET)$(ASCIIDOC) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(STYLESRC)
384e5c31af7Sopenharmony_ci	$(QUIET)$(TRANSLATEMATH) $@
385e5c31af7Sopenharmony_ci
386e5c31af7Sopenharmony_ci
387e5c31af7Sopenharmony_ci# Vulkan API Registry (XML Schema) documentation
388e5c31af7Sopenharmony_ci# Currently does not use latexmath / KaTeX
389e5c31af7Sopenharmony_ci
390e5c31af7Sopenharmony_ciREGSRC = registry.adoc
391e5c31af7Sopenharmony_ci
392e5c31af7Sopenharmony_ciregistry: $(OUTDIR)/registry.html
393e5c31af7Sopenharmony_ci
394e5c31af7Sopenharmony_ci$(OUTDIR)/registry.html: KATEXDIR = katex
395e5c31af7Sopenharmony_ci$(OUTDIR)/registry.html: $(REGSRC) $(GENDEPENDS)
396e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(OUTDIR)
397e5c31af7Sopenharmony_ci	$(QUIET)$(ASCIIDOC) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(REGSRC)
398e5c31af7Sopenharmony_ci	$(QUIET)$(TRANSLATEMATH) $@
399e5c31af7Sopenharmony_ci
400e5c31af7Sopenharmony_ci# Build proposal documents
401e5c31af7Sopenharmony_ciPROPOSALSOURCES   = $(filter-out $(PROPOSALPATH)/template.adoc, $(wildcard $(PROPOSALPATH)/*.adoc))
402e5c31af7Sopenharmony_ciPROPOSALDOCS	  = $(PROPOSALSOURCES:$(PROPOSALPATH)/%.adoc=$(PROPOSALDIR)/%.html)
403e5c31af7Sopenharmony_ciproposals: $(PROPOSALDOCS) $(PROPOSALSOURCES)
404e5c31af7Sopenharmony_ci
405e5c31af7Sopenharmony_ci# Proposal documents are built outside of the main specification
406e5c31af7Sopenharmony_ci$(PROPOSALDIR)/%.html: $(PROPOSALPATH)/%.adoc
407e5c31af7Sopenharmony_ci	$(QUIET)$(ASCIIDOC) --failure-level ERROR -b html5 -o $@ $<
408e5c31af7Sopenharmony_ci	$(QUIET) if egrep -q '\\[([]' $@ ; then \
409e5c31af7Sopenharmony_ci	    $(TRANSLATEMATH) $@ ; \
410e5c31af7Sopenharmony_ci	fi
411e5c31af7Sopenharmony_ci
412e5c31af7Sopenharmony_ci# Reflow text in spec sources
413e5c31af7Sopenharmony_ciREFLOW = $(SCRIPTS)/reflow.py
414e5c31af7Sopenharmony_ciREFLOWOPTS = -overwrite
415e5c31af7Sopenharmony_ci
416e5c31af7Sopenharmony_cireflow:
417e5c31af7Sopenharmony_ci	$(QUIET) echo "Warning: please verify the spec outputs build without changes!"
418e5c31af7Sopenharmony_ci	$(PYTHON) $(REFLOW) $(REFLOWOPTS) $(SPECSRC) $(SPECFILES) $(STYLESRC) $(STYLEFILES)
419e5c31af7Sopenharmony_ci
420e5c31af7Sopenharmony_ci# Automated markup and consistency checks, invoked by 'allchecks' and
421e5c31af7Sopenharmony_ci# 'ci-allchecks' targets or individually.
422e5c31af7Sopenharmony_ci
423e5c31af7Sopenharmony_ci# Look for disallowed contractions
424e5c31af7Sopenharmony_ciCHECK_CONTRACTIONS = git grep -i -F -f $(ROOTDIR)/config/CI/contractions | egrep -v -E -f $(ROOTDIR)/config/CI/contractions-allowed
425e5c31af7Sopenharmony_cicheck-contractions:
426e5c31af7Sopenharmony_ci	if test `$(CHECK_CONTRACTIONS) | wc -l` != 0 ; then \
427e5c31af7Sopenharmony_ci	    echo "Contractions found that are not allowed:" ; \
428e5c31af7Sopenharmony_ci	    $(CHECK_CONTRACTIONS) ; \
429e5c31af7Sopenharmony_ci	    exit 1 ; \
430e5c31af7Sopenharmony_ci	fi
431e5c31af7Sopenharmony_ci
432e5c31af7Sopenharmony_ci# Look for typos and suggest fixes
433e5c31af7Sopenharmony_ciCODESPELL = codespell --config $(ROOTDIR)/config/CI/codespellrc -S '*.js' -S './antora*/*' -S 'ERRS*,*.pdf,*.html'
434e5c31af7Sopenharmony_cicheck-spelling:
435e5c31af7Sopenharmony_ci	if ! $(CODESPELL) > /dev/null ; then \
436e5c31af7Sopenharmony_ci	    echo "Found probable misspellings. Corrections can be added to config/CI/codespell-allowed:" ; \
437e5c31af7Sopenharmony_ci	    $(CODESPELL) ; \
438e5c31af7Sopenharmony_ci	    exit 1 ; \
439e5c31af7Sopenharmony_ci	fi
440e5c31af7Sopenharmony_ci
441e5c31af7Sopenharmony_ci# Look for old or unpreferred language in specification language.
442e5c31af7Sopenharmony_ci# This mostly helps when we make global changes that also need to be
443e5c31af7Sopenharmony_ci# made in outstanding extension branches for new text.
444e5c31af7Sopenharmony_ciCHECK_WRITING = git grep -E -f $(ROOTDIR)/config/CI/writing $(SPECDIR)/registry.adoc $(SPECDIR)/vkspec.adoc $(SPECDIR)/chapters $(SPECDIR)/appendices
445e5c31af7Sopenharmony_cicheck-writing:
446e5c31af7Sopenharmony_ci	if test `$(CHECK_WRITING) | wc -l` != 0 ; then \
447e5c31af7Sopenharmony_ci	    echo "Found old style writing. Please refer to the style guide or similar language in current main branch for fixes:" ; \
448e5c31af7Sopenharmony_ci	    $(CHECK_WRITING) ; \
449e5c31af7Sopenharmony_ci	    exit 1 ; \
450e5c31af7Sopenharmony_ci	fi
451e5c31af7Sopenharmony_ci
452e5c31af7Sopenharmony_ci# Look for bullet list items not preceded by exactly two spaces, per styleguide
453e5c31af7Sopenharmony_ciCHECK_BULLETS = git grep -E '^( |   +)[-*]+ ' $(SPECDIR)/chapters $(SPECDIR)/appendices $(SPECDIR)/style $(SPECDIR)/[a-z]*.adoc
454e5c31af7Sopenharmony_cicheck-bullets:
455e5c31af7Sopenharmony_ci	if test `$(CHECK_BULLETS) | wc -l` != 0 ; then \
456e5c31af7Sopenharmony_ci	    echo "Bullet list item found not preceded by exactly two spaces:" ; \
457e5c31af7Sopenharmony_ci	    $(CHECK_BULLETS) ; \
458e5c31af7Sopenharmony_ci	    exit 1 ; \
459e5c31af7Sopenharmony_ci	fi
460e5c31af7Sopenharmony_ci
461e5c31af7Sopenharmony_ci# Look for asciidoctor conditionals inside VU statements; and for
462e5c31af7Sopenharmony_ci# duplicated VUID numbers, but only in spec sources.
463e5c31af7Sopenharmony_cicheck-reflow:
464e5c31af7Sopenharmony_ci	$(PYTHON) $(SCRIPTS)/reflow.py -nowrite -noflow -check FAIL -checkVUID FAIL $(SPECFILES)
465e5c31af7Sopenharmony_ci
466e5c31af7Sopenharmony_ci# Look for files whose Khronos copyright has not been updated to the
467e5c31af7Sopenharmony_ci# current year
468e5c31af7Sopenharmony_ciDATE_YEAR = $(shell date +%Y)
469e5c31af7Sopenharmony_ciCHECK_DATES = git grep -z -l 'Copyright.*The Khronos' | xargs -0 git grep -L 'Copyright.*$(DATE_YEAR).*The Khronos'
470e5c31af7Sopenharmony_cicheck-copyright-dates:
471e5c31af7Sopenharmony_ci	if test `$(CHECK_DATES) | wc -l` != 0 ; then \
472e5c31af7Sopenharmony_ci	    echo "Files with out-of-date Khronos copyrights (must be updated to $(DATE_YEAR):" ; \
473e5c31af7Sopenharmony_ci	    $(CHECK_DATES) ; \
474e5c31af7Sopenharmony_ci	    exit 1 ; \
475e5c31af7Sopenharmony_ci	 fi
476e5c31af7Sopenharmony_ci
477e5c31af7Sopenharmony_ci# Look for proper use of custom markup macros
478e5c31af7Sopenharmony_ci#   --ignore_count 0 can be incremented if there are unfixable errors
479e5c31af7Sopenharmony_cicheck-links:
480e5c31af7Sopenharmony_ci	$(PYTHON) $(SCRIPTS)/check_spec_links.py -Werror --ignore_count 0
481e5c31af7Sopenharmony_ci
482e5c31af7Sopenharmony_ci# Perform XML consistency checks
483e5c31af7Sopenharmony_ci# Use '-warn' option to display warnings as well as errors
484e5c31af7Sopenharmony_cicheck-consistency:
485e5c31af7Sopenharmony_ci	$(PYTHON) $(SCRIPTS)/xml_consistency.py
486e5c31af7Sopenharmony_ci
487e5c31af7Sopenharmony_ci# Looks for untagged use of 'undefined' in spec sources
488e5c31af7Sopenharmony_cicheck-undefined:
489e5c31af7Sopenharmony_ci	$(SCRIPTS)/ci/check_undefined
490e5c31af7Sopenharmony_ci
491e5c31af7Sopenharmony_ci# Look for '.txt' files, which should almost all be .adoc now
492e5c31af7Sopenharmony_ciCHECK_TXTFILES = find . -name '*.txt' | egrep -v -E -f $(ROOTDIR)/config/CI/txt-files-allowed
493e5c31af7Sopenharmony_cicheck-txtfiles:
494e5c31af7Sopenharmony_ci	if test `$(CHECK_TXTFILES) | wc -l` != 0 ; then \
495e5c31af7Sopenharmony_ci	    echo "*.txt files found that are not allowed (use .adoc):" ; \
496e5c31af7Sopenharmony_ci	    $(CHECK_TXTFILES) ; \
497e5c31af7Sopenharmony_ci	    exit 1 ; \
498e5c31af7Sopenharmony_ci	fi
499e5c31af7Sopenharmony_ci
500e5c31af7Sopenharmony_ci# Check for valid xrefs in the output html
501e5c31af7Sopenharmony_cicheck-xrefs: $(HTMLDIR)/vkspec.html
502e5c31af7Sopenharmony_ci	$(SCRIPTS)/check_html_xrefs.py $(HTMLDIR)/vkspec.html
503e5c31af7Sopenharmony_ci
504e5c31af7Sopenharmony_ci# Clean generated and output files
505e5c31af7Sopenharmony_ci
506e5c31af7Sopenharmony_ciclean: clean_html clean_pdf clean_man clean_generated clean_validusage
507e5c31af7Sopenharmony_ci
508e5c31af7Sopenharmony_ciclean_html:
509e5c31af7Sopenharmony_ci	$(QUIET)$(RMRF) $(HTMLDIR) $(OUTDIR)/katex
510e5c31af7Sopenharmony_ci	$(QUIET)$(RM) $(OUTDIR)/apispec.html $(OUTDIR)/styleguide.html \
511e5c31af7Sopenharmony_ci	    $(OUTDIR)/registry.html
512e5c31af7Sopenharmony_ci
513e5c31af7Sopenharmony_ciclean_pdf:
514e5c31af7Sopenharmony_ci	$(QUIET)$(RMRF) $(PDFDIR) $(OUTDIR)/apispec.pdf
515e5c31af7Sopenharmony_ci
516e5c31af7Sopenharmony_ciclean_man:
517e5c31af7Sopenharmony_ci	$(QUIET)$(RMRF) $(MANHTMLDIR)
518e5c31af7Sopenharmony_ci
519e5c31af7Sopenharmony_ci# Generated directories and files to remove
520e5c31af7Sopenharmony_ciCLEAN_GEN_PATHS = \
521e5c31af7Sopenharmony_ci    $(APIPATH) \
522e5c31af7Sopenharmony_ci    $(HOSTSYNCPATH) \
523e5c31af7Sopenharmony_ci    $(VALIDITYPATH) \
524e5c31af7Sopenharmony_ci    $(METAPATH) \
525e5c31af7Sopenharmony_ci    $(INTERFACEPATH) \
526e5c31af7Sopenharmony_ci    $(SPIRVCAPPATH) \
527e5c31af7Sopenharmony_ci    $(FORMATSPATH) \
528e5c31af7Sopenharmony_ci    $(SYNCPATH) \
529e5c31af7Sopenharmony_ci    $(REFPATH) \
530e5c31af7Sopenharmony_ci    $(GENERATED)/include \
531e5c31af7Sopenharmony_ci    $(GENERATED)/__pycache__ \
532e5c31af7Sopenharmony_ci    $(PDFMATHDIR) \
533e5c31af7Sopenharmony_ci    $(JSAPIMAP) \
534e5c31af7Sopenharmony_ci    $(PYAPIMAP) \
535e5c31af7Sopenharmony_ci    $(RBAPIMAP) \
536e5c31af7Sopenharmony_ci    $(ATTRIBFILE)
537e5c31af7Sopenharmony_ci
538e5c31af7Sopenharmony_ciclean_generated:
539e5c31af7Sopenharmony_ci	$(QUIET)$(RMRF) $(CLEAN_GEN_PATHS)
540e5c31af7Sopenharmony_ci
541e5c31af7Sopenharmony_ciclean_validusage:
542e5c31af7Sopenharmony_ci	$(QUIET)$(RM) $(VUDIR)/validusage.json
543e5c31af7Sopenharmony_ci
544e5c31af7Sopenharmony_ci
545e5c31af7Sopenharmony_ci# Generated refpage sources. For now, always build all refpages.
546e5c31af7Sopenharmony_ciMANSOURCES   = $(filter-out $(REFPATH)/apispec.adoc, $(wildcard $(REFPATH)/*.adoc))
547e5c31af7Sopenharmony_ci
548e5c31af7Sopenharmony_ci# Generation of refpage asciidoctor sources by extraction from the
549e5c31af7Sopenharmony_ci# specification(s).
550e5c31af7Sopenharmony_ci#
551e5c31af7Sopenharmony_ci# Should have a proper dependency causing the man page sources to be
552e5c31af7Sopenharmony_ci# generated by running genRef (once), but adding $(MANSOURCES) to the
553e5c31af7Sopenharmony_ci# targets causes genRef to run once/target.
554e5c31af7Sopenharmony_ci#
555e5c31af7Sopenharmony_ci# Should pass in $(EXTOPTIONS) to determine which pages to generate.
556e5c31af7Sopenharmony_ci# For now, all core and extension refpages are extracted by genRef.py.
557e5c31af7Sopenharmony_ciGENREF = $(SCRIPTS)/genRef.py
558e5c31af7Sopenharmony_ciLOGFILE = $(REFPATH)/refpage.log
559e5c31af7Sopenharmony_cirefpages: $(REFPATH)/apispec.adoc
560e5c31af7Sopenharmony_ci$(REFPATH)/apispec.adoc: $(SPECFILES) $(GENREF) $(SCRIPTS)/reflib.py $(PYAPIMAP)
561e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(REFPATH)
562e5c31af7Sopenharmony_ci	$(PYTHON) $(GENREF) -genpath $(GENERATED) -basedir $(REFPATH) \
563e5c31af7Sopenharmony_ci	    -log $(LOGFILE) -extpath $(SPECDIR)/appendices \
564e5c31af7Sopenharmony_ci	    $(EXTOPTIONS) $(SPECFILES)
565e5c31af7Sopenharmony_ci
566e5c31af7Sopenharmony_ci# These targets are HTML5 refpages
567e5c31af7Sopenharmony_ci#
568e5c31af7Sopenharmony_ci# The recursive $(MAKE) is an apparently unavoidable hack, since the
569e5c31af7Sopenharmony_ci# actual list of man page sources is not known until after
570e5c31af7Sopenharmony_ci# $(REFPATH)/apispec.adoc is generated. $(GENDEPENDS) is generated before
571e5c31af7Sopenharmony_ci# running the recursive make, so it does not trigger twice
572e5c31af7Sopenharmony_ci# $(SUBMAKEOPTIONS) suppresses the redundant "Entering / leaving"
573e5c31af7Sopenharmony_ci# messages make normally prints out, similarly to suppressing make
574e5c31af7Sopenharmony_ci# command output logging in the individual refpage actions below.
575e5c31af7Sopenharmony_ciSUBMAKEOPTIONS = --no-print-directory
576e5c31af7Sopenharmony_cimanhtmlpages: $(REFPATH)/apispec.adoc $(GENDEPENDS)
577e5c31af7Sopenharmony_ci	$(QUIET) echo "manhtmlpages: building HTML refpages with these options:"
578e5c31af7Sopenharmony_ci	$(QUIET) echo $(ASCIIDOC) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) \
579e5c31af7Sopenharmony_ci	    $(ADOCREFOPTS) -d manpage -o REFPAGE.html REFPAGE.adoc
580e5c31af7Sopenharmony_ci	$(MAKE) $(SUBMAKEOPTIONS) -e buildmanpages
581e5c31af7Sopenharmony_ci
582e5c31af7Sopenharmony_ci# Build the individual refpages, then the symbolic links from aliases
583e5c31af7Sopenharmony_ciMANHTMLDIR  = $(OUTDIR)/man/html
584e5c31af7Sopenharmony_ciMANHTML     = $(MANSOURCES:$(REFPATH)/%.adoc=$(MANHTMLDIR)/%.html)
585e5c31af7Sopenharmony_cibuildmanpages: $(MANHTML)
586e5c31af7Sopenharmony_ci	$(MAKE) $(SUBMAKEOPTIONS) -e manaliases
587e5c31af7Sopenharmony_ci
588e5c31af7Sopenharmony_ci# Asciidoctor options to build refpages
589e5c31af7Sopenharmony_ci#
590e5c31af7Sopenharmony_ci# ADOCREFOPTS *must* be placed after ADOCOPTS in the command line, so
591e5c31af7Sopenharmony_ci# that it can override spec attribute values.
592e5c31af7Sopenharmony_ci#
593e5c31af7Sopenharmony_ci# cross-file-links makes custom macros link to other refpages
594e5c31af7Sopenharmony_ci# refprefix includes the refpage (not spec) extension metadata.
595e5c31af7Sopenharmony_ci# isrefpage is for refpage-specific content
596e5c31af7Sopenharmony_ci# html_spec_relative is where to find the full specification
597e5c31af7Sopenharmony_ciADOCREFOPTS = -a cross-file-links -a refprefix='refpage.' -a isrefpage \
598e5c31af7Sopenharmony_ci	      -a html_spec_relative='../../html/vkspec.html'
599e5c31af7Sopenharmony_ci
600e5c31af7Sopenharmony_ci# The refpage build process normally generates far too much output, so
601e5c31af7Sopenharmony_ci# use VERYQUIET instead of QUIET
602e5c31af7Sopenharmony_ci# Running translate_math.js on every refpage is slow and most of them
603e5c31af7Sopenharmony_ci# do not contain math, so do a quick search for latexmath delimiters.
604e5c31af7Sopenharmony_ci$(MANHTMLDIR)/%.html: KATEXDIR = ../../katex
605e5c31af7Sopenharmony_ci$(MANHTMLDIR)/%.html: $(REFPATH)/%.adoc $(GENDEPENDS) $(KATEXINSTDIR)
606e5c31af7Sopenharmony_ci	$(VERYQUIET)echo "Building $@ from $< using default options"
607e5c31af7Sopenharmony_ci	$(VERYQUIET)$(MKDIR) $(MANHTMLDIR)
608e5c31af7Sopenharmony_ci	$(VERYQUIET)$(ASCIIDOC) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) $(ADOCREFOPTS) \
609e5c31af7Sopenharmony_ci	    -d manpage -o $@ $<
610e5c31af7Sopenharmony_ci	$(VERYQUIET)if egrep -q '\\[([]' $@ ; then \
611e5c31af7Sopenharmony_ci	    $(TRANSLATEMATH) $@ ; \
612e5c31af7Sopenharmony_ci	fi
613e5c31af7Sopenharmony_ci
614e5c31af7Sopenharmony_ci# The 'manhtml' and 'manpdf' targets are NO LONGER SUPPORTED by Khronos.
615e5c31af7Sopenharmony_ci# They generate HTML5 and PDF single-file versions of the refpages.
616e5c31af7Sopenharmony_ci# The generated refpage sources are included by $(REFPATH)/apispec.adoc,
617e5c31af7Sopenharmony_ci# and are always generated along with that file. Therefore there is no
618e5c31af7Sopenharmony_ci# need for a recursive $(MAKE) or a $(MANHTML) dependency, unlike the
619e5c31af7Sopenharmony_ci# manhtmlpages target.
620e5c31af7Sopenharmony_ci
621e5c31af7Sopenharmony_cimanpdf: $(OUTDIR)/apispec.pdf
622e5c31af7Sopenharmony_ci
623e5c31af7Sopenharmony_ci$(OUTDIR)/apispec.pdf: $(SPECVERSION) $(REFPATH)/apispec.adoc $(SVGFILES) $(GENDEPENDS)
624e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(OUTDIR)
625e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(PDFMATHDIR)
626e5c31af7Sopenharmony_ci	$(QUIET)$(ASCIIDOC) -b pdf -a html_spec_relative='html/vkspec.html' \
627e5c31af7Sopenharmony_ci	    $(ADOCOPTS) $(ADOCPDFOPTS) -o $@ $(REFPATH)/apispec.adoc
628e5c31af7Sopenharmony_ci	$(QUIET)$(OPTIMIZEPDF) $@ $@.out.pdf && mv $@.out.pdf $@
629e5c31af7Sopenharmony_ci
630e5c31af7Sopenharmony_cimanhtml: $(OUTDIR)/apispec.html
631e5c31af7Sopenharmony_ci
632e5c31af7Sopenharmony_ci$(OUTDIR)/apispec.html: KATEXDIR = katex
633e5c31af7Sopenharmony_ci$(OUTDIR)/apispec.html: ADOCMISCOPTS =
634e5c31af7Sopenharmony_ci$(OUTDIR)/apispec.html: $(SPECVERSION) $(REFPATH)/apispec.adoc $(SVGFILES) $(GENDEPENDS) $(KATEXINSTDIR)
635e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(OUTDIR)
636e5c31af7Sopenharmony_ci	$(QUIET)$(ASCIIDOC) -b html5 -a html_spec_relative='html/vkspec.html' \
637e5c31af7Sopenharmony_ci	    $(ADOCOPTS) $(ADOCHTMLOPTS) -o $@ $(REFPATH)/apispec.adoc
638e5c31af7Sopenharmony_ci	$(QUIET)$(TRANSLATEMATH) $@
639e5c31af7Sopenharmony_ci
640e5c31af7Sopenharmony_ci# Create links for refpage aliases
641e5c31af7Sopenharmony_ci
642e5c31af7Sopenharmony_ciMAKEMANALIASES = $(SCRIPTS)/makemanaliases.py
643e5c31af7Sopenharmony_cimanaliases: $(PYAPIMAP)
644e5c31af7Sopenharmony_ci	$(PYTHON) $(MAKEMANALIASES) -genpath $(GENERATED) -refdir $(MANHTMLDIR)
645e5c31af7Sopenharmony_ci
646e5c31af7Sopenharmony_ci# Targets generated from the XML and registry processing scripts
647e5c31af7Sopenharmony_ci#   $(PYAPIMAP) (apimap.py) - Python encoding of the registry
648e5c31af7Sopenharmony_ci# The $(...DEPEND) targets are files named 'timeMarker' in generated
649e5c31af7Sopenharmony_ci# target directories. They serve as proxies for the multiple generated
650e5c31af7Sopenharmony_ci# files written for each target:
651e5c31af7Sopenharmony_ci#   apiinc / proxy $(APIDEPEND) - API interface include files in $(APIPATH)
652e5c31af7Sopenharmony_ci#   hostsyncinc / proxy $(HOSTSYNCDEPEND) - host sync table include files in $(HOSTSYNCPATH)
653e5c31af7Sopenharmony_ci#   validinc / proxy $(VALIDITYDEPEND) - API validity include files in $(VALIDITYPATH)
654e5c31af7Sopenharmony_ci#   extinc / proxy $(METADEPEND) - extension appendix metadata include files in $(METAPATH)
655e5c31af7Sopenharmony_ci#
656e5c31af7Sopenharmony_ci# $(VERSIONOPTIONS) specifies the core API versions which are included
657e5c31af7Sopenharmony_ci# in these targets, and is set above based on $(VERSIONS)
658e5c31af7Sopenharmony_ci#
659e5c31af7Sopenharmony_ci# $(EXTOPTIONS) specifies the extensions which are included in these
660e5c31af7Sopenharmony_ci# targets, and is set above based on $(EXTENSIONS).
661e5c31af7Sopenharmony_ci#
662e5c31af7Sopenharmony_ci# $(GENVKEXTRA) are extra options that can be passed to genvk.py, e.g.
663e5c31af7Sopenharmony_ci# '-diag diag'
664e5c31af7Sopenharmony_ci
665e5c31af7Sopenharmony_ciREGISTRY   = $(ROOTDIR)/xml
666e5c31af7Sopenharmony_ciVKXML	   = $(REGISTRY)/vk.xml
667e5c31af7Sopenharmony_ciGENVK	   = $(SCRIPTS)/genvk.py
668e5c31af7Sopenharmony_ciGENVKOPTS  = $(VERSIONOPTIONS) $(EXTOPTIONS) $(GENVKEXTRA) -registry $(VKXML)
669e5c31af7Sopenharmony_ciGENVKEXTRA =
670e5c31af7Sopenharmony_ci
671e5c31af7Sopenharmony_ciscriptapi: jsapi pyapi rubyapi
672e5c31af7Sopenharmony_ci
673e5c31af7Sopenharmony_cijsapi $(JSAPIMAP): $(VKXML) $(GENVK)
674e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(GENERATED)
675e5c31af7Sopenharmony_ci	$(QUIET)$(PYTHON) $(GENVK) $(GENVKOPTS) -o $(GENERATED) apimap.cjs
676e5c31af7Sopenharmony_ci
677e5c31af7Sopenharmony_cipyapi $(PYAPIMAP): $(VKXML) $(GENVK)
678e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(GENERATED)
679e5c31af7Sopenharmony_ci	$(QUIET)$(PYTHON) $(GENVK) $(GENVKOPTS) -o $(GENERATED) apimap.py
680e5c31af7Sopenharmony_ci
681e5c31af7Sopenharmony_cirubyapi $(RBAPIMAP): $(VKXML) $(GENVK)
682e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(GENERATED)
683e5c31af7Sopenharmony_ci	$(QUIET)$(PYTHON) $(GENVK) $(GENVKOPTS) -o $(GENERATED) apimap.rb
684e5c31af7Sopenharmony_ci
685e5c31af7Sopenharmony_ciapiinc: $(APIDEPEND)
686e5c31af7Sopenharmony_ci
687e5c31af7Sopenharmony_ci$(APIDEPEND): $(VKXML) $(GENVK) $(PYAPIMAP)
688e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(APIPATH)
689e5c31af7Sopenharmony_ci	$(QUIET)$(PYTHON) $(GENVK) $(GENVKOPTS) -o $(APIPATH) -genpath $(GENERATED) apiinc
690e5c31af7Sopenharmony_ci
691e5c31af7Sopenharmony_cihostsyncinc: $(HOSTSYNCDEPEND)
692e5c31af7Sopenharmony_ci
693e5c31af7Sopenharmony_ci$(HOSTSYNCDEPEND): $(VKXML) $(GENVK)
694e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(HOSTSYNCPATH)
695e5c31af7Sopenharmony_ci	$(QUIET)$(PYTHON) $(GENVK) $(GENVKOPTS) -o $(HOSTSYNCPATH) hostsyncinc
696e5c31af7Sopenharmony_ci
697e5c31af7Sopenharmony_civalidinc: $(VALIDITYDEPEND)
698e5c31af7Sopenharmony_ci
699e5c31af7Sopenharmony_ci$(VALIDITYDEPEND): $(VKXML) $(GENVK)
700e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(VALIDITYPATH)
701e5c31af7Sopenharmony_ci	$(QUIET)$(PYTHON) $(GENVK) $(GENVKOPTS) -o $(VALIDITYPATH) validinc
702e5c31af7Sopenharmony_ci
703e5c31af7Sopenharmony_ciextinc: $(METAPATH)/timeMarker
704e5c31af7Sopenharmony_ci
705e5c31af7Sopenharmony_ci$(METADEPEND): $(VKXML) $(GENVK)
706e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(METAPATH)
707e5c31af7Sopenharmony_ci	$(QUIET)$(PYTHON) $(GENVK) $(GENVKOPTS) -o $(METAPATH) extinc
708e5c31af7Sopenharmony_ci
709e5c31af7Sopenharmony_ciinterfaceinc: $(INTERFACEPATH)/timeMarker
710e5c31af7Sopenharmony_ci
711e5c31af7Sopenharmony_ci$(INTERFACEDEPEND): $(VKXML) $(GENVK)
712e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(INTERFACEPATH)
713e5c31af7Sopenharmony_ci	$(QUIET)$(PYTHON) $(GENVK) $(GENVKOPTS) -o $(INTERFACEPATH) interfaceinc
714e5c31af7Sopenharmony_ci
715e5c31af7Sopenharmony_ci# This generates a single file, so SPIRVCAPDEPEND is the full path to
716e5c31af7Sopenharmony_ci# the file, rather than to a timeMarker in the same directory.
717e5c31af7Sopenharmony_cispirvcapinc: $(SPIRVCAPDEPEND)
718e5c31af7Sopenharmony_ci
719e5c31af7Sopenharmony_ci$(SPIRVCAPDEPEND): $(VKXML) $(GENVK)
720e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(SPIRVCAPPATH)
721e5c31af7Sopenharmony_ci	$(QUIET)$(PYTHON) $(GENVK) $(GENVKOPTS) -o $(SPIRVCAPPATH) spirvcapinc
722e5c31af7Sopenharmony_ci
723e5c31af7Sopenharmony_ci# This generates a single file, so FORMATSDEPEND is the full path to
724e5c31af7Sopenharmony_ci# the file, rather than to a timeMarker in the same directory.
725e5c31af7Sopenharmony_ciformatsinc: $(FORMATSDEPEND)
726e5c31af7Sopenharmony_ci
727e5c31af7Sopenharmony_ci$(FORMATSDEPEND): $(VKXML) $(GENVK)
728e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(FORMATSPATH)
729e5c31af7Sopenharmony_ci	$(QUIET)$(PYTHON) $(GENVK) $(GENVKOPTS) -o $(FORMATSPATH) formatsinc
730e5c31af7Sopenharmony_ci
731e5c31af7Sopenharmony_ci# This generates a single file, so FORMATSDEPEND is the full path to
732e5c31af7Sopenharmony_ci# the file, rather than to a timeMarker in the same directory.
733e5c31af7Sopenharmony_cisyncinc: $(SYNCDEPEND)
734e5c31af7Sopenharmony_ci
735e5c31af7Sopenharmony_ci$(SYNCDEPEND): $(VKXML) $(GENVK)
736e5c31af7Sopenharmony_ci	$(QUIET)$(MKDIR) $(SYNCPATH)
737e5c31af7Sopenharmony_ci	$(QUIET)$(PYTHON) $(GENVK) $(GENVKOPTS) -o $(SYNCPATH) syncinc
738e5c31af7Sopenharmony_ci
739e5c31af7Sopenharmony_ci# This generates a single file containing asciidoc attributes for each
740e5c31af7Sopenharmony_ci# core version and extension in the spec being built.
741e5c31af7Sopenharmony_ci# For use with Antora, it also includes a couple of document attributes
742e5c31af7Sopenharmony_ci# otherwise passed on the asciidoctor command line.
743e5c31af7Sopenharmony_ci# These should not use the asciidoctor attribute names (e.g. revnumber,
744e5c31af7Sopenharmony_ci# revdate), so use the Makefile variable names instead (e.g.
745e5c31af7Sopenharmony_ci# SPECREVISION, SPECDATE).
746e5c31af7Sopenharmony_ci
747e5c31af7Sopenharmony_ciattribs: $(ATTRIBFILE)
748e5c31af7Sopenharmony_ci
749e5c31af7Sopenharmony_ci$(ATTRIBFILE):
750e5c31af7Sopenharmony_ci	$(QUIET)for attrib in $(VERSIONS) $(EXTS) ; do \
751e5c31af7Sopenharmony_ci	    echo ":$${attrib}:" ; \
752e5c31af7Sopenharmony_ci	done > $@
753e5c31af7Sopenharmony_ci	$(QUIET)(echo ":SPECREVISION: $(SPECREVISION)" ; \
754e5c31af7Sopenharmony_ci		 echo ":SPECDATE: $(SPECDATE)" ; \
755e5c31af7Sopenharmony_ci		 echo ":SPECREMARK: $(SPECREMARK)" ; \
756e5c31af7Sopenharmony_ci		 echo ":APITITLE: $(APITITLE)") >> $@
757e5c31af7Sopenharmony_ci
758e5c31af7Sopenharmony_ci# Debugging aid - generate all files from registry XML
759e5c31af7Sopenharmony_cigenerated: $(PYAPIMAP) $(GENDEPENDS)
760