jdk/make/modules/Makefile
author mchung
Mon, 18 Jan 2010 15:23:14 -0800
changeset 4681 7d382dfe6e55
parent 4665 d14dc3d9e1fa
child 5506 202f599c92aa
permissions -rw-r--r--
6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH Summary: build modules not depending on ALT_JDK_IMPORT_PATH being set Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
     1
#
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
     2
# Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
     4
#
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
     7
# published by the Free Software Foundation.  Sun designates this
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
     9
# by Sun in the LICENSE file that accompanied this code.
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    10
#
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    15
# accompanied this code).
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    16
#
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    20
#
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    21
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    22
# CA 95054 USA or visit www.sun.com if you need additional information or
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    23
# have any questions.
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    24
#
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    25
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    26
BUILDDIR = ..
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    27
include $(BUILDDIR)/common/Defs.gmk
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    28
4681
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    29
#
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    30
# Modularizing the JDK
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    31
# - Post jdk build process until the source tree is restructured
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    32
#   for modules build
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    33
# - <outputdir>/modules/<module> will be created for each module.
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    34
#
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    35
# Steps:
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    36
# 0. During jdk build before this makefile is invoked, classes, 
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    37
#    resource files, and other non-class files such as native libraries,
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    38
#    properties file, images, etc are created.
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    39
#
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    40
#    Non-class files are copied to <outputdir>/tmp/modules/<MODULE>
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    41
#    directory in this step to prepare for the post-build modularization. 
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    42
#
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    43
#    The MODULE variable defined in other makefiles specifies 
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    44
#    the lowest-level module that the non-class files belong to.
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    45
#    The name might or might not be the same as the name of the modules 
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    46
#    in the resulting <outputdir>/modules directory.
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    47
#    
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    48
# 1. Unpack all jars in the <builddir>/lib directory to a temporary 
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    49
#    location (<outputdir>/tmp/modules/classes) to prepare for modules
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    50
#    creation.
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    51
#
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    52
# 2. Run ClassAnalyzer tool to analyze all jdk classes and generate
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    53
#    class list for all modules and also perform dependency analysis. 
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    54
#
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    55
#    Input configuration files :-
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    56
#
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    57
#    modules.config : defines the low-level modules and specifies 
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    58
#       what classes and resource files each module includes.
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    59
#    modules.group  : defines the module groups and its members.
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    60
#    jdk7.depconfig : lists the dynamic dependencies including
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    61
#       use of reflection Class.forName and JNI FindClass and
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    62
#       service provider.
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    63
#    optional.depconfig : lists the optional dependencies
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    64
#
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    65
# 3. Create one directory for each module (<outputdir>/modules/<module>)
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    66
#    based on the output files from (2).
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    67
#       
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    68
#    modules.list lists the modules to be created for the modules
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    69
#    build and its members. For each module (m) in modules.list,
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    70
#    a. create $m/lib/$m.jar with all classes and resource files
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    71
#       listed in $m.classlist and $m.resources respectively.
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    72
#    b. copy all non-class files from its members to 
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    73
#       <outputdir>/modules/$m.
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    74
4681
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    75
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    76
MAINMANIFEST=$(JDK_TOPDIR)/make/tools/manifest.mf
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    77
MODULE_JAR_MANIFEST_FILE=$(ABS_TEMPDIR)/manifest.tmp
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    78
4681
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    79
TMP = $(ABS_MODULES_TEMPDIR)
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    80
MODULE_CLASSLIST = $(ABS_MODULES_TEMPDIR)/classlist
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    81
MODULE_CLASSES = $(ABS_MODULES_TEMPDIR)/classes
4665
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
    82
MODULES_LIST = $(MODULE_CLASSLIST)/modules.list
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    83
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    84
all:: unpack-jars gen-classlist modularize
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    85
4665
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
    86
JAR_LIST := $(shell $(FIND) $(ABS_OUTPUTDIR)/lib -name \*.jar -print) 
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    87
unpack-jars:
4681
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    88
	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    89
	$(RM) -rf $(MODULE_CLASSES)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    90
	$(MKDIR) -p $(MODULE_CLASSES)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    91
	$(CP) -rf $(CLASSBINDIR)/* $(MODULE_CLASSES)
4681
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    92
	@for jf in  $(JAR_LIST) ; do \
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    93
	   $(CD) $(MODULE_CLASSES) && $(BOOT_JAR_CMD) xf $$jf $(BOOT_JAR_JFLAGS);\
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    94
	done
4681
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    95
	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    96
4681
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    97
gen-classlist:
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
    98
	$(CD) tools && $(MAKE) all
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    99
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   100
modularize: $(MODULE_JAR_MANIFEST_FILE)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   101
	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
4681
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
   102
	@$(RM) -rf $(MODULES_DIR)
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   103
4665
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   104
	@# create jar file for modules and
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   105
	@# copy other files from all members of this module 
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   106
	for m in `$(NAWK) '{print $$1}' $(MODULES_LIST)` ; do \
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   107
   	   $(ECHO) "Creating module $$m" ; \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   108
   	   $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.classlist > $(TMP)/tmp.cf ; \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   109
	   if [ -f $(MODULE_CLASSLIST)/$$m.resources ] ; then \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   110
   	       $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.resources >> $(TMP)/tmp.cf ; \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   111
           fi ; \
4681
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
   112
           $(MKDIR) -p $(ABS_MODULES_DIR)/$$m/lib; \
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   113
	   $(CD) $(MODULE_CLASSES) && \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   114
               $(BOOT_JAR_CMD) c0mf $(MODULE_JAR_MANIFEST_FILE) \
4681
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
   115
		   $(ABS_MODULES_DIR)/$$m/lib/$$m.jar \
4665
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   116
	           @$(TMP)/tmp.cf \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   117
                   $(BOOT_JAR_JFLAGS); \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   118
	   for s in `$(GREP) "^$$m" $(MODULES_LIST)` ; do \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   119
               if [ -d $(TMP)/$$s ] ; then \
4681
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
   120
               	   $(CP) -rf $(TMP)/$$s/*  $(ABS_MODULES_DIR)/$$m; \
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
   121
		   $(RM) -rf $(ABS_MODULES_DIR)/$$m/classes; \
4665
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   122
	       fi \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   123
	   done \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   124
        done
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   125
	@$(CD) $(MODULE_CLASSES) && $(java-vm-cleanup)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   126
	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   127
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   128
$(MODULE_JAR_MANIFEST_FILE):
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   129
	$(SED) -e "s/@@RELEASE@@/$(RELEASE)/" $(MAINMANIFEST) > $@
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   130
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   131
clean clobber::
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   132
	$(RM) -rf $(MODULE_CLASSLIST)
4681
7d382dfe6e55 6916217: make/modules/Makefile requires ALT_JDK_IMPORT_PATH
mchung
parents: 4665
diff changeset
   133
	$(RM) -rf $(MODULES_DIR)
4665
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   134
	$(RM) $(MODULE_JAR_MANIFEST_FILE)