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