6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
authormchung
Mon, 18 Jan 2010 15:23:14 -0800
changeset 4681 7d382dfe6e55
parent 4680 925408ac04c2
child 4682 2aebbe5c08a7
6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH Summary: build modules not depending on ALT_JDK_IMPORT_PATH being set Reviewed-by: alanb
jdk/make/common/Defs.gmk
jdk/make/common/Modules.gmk
jdk/make/modules/Makefile
jdk/make/modules/optional.depconfig
jdk/make/modules/tools/Makefile
--- a/jdk/make/common/Defs.gmk	Mon Jan 18 17:53:26 2010 +0100
+++ b/jdk/make/common/Defs.gmk	Mon Jan 18 15:23:14 2010 -0800
@@ -307,6 +307,9 @@
 # for generated class files
 CLASSBINDIR         = $(OUTPUTDIR)/classes
 DEMOCLASSDIR        = $(OUTPUTDIR)/democlasses
+# for modules
+MODULES_DIR         = $(OUTPUTDIR)/modules
+ABS_MODULES_DIR     = $(ABS_OUTPUTDIR)/modules
 # for generated tool class files
 BUILDTOOLCLASSDIR   = $(OUTPUTDIR)/btclasses
 # for build tool jar files
@@ -385,10 +388,18 @@
 #
 # Build units may or may not define MODULE.  Default to "other".
 #
+# MODULE variable defines the lowest-level module name that
+# might or might not be the name of the modules created in
+# the modules build (see make/modules/modules.config and
+# modules.group).
+#
+MODULES_TEMPDIR     = $(OUTPUTDIR)/tmp/modules
+ABS_MODULES_TEMPDIR = $(ABS_OUTPUTDIR)/tmp/modules
+
 ifndef MODULE
   MODULE = other
 endif
-override MODULE_DEST_DIR = $(OUTPUTDIR)/tmp/modules/$(MODULE)
+override MODULE_DEST_DIR = $(MODULES_TEMPDIR)/$(MODULE)
 
 # the use of += above makes a space separated list which we need to 
 # remove for filespecs.
@@ -516,7 +527,7 @@
 define install-module-file
 dest=`echo $(@D)/ | $(SED) $(MODULE_PATH_PATTERN)` ; \
 $(MKDIR) -p $(MODULE_DEST_DIR)/$$dest; \
-$(CP) $@ $(MODULE_DEST_DIR)/$$dest
+$(CP) -f $@ $(MODULE_DEST_DIR)/$$dest
 endef
 
 # Install all files from the directory to its module
@@ -535,7 +546,7 @@
 # install a sym link in its module
 define install-module-sym-link
 dest=`echo $@ | $(SED) $(MODULE_PATH_PATTERN)` ; \
-$(LN) -s $1 $(MODULE_DEST_DIR)/$$dest
+$(LN) -sf $1 $(MODULE_DEST_DIR)/$$dest
 endef
 
 
--- a/jdk/make/common/Modules.gmk	Mon Jan 18 17:53:26 2010 +0100
+++ b/jdk/make/common/Modules.gmk	Mon Jan 18 15:23:14 2010 -0800
@@ -121,8 +121,6 @@
 # JRE Image
 ######################################################
 
-MODULES_TEMPDIR=$(ABS_TEMPDIR)/modules
-MODULES_LIB = $(ABS_OUTPUTDIR)/modules
 MODULES_LIST = $(MODULES_TEMPDIR)/classlist/modules.list
 
 # Modules in the jre/lib/security directory
@@ -188,7 +186,7 @@
 	@# copy modules to jre/lib
 	@#
 	for m in `$(NAWK) '{print $$1}' $(MODULES_LIST)` ; do \
-	    $(CP) $(MODULES_LIB)/$$m/lib/$$m.jar $(JRE_MODULE_IMAGE_DIR)/lib ; \
+	    $(CP) $(MODULES_DIR)/$$m/lib/$$m.jar $(JRE_MODULE_IMAGE_DIR)/lib ; \
 	done
 	$(MKDIR) -p $(JRE_MODULE_IMAGE_DIR)/lib/ext
 	for m in $(EXT_MODULES) ; do \
@@ -344,7 +342,7 @@
 	@#
 	$(MKDIR) -p $(JDK_MODULE_IMAGE_DIR)/lib
 	for m in $(JDK_MODULES) ; do \
-	    $(CP) $(MODULES_LIB)/$$m/lib/$$m.jar $(JDK_MODULE_IMAGE_DIR)/lib ; \
+	    $(CP) $(MODULES_DIR)/$$m/lib/$$m.jar $(JDK_MODULE_IMAGE_DIR)/lib ; \
         done
   ifeq ($(PLATFORM), windows)
 	@#
--- a/jdk/make/modules/Makefile	Mon Jan 18 17:53:26 2010 +0100
+++ b/jdk/make/modules/Makefile	Mon Jan 18 15:23:14 2010 -0800
@@ -23,65 +23,83 @@
 # have any questions.
 #
 
-#
-# Modularizing the JDK
-#
-
 BUILDDIR = ..
 include $(BUILDDIR)/common/Defs.gmk
 
-CLASSANALYZER_JAR=$(BUILDTOOLJARDIR)/classanalyzer.jar
-JAVA_FLAGS=$(JAVA_TOOLS_FLAGS) -Xbootclasspath:$(CLASSBINDIR)
+#
+# Modularizing the JDK
+# - Post jdk build process until the source tree is restructured
+#   for modules build
+# - <outputdir>/modules/<module> will be created for each module.
+#
+# Steps:
+# 0. During jdk build before this makefile is invoked, classes, 
+#    resource files, and other non-class files such as native libraries,
+#    properties file, images, etc are created.
+#
+#    Non-class files are copied to <outputdir>/tmp/modules/<MODULE>
+#    directory in this step to prepare for the post-build modularization. 
+#
+#    The MODULE variable defined in other makefiles specifies 
+#    the lowest-level module that the non-class files belong to.
+#    The name might or might not be the same as the name of the modules 
+#    in the resulting <outputdir>/modules directory.
+#    
+# 1. Unpack all jars in the <builddir>/lib directory to a temporary 
+#    location (<outputdir>/tmp/modules/classes) to prepare for modules
+#    creation.
+#
+# 2. Run ClassAnalyzer tool to analyze all jdk classes and generate
+#    class list for all modules and also perform dependency analysis. 
+#
+#    Input configuration files :-
+#
+#    modules.config : defines the low-level modules and specifies 
+#       what classes and resource files each module includes.
+#    modules.group  : defines the module groups and its members.
+#    jdk7.depconfig : lists the dynamic dependencies including
+#       use of reflection Class.forName and JNI FindClass and
+#       service provider.
+#    optional.depconfig : lists the optional dependencies
+#
+# 3. Create one directory for each module (<outputdir>/modules/<module>)
+#    based on the output files from (2).
+#       
+#    modules.list lists the modules to be created for the modules
+#    build and its members. For each module (m) in modules.list,
+#    a. create $m/lib/$m.jar with all classes and resource files
+#       listed in $m.classlist and $m.resources respectively.
+#    b. copy all non-class files from its members to 
+#       <outputdir>/modules/$m.
 
-MODULE_LIB = $(ABS_OUTPUTDIR)/modules
+
 MAINMANIFEST=$(JDK_TOPDIR)/make/tools/manifest.mf
 MODULE_JAR_MANIFEST_FILE=$(ABS_TEMPDIR)/manifest.tmp
 
-TMP=$(ABS_TEMPDIR)/modules
-MODULE_CLASSLIST = $(TMP)/classlist
-MODULE_CLASSES = $(TMP)/classes
+TMP = $(ABS_MODULES_TEMPDIR)
+MODULE_CLASSLIST = $(ABS_MODULES_TEMPDIR)/classlist
+MODULE_CLASSES = $(ABS_MODULES_TEMPDIR)/classes
 MODULES_LIST = $(MODULE_CLASSLIST)/modules.list
 
-SUBDIRS = tools
-all build clean clobber::
-	$(SUBDIRS-loop)
-
 all:: unpack-jars gen-classlist modularize
 
-$(CLASSANALYZER_JAR):
-	$(CD) tools && $(MAKE) all
-
 JAR_LIST := $(shell $(FIND) $(ABS_OUTPUTDIR)/lib -name \*.jar -print) 
 unpack-jars:
+	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
 	$(RM) -rf $(MODULE_CLASSES)
 	$(MKDIR) -p $(MODULE_CLASSES)
 	$(CP) -rf $(CLASSBINDIR)/* $(MODULE_CLASSES)
-	for jf in  $(JAR_LIST) ; do \
+	@for jf in  $(JAR_LIST) ; do \
 	   $(CD) $(MODULE_CLASSES) && $(BOOT_JAR_CMD) xf $$jf $(BOOT_JAR_JFLAGS);\
 	done
-
-gen-classlist: $(CLASSANALYZER_JAR)
-	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
-	@$(RM) -rf $(MODULE_CLASSLIST)
-	@$(MKDIR) -p $(MODULE_CLASSLIST)
+	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
 
-	@# Use java in the default tool directory.
-	@# OUTPUTDIR for solaris 64-bit doesn't have the tools.
-	$(JAVA_TOOLS_DIR)/java $(JAVA_FLAGS) \
-		-Dclassanalyzer.debug \
-		-jar $(CLASSANALYZER_JAR) \
-		-jdkhome $(OUTPUTDIR) \
-	        -config modules.config \
-	        -config modules.group \
-		-depconfig jdk7.depconfig \
-		-depconfig optional.depconfig \
-		-showdynamic \
-		-output $(MODULE_CLASSLIST)
-	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
+gen-classlist:
+	$(CD) tools && $(MAKE) all
 
 modularize: $(MODULE_JAR_MANIFEST_FILE)
 	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
-	@$(RM) -rf $(MODULE_LIB)
+	@$(RM) -rf $(MODULES_DIR)
 
 	@# create jar file for modules and
 	@# copy other files from all members of this module 
@@ -91,16 +109,16 @@
 	   if [ -f $(MODULE_CLASSLIST)/$$m.resources ] ; then \
    	       $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.resources >> $(TMP)/tmp.cf ; \
            fi ; \
-           $(MKDIR) -p $(MODULE_LIB)/$$m/lib; \
+           $(MKDIR) -p $(ABS_MODULES_DIR)/$$m/lib; \
 	   $(CD) $(MODULE_CLASSES) && \
                $(BOOT_JAR_CMD) c0mf $(MODULE_JAR_MANIFEST_FILE) \
-		   $(MODULE_LIB)/$$m/lib/$$m.jar \
+		   $(ABS_MODULES_DIR)/$$m/lib/$$m.jar \
 	           @$(TMP)/tmp.cf \
                    $(BOOT_JAR_JFLAGS); \
 	   for s in `$(GREP) "^$$m" $(MODULES_LIST)` ; do \
                if [ -d $(TMP)/$$s ] ; then \
-               	   $(CP) -rf $(TMP)/$$s/*  $(MODULE_LIB)/$$m; \
-		   $(RM) -rf $(MODULE_LIB)/$$m/classes; \
+               	   $(CP) -rf $(TMP)/$$s/*  $(ABS_MODULES_DIR)/$$m; \
+		   $(RM) -rf $(ABS_MODULES_DIR)/$$m/classes; \
 	       fi \
 	   done \
         done
@@ -112,6 +130,5 @@
 
 clean clobber::
 	$(RM) -rf $(MODULE_CLASSLIST)
-	$(RM) -rf $(MODULE_LIB)
+	$(RM) -rf $(MODULES_DIR)
 	$(RM) $(MODULE_JAR_MANIFEST_FILE)
-	$(RM) $(CLASSANALYZER_JAR)
--- a/jdk/make/modules/optional.depconfig	Mon Jan 18 17:53:26 2010 +0100
+++ b/jdk/make/modules/optional.depconfig	Mon Jan 18 15:23:14 2010 -0800
@@ -1,3 +1,28 @@
+#
+# Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
 # public final java.nio.channels.SocketChannel getChannel()
 @Optional
   sun.security.ssl.BaseSSLSocketImpl -> java.nio.channels.SocketChannel
--- a/jdk/make/modules/tools/Makefile	Mon Jan 18 17:53:26 2010 +0100
+++ b/jdk/make/modules/tools/Makefile	Mon Jan 18 15:23:14 2010 -0800
@@ -28,58 +28,128 @@
 #
 
 BUILDDIR = ../..
-PACKAGE = com.sun.classanalyzer
-PRODUCT = tools
-PROGRAM = classanalyzer
 include $(BUILDDIR)/common/Defs.gmk
 
+PKGDIR = com/sun/classanalyzer
 BUILDTOOL_SOURCE_ROOT = src
 BUILDTOOL_MAIN        = $(PKGDIR)/ClassAnalyzer.java
 BUILTTOOL_MAINCLASS   = $(subst /,.,$(BUILDTOOL_MAIN:%.java=%))
 
 BUILDTOOL_MAIN_SOURCE_FILE = $(BUILDTOOL_SOURCE_ROOT)/$(BUILDTOOL_MAIN)
-BUILDTOOL_MANIFEST_FILE    = $(BUILDTOOLCLASSDIR)/$(PROGRAM)_manifest.mf
-BUILDTOOL_JAR_FILE         = $(BUILDTOOLJARDIR)/$(PROGRAM).jar
+BUILDTOOL_MANIFEST_FILE    = $(BUILDTOOLCLASSDIR)/classanalyzer_manifest.mf
 
 FILES_java := $(shell $(CD) $(BUILDTOOL_SOURCE_ROOT) \
-    && $(FIND) $(PKGDIR) $(SCM_DIRS_prune) -o -type f -print)
+    && $(FIND) $(PKGDIR) -type f -print)
+
 FILES_class = $(FILES_java:%.java=$(BUILDTOOLCLASSDIR)/%.class)
 
-all build: $(BUILDTOOL_JAR_FILE) tool_info
+CLASSANALYZER_JAR_FILE     = $(BUILDTOOLJARDIR)/classanalyzer.jar
+
+#
+# ClassAnalyzer depends on the com.sun.tools.classfile API.
+# The tool is compiled with the latest version of the classfile 
+# library in the langtools repo to make sure that synchronized
+# change is made if the classfile API is changed. 
+#
+# If langtools repo exists, build its own copy of the
+# classfile library and use it for compile time and runtime.
+# If not exist (the top level repo is not a forest), use 
+# the built jdk tools that imports tools.jar from the latest
+# promoted build.
+#
+# If the classfile API is changed but not yet in a promoted build,
+# the build might fail and the tool would need the langtools repo
+# to build in that case.
+#
+ifndef LANGTOOLS_TOPDIR
+  LANGTOOLS_TOPDIR=$(JDK_TOPDIR)/../langtools
+endif
+
+LANGTOOLS_TOPDIR_EXISTS := $(shell \
+  if [ -d $(LANGTOOLS_TOPDIR) ] ; then \
+    echo true; \
+  else \
+    echo false; \
+  fi)
+
+CLASSFILE_SRC = $(LANGTOOLS_TOPDIR)/src/share/classes
+CLASSFILE_PKGDIR = com/sun/tools/classfile
+
+ifeq ($(LANGTOOLS_TOPDIR_EXISTS), true)
+  FILES_classfile_java := $(shell \
+       $(CD) $(CLASSFILE_SRC) && \
+           $(FIND) $(CLASSFILE_PKGDIR) -name '*.java' -print)
+  FILES_classfile_class = $(FILES_classfile_java:%.java=$(BUILDTOOLCLASSDIR)/%.class)
+  CLASSFILE_JAR_FILE = $(BUILDTOOLJARDIR)/classfile.jar
+  BUILDTOOL_JAVAC    = $(BOOT_JAVAC_CMD) $(JAVAC_JVM_FLAGS) \
+                          $(BOOT_JAVACFLAGS) -classpath $(CLASSFILE_JAR_FILE)
+  BUILDTOOL_JAVA     = $(BOOT_JAVA_CMD) $(JAVA_TOOLS_FLAGS) \
+                          -Xbootclasspath/p:$(CLASSFILE_JAR_FILE)
+else
+  # if langtools doesn't exist, use tools from the built jdk
+  BUILDTOOL_JAVAC = $(BINDIR)/javac $(JAVAC_JVM_FLAGS) \
+                       $(BOOT_JAVACFLAGS)
+  BUILDTOOL_JAVA  = $(BINDIR)/java $(JAVA_TOOLS_FLAGS)
+endif
+
+# Location of the output modules.list, <module>.classlist
+# and other output files generated by the class analyzer tool.
+#
+MODULE_CLASSLIST = $(MODULES_TEMPDIR)/classlist
+
+all build: classanalyzer gen-classlist
+
+classanalyzer: $(CLASSFILE_JAR_FILE) $(CLASSANALYZER_JAR_FILE) 
+
+gen-classlist:
+	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
+	@$(RM) -rf $(MODULE_CLASSLIST)
+	@$(MKDIR) -p $(MODULE_CLASSLIST)
+	$(BUILDTOOL_JAVA) \
+                -Dclassanalyzer.debug \
+                -jar $(CLASSANALYZER_JAR_FILE) \
+                -jdkhome $(OUTPUTDIR) \
+                -config ../modules.config \
+                -config ../modules.group \
+                -depconfig ../jdk7.depconfig \
+                -depconfig ../optional.depconfig \
+                -showdynamic \
+                -output $(MODULE_CLASSLIST)
+	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
 
 $(BUILDTOOL_MANIFEST_FILE): $(BUILDTOOL_MAIN_SOURCE_FILE)
 	@$(prep-target)
 	$(ECHO) "Main-Class: $(BUILTTOOL_MAINCLASS)" > $@
 
+$(BUILDTOOLCLASSDIR)/$(CLASSFILE_PKGDIR)/%.class : $(CLASSFILE_SRC)/$(CLASSFILE_PKGDIR)/%.java
+	@$(prep-target)
+	@$(BUILDTOOL_JAVAC) \
+            -sourcepath $(CLASSFILE_SRC) \
+            -d $(BUILDTOOLCLASSDIR) $<
+
 $(BUILDTOOLCLASSDIR)/%.class : $(BUILDTOOL_SOURCE_ROOT)/%.java
 	@$(prep-target)
-	$(JAVAC_CMD) \
+	$(BUILDTOOL_JAVAC) \
             -sourcepath $(BUILDTOOL_SOURCE_ROOT) \
             -d $(BUILDTOOLCLASSDIR) $<
 
-$(BUILDTOOL_JAR_FILE): $(BUILDTOOL_MANIFEST_FILE) $(FILES_class)
+$(CLASSANALYZER_JAR_FILE): $(BUILDTOOL_MANIFEST_FILE) $(FILES_class)
 	@$(prep-target)
-	$(BOOT_JAR_CMD) cfm $@ $(BUILDTOOL_MANIFEST_FILE) \
-	    -C $(BUILDTOOLCLASSDIR) $(PKGDIR) \
-	    $(BOOT_JAR_JFLAGS) || $(RM) $@
-	$(java-vm-cleanup)
+	$(CD) $(BUILDTOOLCLASSDIR) && \
+	    $(BOOT_JAR_CMD) cfm $@ $(BUILDTOOL_MANIFEST_FILE) \
+	       $(PKGDIR) $(BOOT_JAR_JFLAGS) || $(RM) $@
+	@$(java-vm-cleanup)
 
-# Printing out a build tool information line
-define printBuildToolSetting
-if [ "$2" != "" ] ; then $(PRINTF) "%-25s %s\n" "$1:" "$2"; fi
-endef
-
-# Print out the build tool information
-tool_info:
-	@$(ECHO) "========================================================="
-	@$(call printBuildToolSetting,BUILDTOOL,$(PROGRAM))
-	@$(call printBuildToolSetting,PACKAGE,$(PACKAGE))
-	@$(call printBuildToolSetting,BUILDTOOL_SOURCE_ROOT,$(BUILDTOOL_SOURCE_ROOT))
-	@$(call printBuildToolSetting,BUILTTOOL_MAINCLASS,$(BUILTTOOL_MAINCLASS))
-	@$(call printBuildToolSetting,BUILDTOOL_JAR_FILE,$(BUILDTOOL_JAR_FILE))
-	@$(ECHO) "========================================================="
+$(BUILDTOOLJARDIR)/classfile.jar: $(FILES_classfile_class)
+	@$(prep-target)
+	$(CD) $(BUILDTOOLCLASSDIR) && \
+	    $(BOOT_JAR_CMD) cf $@ \
+	        $(CLASSFILE_PKGDIR) $(BOOT_JAR_JFLAGS) || $(RM) $@
+	@$(java-vm-cleanup)
 
 clean clobber::
 	@$(RM) -rf $(BUILDTOOLCLASSDIR)/$(PKGDIR)
+	@$(RM) -rf $(BUILDTOOLCLASSDIR)/$(CLASSFILE_PKGDIR)
 	@$(RM) $(BUILDTOOL_MANIFEST_FILE)
-	@$(RM) $(BUILDTOOL_JAR_FILE)
+	@$(RM) $(CLASSANALYZER_JAR_FILE)
+	@$(RM) $(CLASSFILE_JAR_FILE)