db2f51d
--- jdk8/make/Javadoc.gmk	2016-04-01 16:53:41.069477682 +0200
db2f51d
+++ jdk8/make/Javadoc.gmk	2016-04-01 16:53:41.014477059 +0200
db2f51d
@@ -220,6 +220,12 @@
db2f51d
 JRE_API_DOCSDIR = $(DOCSDIR)/jre/api
db2f51d
 PLATFORM_DOCSDIR = $(DOCSDIR)/platform
db2f51d
 
db2f51d
+
db2f51d
+JAVADOC_ARCHIVE_NAME := jdk-$(FULL_VERSION)-docs.zip
db2f51d
+JAVADOC_ARCHIVE_ASSEMBLY_DIR :=  $(DOCSTMPDIR)/zip-docs
db2f51d
+JAVADOC_ARCHIVE_DIR := $(OUTPUT_ROOT)/bundles
db2f51d
+JAVADOC_ARCHIVE := $(JAVADOC_ARCHIVE_DIR)/$(JAVADOC_ARCHIVE_NAME)
db2f51d
+
db2f51d
 # The non-core api javadocs need to be able to access the root of the core
db2f51d
 # api directory, so for jdk/api or jre/api to get to the core api/
db2f51d
 # directory we would use this:
db2f51d
@@ -319,6 +325,37 @@
db2f51d
 all: docs
db2f51d
 docs: coredocs otherdocs
db2f51d
 
db2f51d
+#
db2f51d
+# Optional target which bundles all generated javadocs into a zip 
db2f51d
+# archive. The dependency on docs is handled in Main.gmk. Incremental 
db2f51d
+# building of docs is currently broken so if you invoke zip-docs after 
db2f51d
+# docs, the docs are always rebuilt.
db2f51d
+#
db2f51d
+
db2f51d
+zip-docs: $(JAVADOC_ARCHIVE)
db2f51d
+
db2f51d
+#
db2f51d
+# Add the core docs as prerequisite to the archive to trigger a rebuild
db2f51d
+# if the core docs were rebuilt. Ideally any doc rebuild should trigger
db2f51d
+# this, but the way prerequisites are currently setup in this file, that
db2f51d
+# is hard to achieve.
db2f51d
+#
db2f51d
+
db2f51d
+$(JAVADOC_ARCHIVE): $(COREAPI_INDEX_FILE)
db2f51d
+	@$(ECHO) "Compressing javadoc to single $(JAVADOC_ARCHIVE_NAME)" ; 
db2f51d
+	$(MKDIR) -p $(JAVADOC_ARCHIVE_DIR) ;
db2f51d
+	$(RM) -r $(JAVADOC_ARCHIVE_ASSEMBLY_DIR) ;
db2f51d
+	$(MKDIR) -p $(JAVADOC_ARCHIVE_ASSEMBLY_DIR);
db2f51d
+	all_roots=`$(FIND) $(DOCSDIR) | $(GREP) index.html `; \
db2f51d
+	pushd $(JAVADOC_ARCHIVE_ASSEMBLY_DIR); \
db2f51d
+	for index_file in $${all_roots} ; do \
db2f51d
+	  target_dir=`dirname $${index_file}`; \
db2f51d
+	  name=`$(ECHO) $${target_dir} | $(SED) "s;/spec;;" | $(SED) "s;.*/;;"`; \
db2f51d
+	  $(LN) -s $${target_dir}  $${name}; \
db2f51d
+	done; \
db2f51d
+	$(ZIP) -q -r $(JAVADOC_ARCHIVE) * ; \
db2f51d
+	popd ;
db2f51d
+
db2f51d
 #################################################################
db2f51d
 # Production Targets -- USE THESE TARGETS WHEN:
db2f51d
 # a) You're generating docs outside of release engineering's
db2f51d
--- jdk8/make/Main.gmk	2016-04-01 16:53:41.311480424 +0200
db2f51d
+++ jdk8/make/Main.gmk	2016-04-01 16:53:41.266479914 +0200
db2f51d
@@ -165,6 +165,12 @@
db2f51d
 	@($(CD) $(SRC_ROOT)/make && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs)
db2f51d
 	@$(call TargetExit)
db2f51d
 
db2f51d
+zip-docs: docs zip-docs-only
db2f51d
+zip-docs-only: start-make
db2f51d
+	@$(call TargetEnter)
db2f51d
+	@($(CD) $(SRC_ROOT)/make && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk zip-docs)
db2f51d
+	@$(call TargetExit)
db2f51d
+
db2f51d
 sign-jars: jdk sign-jars-only
db2f51d
 sign-jars-only: start-make
db2f51d
 	@$(call TargetEnter)