jdk/make/modules/Makefile
changeset 4681 7d382dfe6e55
parent 4665 d14dc3d9e1fa
child 5506 202f599c92aa
equal deleted inserted replaced
4680:925408ac04c2 4681:7d382dfe6e55
    21 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    21 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    22 # CA 95054 USA or visit www.sun.com if you need additional information or
    22 # CA 95054 USA or visit www.sun.com if you need additional information or
    23 # have any questions.
    23 # have any questions.
    24 #
    24 #
    25 
    25 
    26 #
       
    27 # Modularizing the JDK
       
    28 #
       
    29 
       
    30 BUILDDIR = ..
    26 BUILDDIR = ..
    31 include $(BUILDDIR)/common/Defs.gmk
    27 include $(BUILDDIR)/common/Defs.gmk
    32 
    28 
    33 CLASSANALYZER_JAR=$(BUILDTOOLJARDIR)/classanalyzer.jar
    29 #
    34 JAVA_FLAGS=$(JAVA_TOOLS_FLAGS) -Xbootclasspath:$(CLASSBINDIR)
    30 # Modularizing the JDK
       
    31 # - Post jdk build process until the source tree is restructured
       
    32 #   for modules build
       
    33 # - <outputdir>/modules/<module> will be created for each module.
       
    34 #
       
    35 # Steps:
       
    36 # 0. During jdk build before this makefile is invoked, classes, 
       
    37 #    resource files, and other non-class files such as native libraries,
       
    38 #    properties file, images, etc are created.
       
    39 #
       
    40 #    Non-class files are copied to <outputdir>/tmp/modules/<MODULE>
       
    41 #    directory in this step to prepare for the post-build modularization. 
       
    42 #
       
    43 #    The MODULE variable defined in other makefiles specifies 
       
    44 #    the lowest-level module that the non-class files belong to.
       
    45 #    The name might or might not be the same as the name of the modules 
       
    46 #    in the resulting <outputdir>/modules directory.
       
    47 #    
       
    48 # 1. Unpack all jars in the <builddir>/lib directory to a temporary 
       
    49 #    location (<outputdir>/tmp/modules/classes) to prepare for modules
       
    50 #    creation.
       
    51 #
       
    52 # 2. Run ClassAnalyzer tool to analyze all jdk classes and generate
       
    53 #    class list for all modules and also perform dependency analysis. 
       
    54 #
       
    55 #    Input configuration files :-
       
    56 #
       
    57 #    modules.config : defines the low-level modules and specifies 
       
    58 #       what classes and resource files each module includes.
       
    59 #    modules.group  : defines the module groups and its members.
       
    60 #    jdk7.depconfig : lists the dynamic dependencies including
       
    61 #       use of reflection Class.forName and JNI FindClass and
       
    62 #       service provider.
       
    63 #    optional.depconfig : lists the optional dependencies
       
    64 #
       
    65 # 3. Create one directory for each module (<outputdir>/modules/<module>)
       
    66 #    based on the output files from (2).
       
    67 #       
       
    68 #    modules.list lists the modules to be created for the modules
       
    69 #    build and its members. For each module (m) in modules.list,
       
    70 #    a. create $m/lib/$m.jar with all classes and resource files
       
    71 #       listed in $m.classlist and $m.resources respectively.
       
    72 #    b. copy all non-class files from its members to 
       
    73 #       <outputdir>/modules/$m.
    35 
    74 
    36 MODULE_LIB = $(ABS_OUTPUTDIR)/modules
    75 
    37 MAINMANIFEST=$(JDK_TOPDIR)/make/tools/manifest.mf
    76 MAINMANIFEST=$(JDK_TOPDIR)/make/tools/manifest.mf
    38 MODULE_JAR_MANIFEST_FILE=$(ABS_TEMPDIR)/manifest.tmp
    77 MODULE_JAR_MANIFEST_FILE=$(ABS_TEMPDIR)/manifest.tmp
    39 
    78 
    40 TMP=$(ABS_TEMPDIR)/modules
    79 TMP = $(ABS_MODULES_TEMPDIR)
    41 MODULE_CLASSLIST = $(TMP)/classlist
    80 MODULE_CLASSLIST = $(ABS_MODULES_TEMPDIR)/classlist
    42 MODULE_CLASSES = $(TMP)/classes
    81 MODULE_CLASSES = $(ABS_MODULES_TEMPDIR)/classes
    43 MODULES_LIST = $(MODULE_CLASSLIST)/modules.list
    82 MODULES_LIST = $(MODULE_CLASSLIST)/modules.list
    44 
       
    45 SUBDIRS = tools
       
    46 all build clean clobber::
       
    47 	$(SUBDIRS-loop)
       
    48 
    83 
    49 all:: unpack-jars gen-classlist modularize
    84 all:: unpack-jars gen-classlist modularize
    50 
    85 
    51 $(CLASSANALYZER_JAR):
       
    52 	$(CD) tools && $(MAKE) all
       
    53 
       
    54 JAR_LIST := $(shell $(FIND) $(ABS_OUTPUTDIR)/lib -name \*.jar -print) 
    86 JAR_LIST := $(shell $(FIND) $(ABS_OUTPUTDIR)/lib -name \*.jar -print) 
    55 unpack-jars:
    87 unpack-jars:
       
    88 	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
    56 	$(RM) -rf $(MODULE_CLASSES)
    89 	$(RM) -rf $(MODULE_CLASSES)
    57 	$(MKDIR) -p $(MODULE_CLASSES)
    90 	$(MKDIR) -p $(MODULE_CLASSES)
    58 	$(CP) -rf $(CLASSBINDIR)/* $(MODULE_CLASSES)
    91 	$(CP) -rf $(CLASSBINDIR)/* $(MODULE_CLASSES)
    59 	for jf in  $(JAR_LIST) ; do \
    92 	@for jf in  $(JAR_LIST) ; do \
    60 	   $(CD) $(MODULE_CLASSES) && $(BOOT_JAR_CMD) xf $$jf $(BOOT_JAR_JFLAGS);\
    93 	   $(CD) $(MODULE_CLASSES) && $(BOOT_JAR_CMD) xf $$jf $(BOOT_JAR_JFLAGS);\
    61 	done
    94 	done
       
    95 	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
    62 
    96 
    63 gen-classlist: $(CLASSANALYZER_JAR)
    97 gen-classlist:
    64 	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
    98 	$(CD) tools && $(MAKE) all
    65 	@$(RM) -rf $(MODULE_CLASSLIST)
       
    66 	@$(MKDIR) -p $(MODULE_CLASSLIST)
       
    67 
       
    68 	@# Use java in the default tool directory.
       
    69 	@# OUTPUTDIR for solaris 64-bit doesn't have the tools.
       
    70 	$(JAVA_TOOLS_DIR)/java $(JAVA_FLAGS) \
       
    71 		-Dclassanalyzer.debug \
       
    72 		-jar $(CLASSANALYZER_JAR) \
       
    73 		-jdkhome $(OUTPUTDIR) \
       
    74 	        -config modules.config \
       
    75 	        -config modules.group \
       
    76 		-depconfig jdk7.depconfig \
       
    77 		-depconfig optional.depconfig \
       
    78 		-showdynamic \
       
    79 		-output $(MODULE_CLASSLIST)
       
    80 	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
       
    81 
    99 
    82 modularize: $(MODULE_JAR_MANIFEST_FILE)
   100 modularize: $(MODULE_JAR_MANIFEST_FILE)
    83 	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
   101 	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
    84 	@$(RM) -rf $(MODULE_LIB)
   102 	@$(RM) -rf $(MODULES_DIR)
    85 
   103 
    86 	@# create jar file for modules and
   104 	@# create jar file for modules and
    87 	@# copy other files from all members of this module 
   105 	@# copy other files from all members of this module 
    88 	for m in `$(NAWK) '{print $$1}' $(MODULES_LIST)` ; do \
   106 	for m in `$(NAWK) '{print $$1}' $(MODULES_LIST)` ; do \
    89    	   $(ECHO) "Creating module $$m" ; \
   107    	   $(ECHO) "Creating module $$m" ; \
    90    	   $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.classlist > $(TMP)/tmp.cf ; \
   108    	   $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.classlist > $(TMP)/tmp.cf ; \
    91 	   if [ -f $(MODULE_CLASSLIST)/$$m.resources ] ; then \
   109 	   if [ -f $(MODULE_CLASSLIST)/$$m.resources ] ; then \
    92    	       $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.resources >> $(TMP)/tmp.cf ; \
   110    	       $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.resources >> $(TMP)/tmp.cf ; \
    93            fi ; \
   111            fi ; \
    94            $(MKDIR) -p $(MODULE_LIB)/$$m/lib; \
   112            $(MKDIR) -p $(ABS_MODULES_DIR)/$$m/lib; \
    95 	   $(CD) $(MODULE_CLASSES) && \
   113 	   $(CD) $(MODULE_CLASSES) && \
    96                $(BOOT_JAR_CMD) c0mf $(MODULE_JAR_MANIFEST_FILE) \
   114                $(BOOT_JAR_CMD) c0mf $(MODULE_JAR_MANIFEST_FILE) \
    97 		   $(MODULE_LIB)/$$m/lib/$$m.jar \
   115 		   $(ABS_MODULES_DIR)/$$m/lib/$$m.jar \
    98 	           @$(TMP)/tmp.cf \
   116 	           @$(TMP)/tmp.cf \
    99                    $(BOOT_JAR_JFLAGS); \
   117                    $(BOOT_JAR_JFLAGS); \
   100 	   for s in `$(GREP) "^$$m" $(MODULES_LIST)` ; do \
   118 	   for s in `$(GREP) "^$$m" $(MODULES_LIST)` ; do \
   101                if [ -d $(TMP)/$$s ] ; then \
   119                if [ -d $(TMP)/$$s ] ; then \
   102                	   $(CP) -rf $(TMP)/$$s/*  $(MODULE_LIB)/$$m; \
   120                	   $(CP) -rf $(TMP)/$$s/*  $(ABS_MODULES_DIR)/$$m; \
   103 		   $(RM) -rf $(MODULE_LIB)/$$m/classes; \
   121 		   $(RM) -rf $(ABS_MODULES_DIR)/$$m/classes; \
   104 	       fi \
   122 	       fi \
   105 	   done \
   123 	   done \
   106         done
   124         done
   107 	@$(CD) $(MODULE_CLASSES) && $(java-vm-cleanup)
   125 	@$(CD) $(MODULE_CLASSES) && $(java-vm-cleanup)
   108 	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
   126 	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
   110 $(MODULE_JAR_MANIFEST_FILE):
   128 $(MODULE_JAR_MANIFEST_FILE):
   111 	$(SED) -e "s/@@RELEASE@@/$(RELEASE)/" $(MAINMANIFEST) > $@
   129 	$(SED) -e "s/@@RELEASE@@/$(RELEASE)/" $(MAINMANIFEST) > $@
   112 
   130 
   113 clean clobber::
   131 clean clobber::
   114 	$(RM) -rf $(MODULE_CLASSLIST)
   132 	$(RM) -rf $(MODULE_CLASSLIST)
   115 	$(RM) -rf $(MODULE_LIB)
   133 	$(RM) -rf $(MODULES_DIR)
   116 	$(RM) $(MODULE_JAR_MANIFEST_FILE)
   134 	$(RM) $(MODULE_JAR_MANIFEST_FILE)
   117 	$(RM) $(CLASSANALYZER_JAR)