changeset 2573:0bf994fa4ee5

8176785: Add build support to generate PNG file from .dot file Reviewed-by: erikj, mchung
author ihse
date Wed, 19 Apr 2017 10:44:40 +0200
parents 566474d7b2e0
children e5c480ca7b29
files make/Help.gmk make/Javadoc.gmk make/Main.gmk make/common/Modules.gmk make/devkit/createGraphvizBundle.sh
diffstat 5 files changed, 292 insertions(+), 142 deletions(-) [+]
line wrap: on
line diff
--- a/make/Help.gmk	Wed Apr 19 10:24:42 2017 +0200
+++ b/make/Help.gmk	Wed Apr 19 10:44:40 2017 +0200
@@ -47,7 +47,7 @@
 	$(info $(_)                        # dependencies for the target. This is faster but may)
 	$(info $(_)                        # result in incorrect build results!)
 	$(info $(_) make docs              # Create all docs)
-	$(info $(_) make docs-javadoc      # Create just javadocs, depends on less than full docs)
+	$(info $(_) make docs-jdk-api      # Create just JDK javadocs)
 	$(info $(_) make profiles          # Create complete jre compact profile images)
 	$(info $(_) make bootcycle-images  # Build images twice, second time with newly built JDK)
 	$(info $(_) make install           # Install the generated images locally)
--- a/make/Javadoc.gmk	Wed Apr 19 10:24:42 2017 +0200
+++ b/make/Javadoc.gmk	Wed Apr 19 10:44:40 2017 +0200
@@ -37,12 +37,9 @@
 ################################################################################
 # Javadoc settings
 
-# All modules to have docs generated by docs-javadoc target
-JAVADOC_MODULES := $(sort $(DOCS_MODULES))
-
 # On top of the sources that was used to compile the JDK, we need some
 # extra java.rmi sources that are used just for javadoc.
-JAVADOC_SOURCE_PATH := $(call PathList, $(call GetModuleSrcPath) \
+MODULES_SOURCE_PATH := $(call PathList, $(call GetModuleSrcPath) \
     $(SUPPORT_OUTPUTDIR)/rmic/* $(JDK_TOPDIR)/src/*/share/doc/stub)
 
 # Should we use -Xdocrootparent? Allow custom to overwrite.
@@ -89,13 +86,6 @@
     -serialwarn -encoding ISO-8859-1 -breakiterator -splitIndex --system none \
     --expand-requires transitive
 
-#
-# TODO: this should be set by the configure option.
-#
-ifndef ENABLE_MODULE_GRAPH
-   ENABLE_MODULE_GRAPH=false
-endif
-
 # Should we add DRAFT stamps to the generated javadoc?
 ifeq ($(VERSION_IS_GA), true)
   IS_DRAFT := false
@@ -118,16 +108,9 @@
   endif
 endif
 
-
-################################################################################
-# JDK javadoc titles/text snippets
-
 JAVADOC_WINDOW_TITLE := Java Platform SE $(VERSION_SPECIFICATION) \
     $(DRAFT_MARKER_TITLE)
 
-JAVADOC_DOC_TITLE := Java™ Platform, Standard Edition Development Kit \
-    (JDK&trade;) $(VERSION_SPECIFICATION)<br>API Specification
-
 JAVADOC_HEADER_TITLE := $(subst $(SPACE),&nbsp;,$(strip \
     <strong>Java&trade; Platform<br>Standard Ed. \
     $(VERSION_SPECIFICATION)</strong>$(DRAFT_MARKER_STR)))
@@ -156,100 +139,208 @@
     purpose of evaluation.</div></div>
 
 ################################################################################
-# Java SE Reference javadoc titles/text snippets
+# JDK javadoc titles/text snippets
 
-REFERENCE_DOC_TITLE := Java&trade; Platform, Standard Edition \
+JDK_JAVADOC_DOC_TITLE := Java&trade; Platform, Standard Edition Development Kit \
+    (JDK&trade;) $(VERSION_SPECIFICATION)<br>API Specification
+
+################################################################################
+# Java SE javadoc titles/text snippets
+
+JAVASE_JAVADOC_DOC_TITLE := Java&trade; Platform, Standard Edition \
     $(VERSION_SPECIFICATION)<br>API Specification
 
 ################################################################################
-# Setup call to JDK javadoc based on above settings
+# Functions
 
-# Create a string like "-Xdoclint:all,-syntax,-html,..."
-JAVADOC_OPTIONS += -Xdoclint:all,$(call CommaList, $(addprefix -, \
-    $(JAVADOC_DISABLED_DOCLINT)))
+# Helper function for creating a png file from a dot file generated by the
+# GenGraphs tool.
+# param 1: SetupJavadocGeneration namespace ($1)
+# param 2: module name
+#
+define setup_gengraph_dot_to_png
+  $1_$2_DOT_SRC :=  $$($1_GENGRAPHS_DIR)/$2.dot
+  $1_$2_PNG_TARGET := $$($1_TARGET_DIR)/$2-graph.png
 
-ifneq ($($DOCROOTPARENT_FLAG), )
-  JAVADOC_OPTIONS += -Xdocrootparent $(JAVADOC_BASE_URL)
-endif
+    # For each module needing a graph, create a png file from the dot file
+    # generated by the GenGraphs tool and store it in the target dir.
+    $$($1_$2_PNG_TARGET): $$($1_GENGRAPHS_MARKER)
+	$$(call MakeDir, $$(@D))
+	$$(call ExecuteWithLog, $$($1_$2_DOT_SRC), \
+	    $$(DOT) -Tpng -o $$($1_$2_PNG_TARGET) $$($1_$2_DOT_SRC))
 
-JAVADOC_TITLE_OPTIONS += -doctitle '$(JAVADOC_DOC_TITLE)'
-JAVADOC_TITLE_OPTIONS += -windowtitle '$(JAVADOC_WINDOW_TITLE)'
-JAVADOC_TITLE_OPTIONS += -header '$(JAVADOC_HEADER_TITLE)'
-JAVADOC_TITLE_OPTIONS += -bottom '$(JAVADOC_BOTTOM)'
-ifeq ($(IS_DRAFT), true)
-  JAVADOC_TITLE_OPTIONS += -top '$(JAVADOC_TOP)'
-endif
-
-# Do not store debug level options in VARDEPS.
-ifneq ($(LOG_LEVEL), trace)
-  JAVADOC_LOG_OPTION += -quiet
-else
-  JAVADOC_LOG_OPTION += -verbose
-endif
-
-JAVADOC_VARDEPS := $(JAVADOC_OPTIONS) $(JAVADOC_TITLE_OPTIONS) $(JAVADOC_TAGS) \
-    $(JAVADOC_MODULES) $(JAVADOC_SOURCE_PATH)
-JAVADOC_VARDEPS_FILE := $(call DependOnVariable, JAVADOC_VARDEPS, \
-    $(SUPPORT_OUTPUTDIR)/docs/javadoc.vardeps)
-
-# Get a list of all files in all the source dirs for all included modules
-JAVADOC_SOURCE_DEPS := $(call CacheFind, $(wildcard \
-    $(foreach module, $(JAVADOC_MODULES), $(call FindModuleSrcDirs, $(module)))))
-
-JAVADOC_TARGET_DIR := $(JAVADOC_OUTPUTDIR)/api
-JAVADOC_OVERVIEW := $(JDK_TOPDIR)/src/java.base/share/classes/overview-core.html
-
-# Javadoc creates a lot of files but use index.html as a marker
-$(JAVADOC_TARGET_DIR)/index.html: $(BUILD_TOOLS_JDK) $(JAVADOC_VARDEPS_FILE) \
-    $(JAVADOC_SOURCE_DEPS) $(JAVADOC_OVERVIEW)
-	$(call LogWarn, Generating Javadoc for $(words $(JAVADOC_MODULES)) modules)
-	$(call LogInfo, Javadoc modules: $(JAVADOC_MODULES))
-	$(call MakeDir, $(JAVADOC_TARGET_DIR))
-	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/docs/javadoc, \
-	    $(JAVA) -Djava.awt.headless=true \
-	        -DenableModuleGraph=$(ENABLE_MODULE_GRAPH) \
-	        $(NEW_JAVADOC) -d $(JAVADOC_TARGET_DIR) \
-	        $(JAVADOC_TAGS) $(JAVADOC_OPTIONS) $(JAVADOC_LOG_OPTION) \
-	        $(JAVADOC_TITLE_OPTIONS) -overview $(JAVADOC_OVERVIEW) \
-	        --module-source-path $(JAVADOC_SOURCE_PATH) \
-	        --module $(call CommaList, $(JAVADOC_MODULES)))
-
-JAVADOC_TARGETS += $(JAVADOC_TARGET_DIR)/index.html
+  $1_MODULEGRAPH_TARGETS += $$($1_$2_PNG_TARGET)
+endef
 
 ################################################################################
-# Setup call to Java SE Reference javadoc based on above settings
+# Setup make rules for creating the API documentation, using javadoc and other
+# tools if needed.
+#
+# Parameter 1 is the name of the rule. This name is used as variable prefix.
+# Targets generated are returned as $1_JAVADOC_TARGETS and
+# $1_MODULEGRAPH_TARGETS. Note that the index.html file will work as a "touch
+# file" for all the magnitude of files that are generated by javadoc.
+#
+# Remaining parameters are named arguments. These include:
+#   MODULES - Modules to generate javadoc for
+#   NAME - The name of the javadoc compilation, to be presented to the user
+#   TARGET_DIR - Where to store the output
+#   OVERVIEW - Path to an html overview file
+#   DOC_TITLE - Title to use in -doctitle.
+#   WINDOW_TITLE - Title to use in -windowtitle.
+#   HEADER_TITLE - Title to use in -header.
+#   BOTTOM_TEXT - Text to use in -bottom.
+#   TOP_TEXT - Text to use in -top.
+#
+SetupApiDocsGeneration = $(NamedParamsMacroTemplate)
+define SetupApiDocsGenerationBody
 
-REFERENCE_TARGET_DIR := $(IMAGES_OUTPUTDIR)/javase-docs/api
-REFERENCE_OVERVIEW := $(JDK_TOPDIR)/src/java.base/share/classes/overview-core.html
+  # Figure out all modules, both specified and transitive, that will be processed
+  # by javadoc.
+  $1_TRANSITIVE_MODULES := $$(call FindTransitiveDepsForModules, $$($1_MODULES))
+  $1_ALL_MODULES := $$(sort $$($1_MODULES) $$($1_TRANSITIVE_MODULES))
 
-REFERENCE_TITLE_OPTIONS += -doctitle '$(REFERENCE_DOC_TITLE)'
-REFERENCE_TITLE_OPTIONS += -windowtitle '$(JAVADOC_WINDOW_TITLE)'
-REFERENCE_TITLE_OPTIONS += -header '$(JAVADOC_HEADER_TITLE)'
-REFERENCE_TITLE_OPTIONS += -bottom '$(JAVADOC_BOTTOM)'
-ifeq ($(IS_DRAFT), true)
-  REFERENCE_TITLE_OPTIONS += -top '$(JAVADOC_TOP)'
-endif
+  ifeq ($$(ENABLE_FULL_DOCS), true)
+    # Tell the ModuleGraph taglet to generate html links to soon-to-be-created
+    # png files with module graphs.
+    $1_JAVA_ARGS += -DenableModuleGraph=true
+  endif
 
-REFERENCE_VARDEPS := $(JAVADOC_OPTIONS) $(REFERENCE_TITLE_OPTIONS) $(JAVADOC_TAGS) \
-    $(JAVADOC_MODULES) $(JAVADOC_SOURCE_PATH)
-REFERENCE_VARDEPS_FILE := $(call DependOnVariable, REFERENCE_VARDEPS, \
-    $(SUPPORT_OUTPUTDIR)/docs/reference.vardeps)
+  # Always include tags and basic options
+  $1_OPTIONS := $$(JAVADOC_TAGS) $$(JAVADOC_OPTIONS)
 
-# Javadoc creates a lot of files but use index.html as a marker.
-$(REFERENCE_TARGET_DIR)/index.html: $(BUILD_TOOLS_JDK) $(REFERENCE_VARDEPS_FILE) \
-    $(JAVADOC_SOURCE_DEPS) $(REFERENCE_OVERVIEW)
-	$(call LogWarn, Generating reference Javadoc for Java SE)
-	$(call MakeDir, $(REFERENCE_TARGET_DIR))
-	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/docs/reference, \
-	    $(JAVA) -Djava.awt.headless=true \
-	        -DenableModuleGraph=$(ENABLE_MODULE_GRAPH) \
-	        $(NEW_JAVADOC) -d $(REFERENCE_TARGET_DIR) \
-	        $(JAVADOC_TAGS) $(JAVADOC_OPTIONS) $(JAVADOC_LOG_OPTION) \
-	        $(REFERENCE_TITLE_OPTIONS) -overview $(REFERENCE_OVERVIEW) \
-	        --module-source-path $(JAVADOC_SOURCE_PATH) \
-	        --module java.se.ee)
+  $1_OPTIONS += -overview $$($1_OVERVIEW)
+  $1_OPTIONS += --module-source-path $$(MODULES_SOURCE_PATH)
+  $1_OPTIONS += --module $$(call CommaList, $$($1_MODULES))
 
-REFERENCE_TARGETS += $(REFERENCE_TARGET_DIR)/index.html
+  # Create a string like "-Xdoclint:all,-syntax,-html,..."
+  $1_OPTIONS += -Xdoclint:all,$$(call CommaList, $$(addprefix -, \
+      $$(JAVADOC_DISABLED_DOCLINT)))
+
+  ifneq ($$($$DOCROOTPARENT_FLAG), )
+    $1_OPTIONS += -Xdocrootparent $$(JAVADOC_BASE_URL)
+  endif
+
+  $1_OPTIONS += -doctitle '$$($1_DOC_TITLE)'
+  $1_OPTIONS += -windowtitle '$$($1_WINDOW_TITLE)'
+  $1_OPTIONS += -header '$$($1_HEADER_TITLE)'
+  $1_OPTIONS += -bottom '$$($1_BOTTOM_TEXT)'
+  ifeq ($$(IS_DRAFT), true)
+    $1_OPTIONS += -top '$$($1_TOP_TEXT)'
+  endif
+
+  # Do not store debug level options in VARDEPS.
+  ifneq ($$(LOG_LEVEL), trace)
+    $1_LOG_OPTION += -quiet
+  else
+    $1_LOG_OPTION += -verbose
+  endif
+
+  $1_VARDEPS := $$($1_JAVA_ARGS) $$($1_OPTIONS) $$(MODULES_SOURCE_PATH) \
+      $$($1_ALL_MODULES)
+  $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
+      $$(SUPPORT_OUTPUTDIR)/docs/$1.vardeps)
+
+  # Get a list of all files in all the source dirs for all included modules
+  $1_SOURCE_DEPS := $$(call CacheFind, $$(wildcard $$(foreach module, \
+      $$($1_ALL_MODULES), $$(call FindModuleSrcDirs, $$(module)))))
+
+  # Javadoc creates a lot of files but use index.html as a marker
+  $$($1_TARGET_DIR)/index.html: $$(BUILD_TOOLS_JDK) $$($1_VARDEPS_FILE) \
+      $$($1_SOURCE_DEPS) $$($1_OVERVIEW)
+	$$(call LogWarn, Generating $$($1_NAME) API javadoc for \
+	    $$(words $$($1_ALL_MODULES)) modules)
+	$$(call LogInfo, Javadoc modules: $$($1_ALL_MODULES))
+	$$(call MakeDir, $$($1_TARGET_DIR))
+	$$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/docs/$1, \
+	    $$(JAVA) -Djava.awt.headless=true $$($1_JAVA_ARGS) \
+	        $$(NEW_JAVADOC) -d $$($1_TARGET_DIR) \
+	        $$(JAVADOC_TAGS) $$($1_OPTIONS) $$($1_LOG_OPTION))
+
+  $1_JAVADOC_TARGETS := $$($1_TARGET_DIR)/index.html
+
+  ifeq ($$(ENABLE_FULL_DOCS), true)
+    # We have asked ModuleGraph to generate links to png files. Now we must
+    # produce the png files.
+
+    # Locate which modules has the @moduleGraph tag in their module-info.java
+    $1_MODULES_NEEDING_GRAPH := $$(strip $$(foreach m, $$($1_ALL_MODULES), \
+      $$(if $$(shell $$(GREP) -e @moduleGraph \
+          $$(wildcard $$(addsuffix /module-info.java, \
+          $$(call FindModuleSrcDirs, $$m)))), \
+        $$m) \
+    ))
+
+    # First we run the GenGraph tool. It will query the module structure of the
+    # running JVM and output .dot files for all existing modules.
+    GENGRAPHS_PROPS := \
+        $$(JDK_TOPDIR)/make/src/classes/build/tools/jigsaw/javadoc-graphs.properties
+
+    $1_GENGRAPHS_DIR := $$(SUPPORT_OUTPUTDIR)/docs/$1-gengraphs
+    $1_GENGRAPHS_MARKER := $$($1_GENGRAPHS_DIR)/_gengraphs_run.marker
+
+    $$($1_GENGRAPHS_MARKER): $$(BUILD_JIGSAW_TOOLS) $$(GENGRAPHS_PROPS)
+	$$(call LogInfo, Running gengraphs for $$($1_NAME) API documentation)
+	$$(call MakeDir, $$($1_GENGRAPHS_DIR))
+	$$(call ExecuteWithLog, $$($1_GENGRAPHS_DIR)/gengraphs, \
+	    $$(TOOL_GENGRAPHS) --spec --output $$($1_GENGRAPHS_DIR) \
+	    --dot-attributes $$(GENGRAPHS_PROPS) && \
+	    $$(TOUCH) $$($1_GENGRAPHS_MARKER))
+
+    # For each module needing a graph, create a png file from the dot file
+    # generated by the GenGraphs tool and store it in the target dir.
+    # They will depend on $1_GENGRAPHS_MARKER, and will be added to $1.
+    $$(foreach m, $$($1_MODULES_NEEDING_GRAPH), \
+      $$(eval $$(call setup_gengraph_dot_to_png,$1,$$m)) \
+    )
+  endif
+endef
+
+################################################################################
+# Setup generation of the JDK API documentation (javadoc + modulegraph)
+
+# All modules to have docs generated by docs-jdk-api target
+JDK_JAVADOC_MODULES := $(sort $(DOCS_MODULES))
+
+JDK_JAVADOC_OVERVIEW := $(JDK_TOPDIR)/src/java.base/share/classes/overview-core.html
+
+$(eval $(call SetupApiDocsGeneration, JDK_API, \
+    MODULES := $(JDK_JAVADOC_MODULES), \
+    NAME := JDK, \
+    TARGET_DIR := $(JAVADOC_OUTPUTDIR)/api, \
+    OVERVIEW := $(JDK_JAVADOC_OVERVIEW), \
+    DOC_TITLE := $(JDK_JAVADOC_DOC_TITLE), \
+    WINDOW_TITLE := $(JAVADOC_WINDOW_TITLE), \
+    HEADER_TITLE := $(JAVADOC_HEADER_TITLE), \
+    BOTTOM_TEXT := $(JAVADOC_BOTTOM), \
+    TOP_TEXT := $(JAVADOC_TOP), \
+))
+
+# Targets generated are returned in JDK_API_JAVADOC_TARGETS and
+# JDK_API_MODULEGRAPH_TARGETS.
+
+################################################################################
+# Setup generation of the Java SE API documentation (javadoc + modulegraph)
+
+# The Java SE module scope is just java.se.ee and it's transitive modules.
+JAVASE_JAVADOC_MODULES := java.se.ee
+
+JAVASE_JAVADOC_OVERVIEW := $(JDK_TOPDIR)/src/java.base/share/classes/overview-core.html
+
+$(eval $(call SetupApiDocsGeneration, JAVASE_API, \
+    MODULES := $(JAVASE_JAVADOC_MODULES), \
+    NAME := Java SE, \
+    TARGET_DIR := $(IMAGES_OUTPUTDIR)/javase-docs/api, \
+    OVERVIEW := $(JAVASE_JAVADOC_OVERVIEW), \
+    DOC_TITLE := $(JAVASE_JAVADOC_DOC_TITLE), \
+    WINDOW_TITLE := $(JAVADOC_WINDOW_TITLE), \
+    HEADER_TITLE := $(JAVADOC_HEADER_TITLE), \
+    BOTTOM_TEXT := $(JAVADOC_BOTTOM), \
+    TOP_TEXT := $(JAVADOC_TOP), \
+))
+
+# Targets generated are returned in JAVASE_API_JAVADOC_TARGETS and
+# JAVASE_API_MODULEGRAPH_TARGETS.
 
 ################################################################################
 # Copy targets
@@ -283,42 +374,33 @@
 $(eval $(call SetupZipArchive, BUILD_JAVADOC_ZIP, \
   SRC := $(JAVADOC_OUTPUTDIR), \
   ZIP := $(JAVADOC_ZIP_FILE), \
-  EXTRA_DEPS := $(JAVADOC_TARGETS) $(COPY_TARGETS), \
+  EXTRA_DEPS := $(JDK_API_JAVADOC_TARGETS) $(JDK_API_MODULEGRAPH_TARGETS) \
+      $(COPY_TARGETS), \
 ))
 
 ZIP_TARGETS += $(BUILD_JAVADOC_ZIP)
 
 ################################################################################
-# generate .dot files for module graphs
-
-JAVADOC_MODULE_GRAPHS_DIR := $(SUPPORT_OUTPUTDIR)/docs/module-graphs
-JAVADOC_MODULE_GRAPHS := $(JAVADOC_MODULE_GRAPHS_DIR)/java.se.dot
-JAVADOC_MODULE_GRAPHS_PROPS := $(JDK_TOPDIR)/make/src/classes/build/tools/jigsaw/javadoc-graphs.properties
-
-$(JAVADOC_MODULE_GRAPHS): $(BUILD_JIGSAW_TOOLS) $(JAVADOC_MODULE_GRAPHS_PROPS)
-	$(MKDIR) -p $(@D)
-	$(TOOL_GENGRAPHS) --spec --output $(JAVADOC_MODULE_GRAPHS_DIR) \
-	    --dot-attributes $(JAVADOC_MODULE_GRAPHS_PROPS)
-
-MODULE_GRAPH_TARGETS += $(JAVADOC_MODULE_GRAPHS)
-
-################################################################################
 
 # Hook to include the corresponding custom file, if present.
 $(eval $(call IncludeCustomExtension, , Javadoc.gmk))
 
 ################################################################################
 
-docs-module-graphs: $(MODULE_GRAPH_TARGETS)
+docs-jdk-api-javadoc: $(JDK_API_JAVADOC_TARGETS)
 
-docs-javadoc: $(JAVADOC_TARGETS)
+docs-jdk-api-modulegraph: $(JDK_API_MODULEGRAPH_TARGETS)
 
-docs-reference: $(REFERENCE_TARGETS)
+docs-javase-api-javadoc: $(JAVASE_API_JAVADOC_TARGETS)
+
+docs-javase-api-modulegraph: $(JAVASE_API_MODULEGRAPH_TARGETS)
 
 docs-copy: $(COPY_TARGETS)
 
 docs-zip: $(ZIP_TARGETS)
 
-all: docs-module-graphs docs-javadoc docs-reference docs-copy docs-zip
+all: docs-jdk-api-javadoc docs-jdk-api-modulegraph docs-javase-api-javadoc \
+    docs-javase-api-modulegraph docs-copy docs-zip
 
-.PHONY: default all docs-module-graphs docs-javadoc docs-reference docs-copy docs-zip
+.PHONY: default all docs-jdk-api-javadoc docs-jdk-api-modulegraph \
+    docs-javase-api-javadoc docs-javase-api-modulegraph docs-copy docs-zip
--- a/make/Main.gmk	Wed Apr 19 10:24:42 2017 +0200
+++ b/make/Main.gmk	Wed Apr 19 10:44:40 2017 +0200
@@ -360,14 +360,19 @@
 ################################################################################
 # Docs targets
 
-docs-module-graphs:
-	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-module-graphs)
+# If building full docs, to complete docs-*-api we need both the javadoc and
+# modulegraph targets.
+docs-jdk-api-javadoc:
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-jdk-api-javadoc)
 
-docs-javadoc:
-	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-javadoc)
+docs-jdk-api-modulegraph:
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-jdk-api-modulegraph)
 
-docs-reference:
-	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-reference)
+docs-javase-api-javadoc:
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-javase-api-javadoc)
+
+docs-javase-api-modulegraph:
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-javase-api-modulegraph)
 
 docs-copy:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs-copy)
@@ -378,8 +383,9 @@
 update-build-docs:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f UpdateBuildDocs.gmk)
 
-ALL_TARGETS += docs-module-graphs docs-javadoc docs-reference docs-copy \
-    docs-zip update-build-docs
+ALL_TARGETS += docs-jdk-api-javadoc docs-jdk-api-modulegraph \
+    docs-javase-api-javadoc docs-javase-api-modulegraph docs-copy docs-zip \
+    update-build-docs
 
 ################################################################################
 # Cross compilation support
@@ -776,16 +782,18 @@
 
   bootcycle-images: jdk-image
 
-  docs-module-graphs: exploded-image buildtools-modules
+  docs-jdk-api-javadoc: $(GENSRC_TARGETS) rmic
 
-  docs-javadoc: $(GENSRC_TARGETS) rmic
+  docs-javase-api-javadoc: $(GENSRC_TARGETS) rmic
 
-  docs-reference: $(GENSRC_TARGETS) rmic
+  docs-jdk-api-modulegraph: exploded-image buildtools-modules
+
+  docs-javase-api-modulegraph: exploded-image buildtools-modules
 
   # The gensrc step for jdk.jdi creates an html file that is used by docs-copy.
   docs-copy: hotspot-$(JVM_VARIANT_MAIN)-gensrc jdk.jdi-gensrc
 
-  docs-zip: docs-javadoc docs-copy
+  docs-zip: docs-jdk docs-copy
 
   test: jdk-image test-image
 
@@ -904,6 +912,22 @@
 
 create-buildjdk: create-buildjdk-copy create-buildjdk-interim-image
 
+docs-jdk-api: docs-jdk-api-javadoc
+docs-javase-api: docs-javase-api-javadoc
+
+# If we're building full docs, we must also generate the module graphs to
+# get non-broken api documentation.
+ifeq ($(ENABLE_FULL_DOCS), true)
+  docs-jdk-api: docs-jdk-api-modulegraph
+  docs-javase-api: docs-javase-api-modulegraph
+endif
+
+docs-jdk: docs-jdk-api
+docs-javase: docs-javase-api
+
+# alias for backwards compatibility
+docs-javadoc: docs-jdk-api
+
 mac-bundles: mac-bundles-jdk
 
 # The $(BUILD_OUTPUT)/images directory contain the resulting deliverables,
@@ -935,7 +959,7 @@
 endif
 
 # This target builds the documentation image
-docs-image: docs-module-graphs docs-javadoc docs-copy
+docs-image: docs-jdk docs-copy
 
 # This target builds the test image
 test-image: prepare-test-image test-image-hotspot-jtreg-native \
@@ -951,7 +975,8 @@
     copy java rmic libs launchers jmods \
     jdk.jdwp.agent-gensrc $(ALL_MODULES) demos \
     exploded-image-base exploded-image \
-    create-buildjdk mac-bundles product-images \
+    create-buildjdk docs-jdk-api docs-javase-api docs-jdk docs-javase \
+    docs-javadoc mac-bundles product-images \
     profiles profiles-images \
     docs-image test-image all-images \
     all-bundles
--- a/make/common/Modules.gmk	Wed Apr 19 10:24:42 2017 +0200
+++ b/make/common/Modules.gmk	Wed Apr 19 10:44:40 2017 +0200
@@ -294,15 +294,15 @@
 	    ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
 	      $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
 	          BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
-	          /requires/ { sub(/;/, ""); \
-	                       sub(/requires/, ""); \
-	                       sub(/transitive/, ""); \
-	                       sub(/\/\/.*/, ""); \
-	                       sub(/\/\*.*\*\//, ""); \
-	                       gsub(/^ +\*.*/, ""); \
-	                       gsub(/ /, ""); \
-	                       printf(" %s", $$0) } \
-	          END        { printf("\n") }' $m \
+	          /^ *requires/ { sub(/;/, ""); \
+	                          sub(/requires/, ""); \
+	                          sub(/transitive/, ""); \
+	                          sub(/\/\/.*/, ""); \
+	                          sub(/\/\*.*\*\//, ""); \
+	                          gsub(/^ +\*.*/, ""); \
+	                          gsub(/ /, ""); \
+	                          printf(" %s", $$0) } \
+	          END           { printf("\n") }' $m \
 	    ) >> $@ $(NEWLINE))
 
 -include $(MODULE_DEPS_MAKEFILE)
@@ -320,6 +320,11 @@
             $(foreach n, $(call FindDepsForModule, $m), \
                  $(call FindDepsForModule, $n))))
 
+# Finds transitive dependencies in 3 levels for a set of modules.
+# Param 1: List of modules to find transitive deps for
+FindTransitiveDepsForModules = \
+    $(sort $(foreach m, $1, $(call FindTransitiveDepsForModule, $m)))
+
 # Upgradeable modules are those that are either defined as upgradeable or that
 # require an upradeable module.
 FindAllUpgradeableModules = \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/devkit/createGraphvizBundle.sh	Wed Apr 19 10:44:40 2017 +0200
@@ -0,0 +1,38 @@
+#!/bin/bash -e
+# Create a bundle in the current directory, containing what's needed to run
+# the 'dot' program from the graphviz suite by the OpenJDK build.
+
+TMPDIR=`mktemp -d -t graphvizbundle-XXXX`
+trap "rm -rf \"$TMPDIR\"" EXIT
+
+ORIG_DIR=`pwd`
+cd "$TMPDIR"
+GRAPHVIZ_VERSION=2.38.0-1
+PACKAGE_VERSION=1.1
+TARGET_PLATFORM=linux_x64
+BUNDLE_NAME=graphviz-$TARGET_PLATFORM-$GRAPHVIZ_VERSION+$PACKAGE_VERSION.tar.gz
+wget http://www.graphviz.org/pub/graphviz/stable/redhat/el6/x86_64/os/graphviz-$GRAPHVIZ_VERSION.el6.x86_64.rpm
+wget http://www.graphviz.org/pub/graphviz/stable/redhat/el6/x86_64/os/graphviz-libs-$GRAPHVIZ_VERSION.el6.x86_64.rpm
+wget http://www.graphviz.org/pub/graphviz/stable/redhat/el6/x86_64/os/graphviz-plugins-core-$GRAPHVIZ_VERSION.el6.x86_64.rpm
+wget http://www.graphviz.org/pub/graphviz/stable/redhat/el6/x86_64/os/graphviz-plugins-x-$GRAPHVIZ_VERSION.el6.x86_64.rpm
+
+mkdir graphviz
+cd graphviz
+for rpm in ../*.rpm; do
+  rpm2cpio $rpm | cpio --extract --make-directories
+done
+
+cat > dot << EOF
+#!/bin/bash
+# Get an absolute path to this script
+this_script_dir=\`dirname \$0\`
+this_script_dir=\`cd \$this_script_dir > /dev/null && pwd\`
+export LD_LIBRARY_PATH="\$this_script_dir/usr/lib64:\$LD_LIBRARY_PATH"
+exec \$this_script_dir/usr/bin/dot "\$@"
+EOF
+chmod +x dot
+export LD_LIBRARY_PATH="$TMPDIR/graphviz/usr/lib64:$LD_LIBRARY_PATH"
+# create config file
+./dot -c
+tar -cvzf ../$BUNDLE_NAME *
+cp ../$BUNDLE_NAME "$ORIG_DIR"