1 # Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
  2 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  3 #
  4 # This code is free software; you can redistribute it and/or modify it
  5 # under the terms of the GNU General Public License version 2 only, as
  6 # published by the Free Software Foundation.  Oracle designates this
  7 # particular file as subject to the "Classpath" exception as provided
  8 # by Oracle in the LICENSE file that accompanied this code.
  9 #
 10 # This code is distributed in the hope that it will be useful, but WITHOUT
 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13 # version 2 for more details (a copy is included in the LICENSE file that
 14 # accompanied this code).
 15 #
 16 # You should have received a copy of the GNU General Public License version
 17 # 2 along with this work; if not, write to the Free Software Foundation,
 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19 #
 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21 # or visit www.oracle.com if you need additional information or have any
 22 # questions.
 23 #
 24 
 25 default: all
 26 
 27 include $(SPEC)
 28 include MakeBase.gmk
 29 include Execute.gmk
 30 include Modules.gmk
 31 include ModuleTools.gmk
 32 include ProcessMarkdown.gmk
 33 include ToolsJdk.gmk
 34 include ZipArchive.gmk
 35 include TextFileProcessing.gmk
 36 
 37 # This is needed to properly setup DOCS_MODULES.
 38 $(eval $(call ReadImportMetaData))
 39 
 40 ################################################################################
 41 # Hook to include the corresponding custom file, if present.
 42 $(eval $(call IncludeCustomExtension, Docs.gmk))
 43 
 44 ################################################################################
 45 # This file generates all documentation for OpenJDK.
 46 #
 47 # We will generate API documentation for two different selections of the source
 48 # code: "Java SE", which contains just the modules covered by the top-level
 49 # module java.se and "JDK", which covers all of Java SE and also all
 50 # other available modules that should be documented, including imported modules,
 51 # if any.
 52 #
 53 # We will also generate separate, free-standing specifications from either
 54 # markdown or existing html files.
 55 #
 56 
 57 ################################################################################
 58 # Javadoc settings
 59 
 60 # Include configuration for URLs in generated javadoc
 61 include $(TOPDIR)/make/conf/javadoc.conf
 62 
 63 MODULES_SOURCE_PATH := $(call PathList, $(call GetModuleSrcPath) )
 64 
 65 
 66 # In order to get a specific ordering it's necessary to specify the total
 67 # ordering of tags as the tags are otherwise ordered in order of definition.
 68 JAVADOC_TAGS := \
 69     -tag beaninfo:X \
 70     -tag revised:X \
 71     -tag since.unbundled:X \
 72     -tag spec:X \
 73     -tag specdefault:X \
 74     -tag Note:X \
 75     -tag ToDo:X \
 76     -tag 'apiNote:a:API Note:' \
 77     -tag 'implSpec:a:Implementation Requirements:' \
 78     -tag 'implNote:a:Implementation Note:' \
 79     -tag param \
 80     -tag return \
 81     -tag throws \
 82     -taglet build.tools.taglet.JSpec\$$JLS \
 83     -taglet build.tools.taglet.JSpec\$$JVMS \
 84     -taglet build.tools.taglet.ModuleGraph \
 85     -taglet build.tools.taglet.ToolGuide \
 86     -tag since \
 87     -tag serialData \
 88     -tag factory \
 89     -tag see \
 90     -taglet build.tools.taglet.ExtLink \
 91     -taglet build.tools.taglet.Incubating \
 92     -tagletpath $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
 93     $(CUSTOM_JAVADOC_TAGS) \
 94     #
 95 
 96 # The reference tags must stay stable to allow for comparisons across the
 97 # development cycle. If JAVADOC_TAGS needs to change, make sure that
 98 # REFERENCE_TAGS remains unchanged, by copying and hardcoding, if necessary.
 99 REFERENCE_TAGS := $(JAVADOC_TAGS)
100 
101 # Which doclint checks to ignore
102 JAVADOC_DISABLED_DOCLINT_WARNINGS := missing
103 JAVADOC_DISABLED_DOCLINT_PACKAGES := org.w3c.* javax.smartcardio
104 
105 # The initial set of options for javadoc
106 JAVADOC_OPTIONS := -XDignore.symbol.file=true -use -keywords -notimestamp \
107     -serialwarn -encoding ISO-8859-1 -docencoding UTF-8 -breakiterator \
108     -splitIndex --system none -javafx --expand-requires transitive \
109     -XDenableValueTypes \
110     --override-methods=summary
111 
112 # The reference options must stay stable to allow for comparisons across the
113 # development cycle.
114 REFERENCE_OPTIONS := -XDignore.symbol.file=true -use -keywords -notimestamp \
115     -serialwarn -encoding ISO-8859-1 -breakiterator -splitIndex --system none \
116     -html5 -javafx --expand-requires transitive
117 
118 # Should we add DRAFT stamps to the generated javadoc?
119 ifeq ($(VERSION_IS_GA), true)
120   IS_DRAFT := false
121 else
122   IS_DRAFT := true
123 endif
124 
125 ################################################################################
126 # General text snippets
127 
128 FULL_COMPANY_NAME := Oracle and/or its affiliates
129 COMPANY_ADDRESS := 500 Oracle Parkway, Redwood Shores, CA 94065 USA
130 
131 JAVA_PLATFORM := Java Platform
132 
133 ifeq ($(IS_DRAFT), true)
134   DRAFT_MARKER_STR := <br><strong>DRAFT $(VERSION_STRING)</strong>
135   ifeq ($(VERSION_BUILD), 0)
136     DRAFT_MARKER_TITLE := $(SPACE)[ad-hoc build]
137   else
138     DRAFT_MARKER_TITLE := $(SPACE)[build $(VERSION_BUILD)]
139   endif
140   DRAFT_TEXT := This specification is not final and is subject to change. \
141       Use is subject to <a href="$(LICENSE_URL)">license terms</a>.
142 
143   # Workaround stylesheet bug
144   HEADER_STYLE := style="margin-top: 9px;"
145 else
146   HEADER_STYLE := style="margin-top: 14px;"
147 endif
148 
149 # $1 - Relative prefix to COPYRIGHT_URL
150 COPYRIGHT_BOTTOM = \
151     <a href="$(strip $1)$(COPYRIGHT_URL)">Copyright</a> \
152     &copy; 1993, $(COPYRIGHT_YEAR), $(FULL_COMPANY_NAME), \
153     $(COMPANY_ADDRESS).<br>All rights reserved. \
154     Use is subject to <a href="$(LICENSE_URL)">license terms</a> and the \
155     <a href="$(REDISTRIBUTION_URL)">documentation redistribution policy</a>. \
156     $(DRAFT_MARKER_STR) <!-- Version $(VERSION_STRING) -->
157 
158 # $1 - Optional "Other Versions" link
159 JAVADOC_BOTTOM = \
160     <a href="$(BUG_SUBMIT_URL)">Report a bug or suggest an enhancement</a><br> \
161     For further API reference and developer documentation see the \
162     <a href="$(JAVADOC_BASE_URL)" target="_blank">Java SE \
163     Documentation</a>, which contains more detailed, \
164     developer-targeted descriptions with conceptual overviews, definitions \
165     of terms, workarounds, and working code examples. $1<br> \
166     Java is a trademark or registered trademark of $(FULL_COMPANY_NAME) in \
167     the US and other countries.<br> \
168     $(call COPYRIGHT_BOTTOM, {@docroot}/../)
169 
170 JAVADOC_TOP := \
171     <div style="padding: 6px; text-align: center; font-size: 80%; \
172     font-family: DejaVu Sans, Arial, Helvetica, sans-serif; \
173     font-weight: normal;">$(DRAFT_TEXT)</div>
174 
175 ################################################################################
176 # JDK javadoc titles/text snippets
177 
178 JDK_SHORT_NAME := Java SE $(VERSION_SPECIFICATION) &amp; JDK $(VERSION_SPECIFICATION)
179 JDK_LONG_NAME := Java<sup>&reg;</sup> Platform, Standard Edition \
180     &amp;&nbsp;Java&nbsp;Development&nbsp;Kit
181 
182 ################################################################################
183 # Java SE javadoc titles/text snippets
184 
185 JAVASE_SHORT_NAME := Java SE $(VERSION_SPECIFICATION)
186 JAVASE_LONG_NAME := Java<sup>&reg;</sup> Platform, Standard Edition
187 
188 ################################################################################
189 # Functions
190 
191 # Helper function for creating a svg file from a dot file generated by the
192 # GenGraphs tool.
193 # param 1: SetupJavadocGeneration namespace ($1)
194 # param 2: module name
195 #
196 define setup_gengraph_dot_to_svg
197   $1_$2_DOT_SRC :=  $$($1_GENGRAPHS_DIR)/$2.dot
198   $1_$2_SVG_TARGET := $$($1_TARGET_DIR)/$2/module-graph.svg
199 
200     # For each module needing a graph, create a svg file from the dot file
201     # generated by the GenGraphs tool and store it in the target dir.
202     $$(eval $$(call SetupExecute, gengraphs_svg_$1_$2, \
203         INFO := Running dot for module graphs for $2, \
204         DEPS := $$(gengraphs_$1_TARGET), \
205         OUTPUT_FILE := $$($1_$2_SVG_TARGET), \
206         SUPPORT_DIR := $$($1_GENGRAPHS_DIR), \
207         COMMAND := $$(DOT) -Tsvg -o $$($1_$2_SVG_TARGET) $$($1_$2_DOT_SRC), \
208     ))
209 
210   $1_MODULEGRAPH_TARGETS += $$($1_$2_SVG_TARGET)
211 endef
212 
213 # Helper function to create the overview.html file to use with the -overview
214 # javadoc option.
215 # Returns the filename as $1_OVERVIEW.
216 #
217 # param 1: SetupJavadocGeneration namespace ($1)
218 define create_overview_file
219   $1_OVERVIEW_TEXT := \
220       <!DOCTYPE html> \
221       <html><head></head><body> \
222       #
223   ifneq ($$($1_GROUPS),)
224     $1_OVERVIEW_TEXT += \
225       <p>This document is divided into \
226       $$(subst 2,two,$$(subst 3,three,$$(words $$($1_GROUPS)))) sections:</p> \
227       <blockquote><dl> \
228       #
229     $1_OVERVIEW_TEXT += $$(foreach g, $$($1_GROUPS), \
230         <dt style="margin-top: 8px;">$$($$g_GROUP_NAME)</dt> \
231         <dd style="margin-top: 8px;">$$($$g_GROUP_DESCRIPTION)</dd> \
232     )
233     $1_OVERVIEW_TEXT += \
234         </dl></blockquote> \
235         #
236   endif
237   $1_OVERVIEW_TEXT += \
238       </body></html> \
239       #
240 
241   $1_OVERVIEW := $$(SUPPORT_OUTPUTDIR)/docs/$1-overview.html
242 
243   $1_OVERVIEW_VARDEPS_FILE := $$(call DependOnVariable, $1_OVERVIEW_TEXT, \
244       $$($1_OVERVIEW).vardeps)
245 
246   $$($1_OVERVIEW): $$($1_OVERVIEW_VARDEPS_FILE)
247 	$$(call LogInfo, Creating overview.html for $1)
248 	$$(call MakeDir, $$(@D))
249 	$$(PRINTF) > $$@ '$$($1_OVERVIEW_TEXT)'
250 endef
251 
252 ################################################################################
253 # Setup make rules to create an API documentation collection, using javadoc and
254 # other tools if needed.
255 #
256 # Parameter 1 is the name of the rule. This name is used as variable prefix.
257 # Targets generated are returned as $1_JAVADOC_TARGETS and
258 # $1_MODULEGRAPH_TARGETS. Note that the index.html file will work as a "touch
259 # file" for all the magnitude of files that are generated by javadoc.
260 #
261 # Remaining parameters are named arguments. These include:
262 #   MODULES - Modules to generate javadoc for
263 #   GROUPS - Name of the groups to divide the modules into, if any
264 #   SHORT_NAME - The short name of this documentation collection
265 #   LONG_NAME - The long name of this documentation collection
266 #   TARGET_DIR - Where to store the output
267 #   OTHER_VERSIONS - URL for other page listing versions
268 #
269 SetupApiDocsGeneration = $(NamedParamsMacroTemplate)
270 define SetupApiDocsGenerationBody
271 
272   # Figure out all modules, both specified and transitive indirect exports, that
273   # will be processed by javadoc.
274   $1_INDIRECT_EXPORTS := $$(call FindTransitiveIndirectDepsForModules, $$($1_MODULES))
275   $1_ALL_MODULES := $$(sort $$($1_MODULES) $$($1_INDIRECT_EXPORTS))
276 
277   $1_JAVA_ARGS := -Dextlink.spec.version=$$(VERSION_SPECIFICATION) \
278 	-Djspec.version=$$(VERSION_SPECIFICATION)
279 
280   ifeq ($$(ENABLE_FULL_DOCS), true)
281     # Tell the ModuleGraph taglet to generate html links to soon-to-be-created
282     # svg files with module graphs.
283     $1_JAVA_ARGS += -DenableModuleGraph=true
284   endif
285 
286   # Start with basic options and tags
287   ifeq ($$($1_OPTIONS), )
288     $1_OPTIONS := $$(JAVADOC_OPTIONS)
289   endif
290   ifeq ($$($1_TAGS), )
291     $1_TAGS := $$(JAVADOC_TAGS)
292   endif
293   $1_OPTIONS += $$($1_TAGS)
294 
295   $1_OPTIONS += --module-source-path $$(MODULES_SOURCE_PATH)
296   $1_OPTIONS += --module $$(call CommaList, $$($1_MODULES))
297 
298   # Create a string like "-Xdoclint:all,-syntax,-html,..."
299   $1_OPTIONS += -Xdoclint:all,$$(call CommaList, $$(addprefix -, \
300       $$(JAVADOC_DISABLED_DOCLINT_WARNINGS)))
301   # Ignore the doclint warnings in certain packages
302   $1_OPTIONS += -Xdoclint/package:$$(call CommaList, $$(addprefix -, \
303       $$(JAVADOC_DISABLED_DOCLINT_PACKAGES)))
304 
305   $1_DOC_TITLE := $$($1_LONG_NAME)<br>Version $$(VERSION_SPECIFICATION) API \
306       Specification
307   $1_WINDOW_TITLE := $$(subst &amp;,&,$$($1_SHORT_NAME))$$(DRAFT_MARKER_TITLE)
308   $1_HEADER_TITLE := <div $$(HEADER_STYLE)><strong>$$($1_SHORT_NAME)</strong> \
309       $$(DRAFT_MARKER_STR)</div>
310   ifneq ($$($1_OTHER_VERSIONS), )
311       $1_JAVADOC_BOTTOM := $$(call JAVADOC_BOTTOM, <a href="$$($1_OTHER_VERSIONS)">Other versions.</a>)
312   else
313       $1_JAVADOC_BOTTOM := $$(call JAVADOC_BOTTOM, )
314   endif
315 
316   $1_OPTIONS += -doctitle '$$($1_DOC_TITLE)'
317   $1_OPTIONS += -windowtitle '$$($1_WINDOW_TITLE)'
318   $1_OPTIONS += -header '$$($1_HEADER_TITLE)'
319   $1_OPTIONS += -bottom '$$($1_JAVADOC_BOTTOM)'
320   ifeq ($$(IS_DRAFT), true)
321     $1_OPTIONS += -top '$$(JAVADOC_TOP)'
322   endif
323 
324   # Do not store debug level options in VARDEPS.
325   ifneq ($$(LOG_LEVEL), trace)
326     $1_LOG_OPTION += -quiet
327   else
328     $1_LOG_OPTION += -verbose
329   endif
330 
331   # Generate the overview.html file. This will return the filename in
332   # $1_OVERVIEW.
333   $$(eval $$(call create_overview_file,$1))
334   $1_OPTIONS += -overview $$($1_OVERVIEW)
335 
336   # Add summary pages for new/deprecated APIs in recent releases
337   $1_OPTIONS += --since $(call CommaList, \
338       $(filter-out $(VERSION_DOCS_API_SINCE), \
339           $(call sequence, $(VERSION_DOCS_API_SINCE), $(VERSION_FEATURE))))
340   $1_OPTIONS += --since-label "New API since JDK $(VERSION_DOCS_API_SINCE)"
341 
342   $$(foreach g, $$($1_GROUPS), \
343     $$(eval $1_OPTIONS += -group "$$($$g_GROUP_NAME)" "$$($$g_GROUP_MODULES)") \
344   )
345 
346   ifeq ($$($1_JAVADOC_CMD), )
347     $1_JAVADOC_CMD := $$(JAVA) -Djava.awt.headless=true $$($1_JAVA_ARGS) \
348         $$(NEW_JAVADOC)
349   else
350     $1_OPTIONS += $$(addprefix -J, $$($1_JAVA_ARGS))
351   endif
352 
353   $1_VARDEPS := $$($1_JAVA_ARGS) $$($1_OPTIONS) $$(MODULES_SOURCE_PATH) \
354       $$($1_ALL_MODULES) $$($1_JAVADOC_CMD)
355   $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
356       $$(SUPPORT_OUTPUTDIR)/docs/$1.vardeps)
357 
358   # Get a list of all files in all the source dirs for all included modules
359   $1_SOURCE_DEPS := $$(call FindFiles, $$(wildcard $$(foreach module, \
360       $$($1_ALL_MODULES), $$(call FindModuleSrcDirs, $$(module)))))
361 
362   $$(eval $$(call SetupExecute, javadoc_$1, \
363       WARN := Generating $1 javadoc for $$(words $$($1_ALL_MODULES)) modules, \
364       INFO := Javadoc modules: $$($1_ALL_MODULES), \
365       DEPS := $$(BUILD_TOOLS_JDK) $$($1_VARDEPS_FILE) $$($1_SOURCE_DEPS) \
366           $$($1_OVERVIEW), \
367       OUTPUT_DIR := $$($1_TARGET_DIR), \
368       SUPPORT_DIR := $$(SUPPORT_OUTPUTDIR)/docs, \
369       COMMAND := $$($1_JAVADOC_CMD) -d $$($1_TARGET_DIR) $$($1_OPTIONS) \
370           $$($1_LOG_OPTION), \
371   ))
372 
373   $1_JAVADOC_TARGETS := $$(javadoc_$1_TARGET)
374 
375   ifeq ($$(ENABLE_FULL_DOCS), true)
376     # We have asked ModuleGraph to generate links to svg files. Now we must
377     # produce the svg files.
378 
379     # Locate which modules has the @moduleGraph tag in their module-info.java
380     $1_MODULES_NEEDING_GRAPH := $$(strip $$(foreach m, $$($1_ALL_MODULES), \
381       $$(if $$(shell $$(GREP) -e @moduleGraph \
382           $$(wildcard $$(addsuffix /module-info.java, \
383           $$(call FindModuleSrcDirs, $$m)))), \
384         $$m) \
385     ))
386 
387     # First we run the GenGraph tool. It will query the module structure of the
388     # running JVM and output .dot files for all existing modules.
389     GENGRAPHS_PROPS := \
390         $$(TOPDIR)/make/jdk/src/classes/build/tools/jigsaw/javadoc-graphs.properties
391 
392     $1_GENGRAPHS_DIR := $$(SUPPORT_OUTPUTDIR)/docs/$1-gengraphs
393 
394     $$(eval $$(call SetupExecute, gengraphs_$1, \
395         INFO := Running gengraphs for $1 documentation, \
396         DEPS := $$(BUILD_JIGSAW_TOOLS) $$(GENGRAPHS_PROPS), \
397         OUTPUT_DIR := $$($1_GENGRAPHS_DIR), \
398         COMMAND := $$(TOOL_GENGRAPHS) --spec --output $$($1_GENGRAPHS_DIR) \
399             --dot-attributes $$(GENGRAPHS_PROPS), \
400     ))
401 
402     # For each module needing a graph, create a svg file from the dot file
403     # generated by the GenGraphs tool and store it in the target dir.
404     # They will depend on gengraphs_$1_TARGET, and will be added to $1.
405     $$(foreach m, $$($1_MODULES_NEEDING_GRAPH), \
406       $$(eval $$(call setup_gengraph_dot_to_svg,$1,$$m)) \
407     )
408   endif
409 endef
410 
411 ################################################################################
412 # Setup generation of the JDK API documentation (javadoc + modulegraph)
413 
414 # Define the groups of the JDK API documentation
415 JavaSE_GROUP_NAME := Java SE
416 JavaSE_GROUP_MODULES := $(call ColonList, $(sort java.se \
417     $(call FindTransitiveIndirectDepsForModules, java.se)))
418 JavaSE_GROUP_DESCRIPTION := \
419     The Java Platform, Standard Edition (Java SE) APIs define the core Java \
420     platform for general-purpose computing. These APIs are in modules whose \
421     names start with {@code java}. \
422     #
423 JDK_GROUPS += JavaSE
424 
425 JDK_GROUP_NAME := JDK
426 JDK_GROUP_MODULES := jdk.*
427 JDK_GROUP_DESCRIPTION := \
428     The Java Development Kit (JDK) APIs are specific to the JDK and will not \
429     necessarily be available in all implementations of the Java SE Platform. \
430     These APIs are in modules whose names start with {@code jdk}. \
431     #
432 JDK_GROUPS += JDK
433 
434 # If we are importing JavaFX, we need a JavaFX group. In an ideal world, this
435 # would have been abstracted away to a more proper generic handling of imported
436 # modules.
437 ifneq ($(findstring javafx., $(IMPORTED_MODULES)), )
438   JavaFX_GROUP_NAME := JavaFX
439   JavaFX_GROUP_MODULES := javafx.*
440   JavaFX_GROUP_DESCRIPTION := \
441       The JavaFX APIs define a set of user-interface controls, graphics, \
442       media, and web packages for developing rich client applications. These \
443       APIs are in modules whose names start with {@code javafx}. \
444       #
445   JDK_GROUPS += JavaFX
446 endif
447 
448 # All modules to have docs generated by docs-jdk-api target
449 JDK_MODULES := $(sort $(filter-out $(MODULES_FILTER), $(DOCS_MODULES)))
450 
451 $(eval $(call SetupApiDocsGeneration, JDK_API, \
452     MODULES := $(JDK_MODULES), \
453     GROUPS := $(JDK_GROUPS), \
454     SHORT_NAME := $(JDK_SHORT_NAME), \
455     LONG_NAME := $(JDK_LONG_NAME), \
456     TARGET_DIR := $(DOCS_OUTPUTDIR)/api, \
457     OTHER_VERSIONS := $(OTHER_JDK_VERSIONS_URL), \
458 ))
459 
460 # Targets generated are returned in JDK_API_JAVADOC_TARGETS and
461 # JDK_API_MODULEGRAPH_TARGETS.
462 
463 ################################################################################
464 # Setup generation of the Java SE API documentation (javadoc + modulegraph)
465 
466 # The Java SE module scope is just java.se and its transitive indirect
467 # exports.
468 JAVASE_MODULES := java.se
469 
470 $(eval $(call SetupApiDocsGeneration, JAVASE_API, \
471     MODULES := $(JAVASE_MODULES), \
472     SHORT_NAME := $(JAVASE_SHORT_NAME), \
473     LONG_NAME := $(JAVASE_LONG_NAME), \
474     TARGET_DIR := $(DOCS_JAVASE_IMAGE_DIR)/api, \
475 ))
476 
477 # Targets generated are returned in JAVASE_API_JAVADOC_TARGETS and
478 # JAVASE_API_MODULEGRAPH_TARGETS.
479 
480 ################################################################################
481 # Setup generation of the reference Java SE API documentation (javadoc + modulegraph)
482 
483 # The reference javadoc is just the same as javase, but using the BootJDK javadoc
484 # and a stable set of javadoc options.  Typically it is used for generating
485 # diffs between the reference javadoc and a javadoc bundle of a specific build
486 # generated in the same way.
487 
488 $(eval $(call SetupApiDocsGeneration, REFERENCE_API, \
489     MODULES := $(JAVASE_MODULES), \
490     SHORT_NAME := $(JAVASE_SHORT_NAME), \
491     LONG_NAME := $(JAVASE_LONG_NAME), \
492     TARGET_DIR := $(DOCS_REFERENCE_IMAGE_DIR)/api, \
493     JAVADOC_CMD := $(DOCS_REFERENCE_JAVADOC), \
494     OPTIONS := $(REFERENCE_OPTIONS), \
495     TAGS := $(REFERENCE_TAGS), \
496 ))
497 
498 # Targets generated are returned in REFERENCE_API_JAVADOC_TARGETS and
499 # REFERENCE_API_MODULEGRAPH_TARGETS.
500 
501 ################################################################################
502 
503 # Use this variable to control which spec files are included in the output.
504 # Format: space-delimited list of names, including at most one '%' as a
505 # wildcard. Spec source files match if their filename or any enclosing folder
506 # name matches one of the items in SPEC_FILTER.
507 SPEC_FILTER := %
508 
509 ApplySpecFilter = \
510     $(strip $(foreach file, $(1), \
511         $(eval searchkeys := $(subst /, ,$(subst $(WORKSPACE_ROOT),,$(file)))) \
512         $(if $(filter $(SPEC_FILTER), $(searchkeys)), \
513             $(file) \
514         ) \
515     ))
516 
517 # Copy the global resources, including the top-level redirect index.html
518 GLOBAL_SPECS_RESOURCES_DIR := $(TOPDIR)/make/data/docs-resources
519 $(eval $(call SetupCopyFiles, COPY_GLOBAL_RESOURCES, \
520     SRC := $(GLOBAL_SPECS_RESOURCES_DIR), \
521     FILES := $(call ApplySpecFilter, $(call FindFiles, $(GLOBAL_SPECS_RESOURCES_DIR))), \
522     DEST := $(DOCS_OUTPUTDIR), \
523 ))
524 JDK_INDEX_TARGETS += $(COPY_GLOBAL_RESOURCES)
525 
526 # Copy the legal notices distributed with the docs bundle
527 $(eval $(call SetupCopyFiles, COPY_DOCS_LEGAL_NOTICES, \
528     SRC := $(TOPDIR)/src/jdk.javadoc/share/legal, \
529     FILES := $(call ApplySpecFilter, $(wildcard $(TOPDIR)/src/jdk.javadoc/share/legal/*)), \
530     DEST := $(DOCS_OUTPUTDIR)/legal, \
531 ))
532 JDK_INDEX_TARGETS += $(COPY_DOCS_LEGAL_NOTICES)
533 
534 ################################################################################
535 # Copy JDK specs files
536 
537 # For all non html/md files in $module/share/specs directories, copy them
538 # unmodified
539 
540 ALL_MODULES := $(call FindAllModules)
541 COPY_SPEC_FILTER := %.gif %.jpg %.mib %.css
542 
543 $(foreach m, $(ALL_MODULES), \
544   $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \
545   $(foreach d, $(SPECS_$m), \
546     $(if $(call ApplySpecFilter, $(filter $(COPY_SPEC_FILTER), $(call FindFiles, $d))), \
547       $(eval $(call SetupCopyFiles, COPY_$m, \
548           SRC := $d, \
549           FILES := $(call ApplySpecFilter, $(filter $(COPY_SPEC_FILTER), $(call FindFiles, $d))), \
550           DEST := $(DOCS_OUTPUTDIR)/specs/, \
551       )) \
552       $(eval JDK_SPECS_TARGETS += $(COPY_$m)) \
553     ) \
554   ) \
555 )
556 
557 # Create copyright footer variables. We need different variables for different
558 # relative paths to the copyright.html file. The number 0-2 below represent how
559 # many extra directory levels down below the specs dir the specs html file is
560 # located.
561 SPECS_BOTTOM = <footer class="legal-footer"><hr/>$(COPYRIGHT_BOTTOM)</footer>
562 # The legal dir is one ../ below the specs dir, so start with one ../.
563 specs_bottom_rel_path := ../
564 $(foreach n, 0 1 2, \
565   $(eval SPECS_BOTTOM_$n := $(call SPECS_BOTTOM,$(specs_bottom_rel_path))) \
566   $(eval specs_bottom_rel_path := $(specs_bottom_rel_path)../) \
567 )
568 
569 SPECS_TOP := $(if $(filter true, $(IS_DRAFT)), <header class="draft-header">$(DRAFT_TEXT)</header>)
570 
571 # For all html files in $module/share/specs directories, copy and add the
572 # copyright footer.
573 
574 $(foreach m, $(ALL_MODULES), \
575   $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \
576   $(foreach d, $(SPECS_$m), \
577     $(foreach f, $(call ApplySpecFilter, $(filter %.html, $(call FindFiles, $d))), \
578       $(eval $m_$f_NOF_SUBDIRS := $(words $(subst /, $(SPACE), $(subst $d, , $(dir $f))))) \
579       $(eval $m_$f_NAME := PROCESS_HTML_$m_$(strip $(call RelativePath, $f, $(TOPDIR)))) \
580       $(eval $(call SetupTextFileProcessing, $($m_$f_NAME), \
581           SOURCE_FILES := $f, \
582           SOURCE_BASE_DIR := $d, \
583           OUTPUT_DIR := $(DOCS_OUTPUTDIR)/specs/, \
584           REPLACEMENTS := \
585               <body> => <body>$(SPECS_TOP) ; \
586               </body> => $(SPECS_BOTTOM_$($m_$f_NOF_SUBDIRS))</body>, \
587       )) \
588       $(eval JDK_SPECS_TARGETS += $($($m_$f_NAME))) \
589     ) \
590   ) \
591 )
592 
593 ifeq ($(ENABLE_PANDOC), true)
594   # For all markdown files in $module/share/specs directories, convert them to
595   # html, if we have pandoc (otherwise we'll just skip this).
596 
597   GLOBAL_SPECS_DEFAULT_CSS_FILE := $(DOCS_OUTPUTDIR)/resources/jdk-default.css
598 
599   $(foreach m, $(ALL_MODULES), \
600     $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \
601     $(foreach d, $(SPECS_$m), \
602       $(foreach f, $(call ApplySpecFilter, $(filter %.md, $(call FindFiles, $d))), \
603         $(eval $m_$f_NOF_SUBDIRS := $(words $(subst /, $(SPACE), $(subst $d, , $(dir $f))))) \
604         $(eval $m_$f_NAME := SPECS_TO_HTML_$m_$(strip $(call RelativePath, $f, $(TOPDIR)))) \
605         $(eval $(call SetupProcessMarkdown, $($m_$f_NAME), \
606             SRC := $d, \
607             FILES := $f, \
608             DEST := $(DOCS_OUTPUTDIR)/specs/, \
609             CSS := $(GLOBAL_SPECS_DEFAULT_CSS_FILE), \
610             OPTIONS := -V include-before='$(SPECS_TOP)' -V include-after='$(SPECS_BOTTOM_$($m_$f_NOF_SUBDIRS))', \
611             REPLACEMENTS := \
612 		@@VERSION_SPECIFICATION@@ => $(VERSION_SPECIFICATION) ; \
613 		@@VERSION_STRING@@ => $(VERSION_STRING), \
614             POST_PROCESS := $(TOOL_FIXUPPANDOC), \
615         )) \
616         $(eval JDK_SPECS_TARGETS += $($($m_$f_NAME))) \
617       ) \
618     ) \
619   )
620 
621   # For all markdown files in $module/share/man directories, convert them to
622   # html.
623 
624   # Create dynamic man pages from markdown using pandoc. We need
625   # PANDOC_HTML_MANPAGE_FILTER, a wrapper around
626   # PANDOC_HTML_MANPAGE_FILTER_JAVASCRIPT. This is created by buildtools-jdk.
627 
628   # We should also depend on the source code for the filter
629   PANDOC_HTML_MANPAGE_FILTER_SOURCE := $(call FindFiles, \
630       $(TOPDIR)/make/jdk/src/classes/build/tools/pandocfilter)
631 
632   $(foreach m, $(ALL_MODULES), \
633     $(eval MAN_$m := $(call FindModuleManDirs, $m)) \
634     $(foreach d, $(MAN_$m), \
635       $(foreach f, $(call ApplySpecFilter, $(filter %.md, $(call FindFiles, $d))), \
636         $(eval $m_$f_NAME := MAN_TO_HTML_$m_$(strip $(call RelativePath, $f, $(TOPDIR)))) \
637         $(eval $(call SetupProcessMarkdown, $($m_$f_NAME), \
638             SRC := $d, \
639             FILES := $f, \
640             DEST := $(DOCS_OUTPUTDIR)/specs/man, \
641             FILTER := $(PANDOC_HTML_MANPAGE_FILTER), \
642             CSS := $(GLOBAL_SPECS_DEFAULT_CSS_FILE), \
643             REPLACEMENTS := \
644 		@@COPYRIGHT_YEAR@@ => $(COPYRIGHT_YEAR) ; \
645 		@@VERSION_SHORT@@ => $(VERSION_SHORT) ; \
646 		@@VERSION_SPECIFICATION@@ => $(VERSION_SPECIFICATION), \
647             OPTIONS := --toc -V include-before='$(SPECS_TOP)' -V include-after='$(SPECS_BOTTOM_1)', \
648             POST_PROCESS := $(TOOL_FIXUPPANDOC), \
649             EXTRA_DEPS := $(PANDOC_HTML_MANPAGE_FILTER) \
650                 $(PANDOC_HTML_MANPAGE_FILTER_SOURCE), \
651         )) \
652         $(eval JDK_SPECS_TARGETS += $($($m_$f_NAME))) \
653       ) \
654     ) \
655   )
656 
657   # The html generated from markdown also needs the css file
658   JDK_SPECS_TARGETS += $(COPY_GLOBAL_RESOURCES)
659 endif
660 
661 # Special treatment for generated documentation
662 
663 JDWP_PROTOCOL := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/jdwp-protocol.html
664 ifneq ($(call ApplySpecFilter, $(JDWP_PROTOCOL)), )
665   $(eval $(call SetupTextFileProcessing, PROCESS_JDWP_PROTOCOL, \
666       SOURCE_FILES := $(JDWP_PROTOCOL), \
667       OUTPUT_DIR := $(DOCS_OUTPUTDIR)/specs/jdwp, \
668       REPLACEMENTS := \
669           <body> => <body>$(SPECS_TOP) ; \
670           </body> => $(SPECS_BOTTOM_1)</body>, \
671   ))
672   JDK_SPECS_TARGETS += $(PROCESS_JDWP_PROTOCOL)
673 endif
674 
675 # Get jvmti.html from the main jvm variant (all variants' jvmti.html are identical).
676 JVMTI_HTML ?= $(HOTSPOT_OUTPUTDIR)/variant-$(JVM_VARIANT_MAIN)/gensrc/jvmtifiles/jvmti.html
677 ifneq ($(call ApplySpecFilter, $(JVMTI_HTML)), )
678   $(eval $(call SetupTextFileProcessing, PROCESS_JVMTI_HTML, \
679       SOURCE_FILES := $(JVMTI_HTML), \
680       OUTPUT_DIR := $(DOCS_OUTPUTDIR)/specs/, \
681       REPLACEMENTS := \
682           <body> => <body>$(SPECS_TOP) ; \
683           </body> => $(SPECS_BOTTOM_0)</body>, \
684   ))
685   JDK_SPECS_TARGETS += $(PROCESS_JVMTI_HTML)
686 endif
687 
688 ################################################################################
689 # Optional target which bundles all generated javadocs into a zip archive.
690 
691 JAVADOC_ZIP_NAME := jdk-$(VERSION_STRING)-docs.zip
692 JAVADOC_ZIP_FILE := $(OUTPUTDIR)/bundles/$(JAVADOC_ZIP_NAME)
693 
694 $(eval $(call SetupZipArchive, BUILD_JAVADOC_ZIP, \
695     SRC := $(DOCS_OUTPUTDIR), \
696     ZIP := $(JAVADOC_ZIP_FILE), \
697     EXTRA_DEPS := $(JDK_API_JAVADOC_TARGETS) $(JDK_API_MODULEGRAPH_TARGETS) \
698         $(JDK_SPECS_TARGETS), \
699 ))
700 
701 ZIP_TARGETS += $(BUILD_JAVADOC_ZIP)
702 
703 ################################################################################
704 # Hook to include the corresponding custom file, if present.
705 $(eval $(call IncludeCustomExtension, Docs-post.gmk))
706 
707 ################################################################################
708 # Bundles all generated specs into a zip archive, skipping javadocs.
709 
710 SPECS_ZIP_NAME := jdk-$(VERSION_STRING)-specs.zip
711 SPECS_ZIP_FILE := $(OUTPUTDIR)/bundles/$(SPECS_ZIP_NAME)
712 
713 $(eval $(call SetupZipArchive, BUILD_SPECS_ZIP, \
714     SRC := $(DOCS_OUTPUTDIR), \
715     ZIP := $(SPECS_ZIP_FILE), \
716     EXTRA_DEPS := $(JDK_SPECS_TARGETS), \
717 ))
718 
719 SPECS_ZIP_TARGETS += $(BUILD_SPECS_ZIP)
720 
721 ################################################################################
722 
723 docs-jdk-api-javadoc: $(JDK_API_JAVADOC_TARGETS) $(JDK_API_CUSTOM_TARGETS)
724 
725 docs-jdk-api-modulegraph: $(JDK_API_MODULEGRAPH_TARGETS)
726 
727 docs-javase-api-javadoc: $(JAVASE_API_JAVADOC_TARGETS) $(JAVASE_API_CUSTOM_TARGETS)
728 
729 docs-javase-api-modulegraph: $(JAVASE_API_MODULEGRAPH_TARGETS)
730 
731 docs-reference-api-javadoc: $(REFERENCE_API_JAVADOC_TARGETS) $(REFERENCE_API_CUSTOM_TARGETS)
732 
733 docs-reference-api-modulegraph: $(REFERENCE_API_MODULEGRAPH_TARGETS)
734 
735 docs-jdk-specs: $(JDK_SPECS_TARGETS)
736 
737 docs-jdk-index: $(JDK_INDEX_TARGETS)
738 
739 docs-zip: $(ZIP_TARGETS)
740 
741 docs-specs-zip: $(SPECS_ZIP_TARGETS)
742 
743 all: docs-jdk-api-javadoc docs-jdk-api-modulegraph docs-javase-api-javadoc \
744     docs-javase-api-modulegraph docs-reference-api-javadoc \
745     docs-reference-api-modulegraph docs-jdk-specs docs-jdk-index docs-zip \
746     docs-specs-zip
747 
748 .PHONY: default all docs-jdk-api-javadoc docs-jdk-api-modulegraph \
749     docs-javase-api-javadoc docs-javase-api-modulegraph \
750     docs-reference-api-javadoc docs-reference-api-modulegraph docs-jdk-specs \
751     docs-jdk-index docs-zip docs-specs-zip
--- EOF ---