1 # 2 # Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 5 # This code is free software; you can redistribute it and/or modify it 6 # under the terms of the GNU General Public License version 2 only, as 7 # published by the Free Software Foundation. Oracle designates this 8 # particular file as subject to the "Classpath" exception as provided 9 # by Oracle in the LICENSE file that accompanied this code. 10 # 11 # This code is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 # version 2 for more details (a copy is included in the LICENSE file that 15 # accompanied this code). 16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 # 25 26 BUILDDIR = .. 27 include $(BUILDDIR)/common/Defs.gmk 28 29 # 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. 74 75 76 MAINMANIFEST=$(JDK_TOPDIR)/make/tools/manifest.mf 77 MODULE_JAR_MANIFEST_FILE=$(ABS_TEMPDIR)/manifest.tmp 78 79 TMP = $(ABS_MODULES_TEMPDIR) 80 MODULE_CLASSLIST = $(ABS_MODULES_TEMPDIR)/classlist 81 MODULE_CLASSES = $(ABS_MODULES_TEMPDIR)/classes 82 MODULES_LIST = $(MODULE_CLASSLIST)/modules.list 83 84 all:: unpack-jars gen-classlist modularize 85 86 JAR_LIST := $(shell $(FIND) $(ABS_OUTPUTDIR)/lib -name \*.jar -print) 87 unpack-jars: 88 @$(ECHO) ">>>Making "$@" @ `$(DATE)` ..." 89 $(RM) -rf $(MODULE_CLASSES) 90 $(MKDIR) -p $(MODULE_CLASSES) 91 $(CP) -rf $(CLASSBINDIR)/* $(MODULE_CLASSES) 92 @for jf in $(JAR_LIST) ; do \ 93 $(CD) $(MODULE_CLASSES) && $(BOOT_JAR_CMD) xf $$jf $(BOOT_JAR_JFLAGS);\ 94 done 95 @$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..." 96 97 gen-classlist: 98 $(CD) tools && $(MAKE) all 99 100 modularize: $(MODULE_JAR_MANIFEST_FILE) 101 @$(ECHO) ">>>Making "$@" @ `$(DATE)` ..." 102 @$(RM) -rf $(MODULES_DIR) 103 104 @# create jar file for modules and 105 @# copy other files from all members of this module 106 for m in `$(NAWK) '{print $$1}' $(MODULES_LIST)` ; do \ 107 $(ECHO) "Creating module $$m" ; \ 108 $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.classlist > $(TMP)/tmp.cf ; \ 109 if [ -f $(MODULE_CLASSLIST)/$$m.resources ] ; then \ 110 $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.resources >> $(TMP)/tmp.cf ; \ 111 fi ; \ 112 $(MKDIR) -p $(ABS_MODULES_DIR)/$$m/lib; \ 113 $(CD) $(MODULE_CLASSES) && \ 114 $(BOOT_JAR_CMD) c0mf $(MODULE_JAR_MANIFEST_FILE) \ 115 $(ABS_MODULES_DIR)/$$m/lib/$$m.jar \ 116 @$(TMP)/tmp.cf \ 117 $(BOOT_JAR_JFLAGS); \ 118 for s in `$(GREP) "^$$m" $(MODULES_LIST)` ; do \ 119 if [ -d $(TMP)/$$s ] ; then \ 120 $(CP) -rf $(TMP)/$$s/* $(ABS_MODULES_DIR)/$$m; \ 121 $(RM) -rf $(ABS_MODULES_DIR)/$$m/classes; \ 122 fi \ 123 done \ 124 done 125 @$(CD) $(MODULE_CLASSES) && $(java-vm-cleanup) 126 @$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..." 127 128 $(MODULE_JAR_MANIFEST_FILE): 129 $(SED) -e "s/@@RELEASE@@/$(RELEASE)/" $(MAINMANIFEST) > $@ 130 131 clean clobber:: 132 $(RM) -rf $(MODULE_CLASSLIST) 133 $(RM) -rf $(MODULES_DIR) 134 $(RM) $(MODULE_JAR_MANIFEST_FILE)