jdk/make/modules/Makefile
author mchung
Thu, 07 Jan 2010 08:14:48 -0800
changeset 4665 d14dc3d9e1fa
parent 4524 697144bd8b04
child 4681 7d382dfe6e55
permissions -rw-r--r--
6911737: Module build: generate modules with native libraries and any other files not in jar Summary: create modules under OUTPUTDIR/modules directory containing resources, native libraries Reviewed-by: alanb, ohair
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
#
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    27
# Modularizing the JDK
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    28
#
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    29
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    30
BUILDDIR = ..
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    31
include $(BUILDDIR)/common/Defs.gmk
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    32
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    33
CLASSANALYZER_JAR=$(BUILDTOOLJARDIR)/classanalyzer.jar
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    34
JAVA_FLAGS=$(JAVA_TOOLS_FLAGS) -Xbootclasspath:$(CLASSBINDIR)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    35
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    36
MODULE_LIB = $(ABS_OUTPUTDIR)/modules
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    37
MAINMANIFEST=$(JDK_TOPDIR)/make/tools/manifest.mf
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    38
MODULE_JAR_MANIFEST_FILE=$(ABS_TEMPDIR)/manifest.tmp
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    39
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    40
TMP=$(ABS_TEMPDIR)/modules
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    41
MODULE_CLASSLIST = $(TMP)/classlist
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    42
MODULE_CLASSES = $(TMP)/classes
4665
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
    43
MODULES_LIST = $(MODULE_CLASSLIST)/modules.list
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    44
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    45
SUBDIRS = tools
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    46
all build clean clobber::
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    47
	$(SUBDIRS-loop)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    48
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    49
all:: unpack-jars gen-classlist modularize
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    50
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    51
$(CLASSANALYZER_JAR):
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    52
	$(CD) tools && $(MAKE) all
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    53
4665
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
    54
JAR_LIST := $(shell $(FIND) $(ABS_OUTPUTDIR)/lib -name \*.jar -print) 
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    55
unpack-jars:
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    56
	$(RM) -rf $(MODULE_CLASSES)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    57
	$(MKDIR) -p $(MODULE_CLASSES)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    58
	$(CP) -rf $(CLASSBINDIR)/* $(MODULE_CLASSES)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    59
	for jf in  $(JAR_LIST) ; do \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    60
	   $(CD) $(MODULE_CLASSES) && $(BOOT_JAR_CMD) xf $$jf $(BOOT_JAR_JFLAGS);\
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    61
	done
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    62
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    63
gen-classlist: $(CLASSANALYZER_JAR)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    64
	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    65
	@$(RM) -rf $(MODULE_CLASSLIST)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    66
	@$(MKDIR) -p $(MODULE_CLASSLIST)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    67
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    68
	@# Use java in the default tool directory.
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    69
	@# OUTPUTDIR for solaris 64-bit doesn't have the tools.
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    70
	$(JAVA_TOOLS_DIR)/java $(JAVA_FLAGS) \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    71
		-Dclassanalyzer.debug \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    72
		-jar $(CLASSANALYZER_JAR) \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    73
		-jdkhome $(OUTPUTDIR) \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    74
	        -config modules.config \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    75
	        -config modules.group \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    76
		-depconfig jdk7.depconfig \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    77
		-depconfig optional.depconfig \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    78
		-showdynamic \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    79
		-output $(MODULE_CLASSLIST)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    80
	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    81
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    82
modularize: $(MODULE_JAR_MANIFEST_FILE)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    83
	@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    84
	@$(RM) -rf $(MODULE_LIB)
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
	@# 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
    87
	@# 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
    88
	for m in `$(NAWK) '{print $$1}' $(MODULES_LIST)` ; do \
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    89
   	   $(ECHO) "Creating module $$m" ; \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    90
   	   $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.classlist > $(TMP)/tmp.cf ; \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    91
	   if [ -f $(MODULE_CLASSLIST)/$$m.resources ] ; then \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    92
   	       $(SED) -e 's%\\%\/%g' < $(MODULE_CLASSLIST)/$$m.resources >> $(TMP)/tmp.cf ; \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    93
           fi ; \
4665
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
    94
           $(MKDIR) -p $(MODULE_LIB)/$$m/lib; \
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    95
	   $(CD) $(MODULE_CLASSES) && \
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
    96
               $(BOOT_JAR_CMD) c0mf $(MODULE_JAR_MANIFEST_FILE) \
4665
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
    97
		   $(MODULE_LIB)/$$m/lib/$$m.jar \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
    98
	           @$(TMP)/tmp.cf \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
    99
                   $(BOOT_JAR_JFLAGS); \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   100
	   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
   101
               if [ -d $(TMP)/$$s ] ; then \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   102
               	   $(CP) -rf $(TMP)/$$s/*  $(MODULE_LIB)/$$m; \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   103
		   $(RM) -rf $(MODULE_LIB)/$$m/classes; \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   104
	       fi \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   105
	   done \
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   106
        done
4524
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   107
	@$(CD) $(MODULE_CLASSES) && $(java-vm-cleanup)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   108
	@$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   109
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   110
$(MODULE_JAR_MANIFEST_FILE):
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   111
	$(SED) -e "s/@@RELEASE@@/$(RELEASE)/" $(MAINMANIFEST) > $@
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   112
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   113
clean clobber::
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   114
	$(RM) -rf $(MODULE_CLASSLIST)
697144bd8b04 6909572: Add a new target for building modules
mchung
parents:
diff changeset
   115
	$(RM) -rf $(MODULE_LIB)
4665
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   116
	$(RM) $(MODULE_JAR_MANIFEST_FILE)
d14dc3d9e1fa 6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents: 4524
diff changeset
   117
	$(RM) $(CLASSANALYZER_JAR)