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