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