Wed, 11 Apr 2012 14:10:53 -0700
Merge
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/makefiles/Makefile Wed Apr 11 14:10:53 2012 -0700 1.3 @@ -0,0 +1,203 @@ 1.4 +# 1.5 +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 +# 1.8 +# This code is free software; you can redistribute it and/or modify it 1.9 +# under the terms of the GNU General Public License version 2 only, as 1.10 +# published by the Free Software Foundation. Oracle designates this 1.11 +# particular file as subject to the "Classpath" exception as provided 1.12 +# by Oracle in the LICENSE file that accompanied this code. 1.13 +# 1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 +# version 2 for more details (a copy is included in the LICENSE file that 1.18 +# accompanied this code). 1.19 +# 1.20 +# You should have received a copy of the GNU General Public License version 1.21 +# 2 along with this work; if not, write to the Free Software Foundation, 1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 +# 1.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 +# or visit www.oracle.com if you need additional information or have any 1.26 +# questions. 1.27 +# 1.28 + 1.29 +include $(SPEC) 1.30 +include MakeBase.gmk 1.31 +include JavaCompilation.gmk 1.32 + 1.33 +default: all 1.34 + 1.35 +# The BOOT_JAVAC setup uses the bootdir compiler to compile the tools 1.36 +# and the bootstrap javac, to be run by the bootdir jvm. 1.37 +$(eval $(call SetupJavaCompiler,BOOT_JAVAC,\ 1.38 + JAVAC:=$(JAVAC),\ 1.39 + FLAGS:=-Xprefer:source -XDignore.symbol.file=true -g,\ 1.40 + MODE:=SINGLE_THREADED_BATCH)) 1.41 + 1.42 +# Now setup the compilation of the properties compilation tool. You can depend 1.43 +# upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we 1.44 +# add src/share/classes to the sourcepath. This is necessary since the GenStubs 1.45 +# program needs to be linked and run towards the new javac sources. 1.46 +$(eval $(call SetupJavaCompilation,BUILD_TOOLS,\ 1.47 + SETUP:=BOOT_JAVAC,\ 1.48 + SRC:=$(LANGTOOLS_TOPDIR)/make/tools $(LANGTOOLS_TOPDIR)/src/share/classes,\ 1.49 + INCLUDES:=compileproperties genstubs,\ 1.50 + BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses)) 1.51 + 1.52 +# The compileprops tools compiles a properties file into a resource bundle. 1.53 +TOOL_COMPILEPROPS_CMD:=$(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/btclasses compileproperties.CompileProperties -quiet 1.54 +# Lookup the properties that need to be compiled into resource bundles. 1.55 +PROPSOURCES:=$(shell find $(LANGTOOLS_TOPDIR)/src/share/classes -name "*.properties") 1.56 +# Strip away prefix and suffix, leaving for example only: "com/sun/tools/javac/resources/javac_zh_CN" 1.57 +PROPPATHS:=$(patsubst $(LANGTOOLS_TOPDIR)/src/share/classes/%.properties,%,$(PROPSOURCES)) 1.58 +# Generate the list of java files to be created. 1.59 +PROPJAVAS:=$(patsubst %,$(LANGTOOLS_OUTPUTDIR)/gensrc/%.java,$(PROPPATHS)) 1.60 +# Generate the package dirs for the tobe generated java files. 1.61 +PROPDIRS:=$(dir $(PROPJAVAS)) 1.62 +# Now generate a sequence of "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle" 1.63 +# suitable to be fed into the CompileProperties command. 1.64 +PROPCMDLINE:=$(subst _SPACE_,$(SPACE),$(join $(addprefix -compile_SPACE_,$(PROPSOURCES)), \ 1.65 + $(addsuffix _SPACE_java.util.ListResourceBundle,$(addprefix _SPACE_$(LANGTOOLS_OUTPUTDIR)/gensrc/,$(addsuffix .java,$(PROPPATHS)))))) 1.66 + 1.67 +# Now setup the rule for the generation of the resource bundles. 1.68 +$(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d : $(PROPSOURCES) $(BUILD_TOOLS) 1.69 + rm -rf $(@D)/* 1.70 + mkdir -p $(@D) $(PROPDIRS) 1.71 + printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties 1.72 + printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties 1.73 + printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties 1.74 + echo Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles 1.75 + $(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \ 1.76 + -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \ 1.77 + $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.java \ 1.78 + java.util.ListResourceBundle \ 1.79 + -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties \ 1.80 + $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.java \ 1.81 + java.util.ListResourceBundle \ 1.82 + -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \ 1.83 + $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \ 1.84 + java.util.ListResourceBundle 1.85 + echo PROPS_ARE_CREATED=yes > $@ 1.86 + 1.87 +# Trigger the generation of the resource bundles. After the resource bundles have 1.88 +# been compiled, then the makefile will restart and the newly created java files 1.89 +# will become part of the build further along in the makefile. 1.90 +-include $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d 1.91 + 1.92 +ifeq ($(PROPS_ARE_CREATED),yes) 1.93 + # Setup the rules to build a dist/bootstrap/lib/javac.jar, ie a smaller intermediate javac 1.94 + # that can be compiled with an old javac. The intermediate javac is then used 1.95 + # to compile javac again and to build the complete new jdk. 1.96 + $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_LANGTOOLS,\ 1.97 + SETUP:=BOOT_JAVAC,\ 1.98 + SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\ 1.99 + EXCLUDES:=com/sun/tools/javac/nio,\ 1.100 + BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap)) 1.101 + 1.102 + $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAC,$(BUILD_BOOTSTRAP_LANGTOOLS),\ 1.103 + SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ 1.104 + JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar,\ 1.105 + JARMAIN:=com.sun.tools.javac.Main)) 1.106 + 1.107 + $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAH,$(BUILD_BOOTSTRAP_LANGTOOLS),\ 1.108 + SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ 1.109 + JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javah.jar,\ 1.110 + JARMAIN:=com.sun.tools.javah.Main)) 1.111 + 1.112 + $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAP,$(BUILD_BOOTSTRAP_LANGTOOLS),\ 1.113 + SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ 1.114 + JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javap.jar,\ 1.115 + JARMAIN:=com.sun.tools.javap.Main)) 1.116 + 1.117 + $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVADOC,$(BUILD_BOOTSTRAP_LANGTOOLS),\ 1.118 + SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ 1.119 + JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javadoc.jar,\ 1.120 + JARMAIN:=com.sun.tools.javadoc.Main)) 1.121 + 1.122 + # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not 1.123 + # yet built. It is currently not needed but might be again in the future. The following 1.124 + # exercises the functionality to verify that it works. 1.125 + TOOL_GENSTUBS_CMD=$(JAVA) \ 1.126 + "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \ 1.127 + -cp "$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar$(PATH_SEP)$(LANGTOOLS_OUTPUTDIR)/btclasses" \ 1.128 + genstubs.GenStubs 1.129 + # We fetch source from the JDK... 1.130 + JDKS=$(JDK_TOPDIR)/src/share/classes 1.131 + # Build the list of classes to generate stubs from. java/util/Objects.java isn't 1.132 + # currently needed, but is used as a demo for now. 1.133 + STUBSOURCES:=$(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \ 1.134 + -e "$(JDKS)/java/util/Objects.java") 1.135 + # Rewrite the file names into class names because the GenStubs tool require this. 1.136 + STUBCLASSES:=$(subst /,.,$(patsubst $(JDKS)/%.java,%,$(STUBSOURCES))) 1.137 + 1.138 + # Now setup the build recipe for genstubs. 1.139 + $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d : $(STUBSOURCES) $(BUILD_TOOLS) \ 1.140 + $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ 1.141 + $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d 1.142 + mkdir -p $(@D) 1.143 + mkdir -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs 1.144 + echo Generating stubs from JDK sources. 1.145 + ($(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES) && echo STUBS_ARE_CREATED=yes > $@) 1.146 + if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs > /dev/null 2>&1; then \ 1.147 + echo No changes in the stubs!; \ 1.148 + rm -rf $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \ 1.149 + else \ 1.150 + echo Changes in stubs detected!; \ 1.151 + rm -rf $(@D); \ 1.152 + mv $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \ 1.153 + fi 1.154 + echo STUBS_ARE_CREATED=yes > $@ 1.155 + 1.156 + # Trigger a generation of the genstubs java source code and a restart 1.157 + # of the makefile to make sure that the following build setup use the 1.158 + # newly created java files. 1.159 + -include $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d 1.160 + 1.161 + ifeq ($(STUBS_ARE_CREATED),yes) 1.162 + # Setup a compiler configuration using the intermediate javac in dist/bootstrap/lib/javac.jar 1.163 + # that generates code for the new jdk that is being built. 1.164 + # The code compiled by this compiler setup, cannot necessarily be run with the bootstrap jvm. 1.165 + $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE,\ 1.166 + JVM:=$(JAVA),\ 1.167 + JAVAC:="-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \ 1.168 + -jar $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar,\ 1.169 + FLAGS:=-Xprefer:source -XDignore.symbol.file=true,\ 1.170 + SERVER_DIR:=$(JAVAC_SERVERS),\ 1.171 + SERVER_JVM:=$(SERVER_JAVA),\ 1.172 + MODE:=$(JAVAC_USE_MODE),\ 1.173 + USE_DEPS:=$(JAVAC_USE_DEPS))) 1.174 + 1.175 + # javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied. 1.176 + RESOURCE_SUFFIXES:=.gif .xml .css javax.tools.JavaCompilerTool 1.177 + 1.178 + $(eval $(call SetupJavaCompilation,BUILD_FULL_JAVAC,\ 1.179 + SETUP:=GENERATE_NEWBYTECODE,\ 1.180 + SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc \ 1.181 + $(LANGTOOLS_OUTPUTDIR)/genstubs,\ 1.182 + EXCLUDES:=java/util java/io java/nio,\ 1.183 + COPY:=$(RESOURCE_SUFFIXES),\ 1.184 + BIN:=$(LANGTOOLS_OUTPUTDIR)/classes)) 1.185 + 1.186 + $(eval $(call SetupArchive,ARCHIVE_FULL_JAVAC,$(BUILD_FULL_JAVAC),\ 1.187 + SETUP:=GENERATE_NEWBYTECODE,\ 1.188 + SRCS:=$(LANGTOOLS_OUTPUTDIR)/classes,\ 1.189 + SUFFIXES:=.class $(RESOURCE_SUFFIXES),\ 1.190 + JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar,\ 1.191 + HEADERS:=$(LANGTOOLS_OUTPUTDIR)/gensrc_headers)) 1.192 + 1.193 + $(eval $(call SetupZipArchive,ZIP_FULL_JAVAC_SOURCE,\ 1.194 + SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\ 1.195 + ZIP:=$(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip)) 1.196 + 1.197 + all: $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar \ 1.198 + $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip \ 1.199 + $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ 1.200 + $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javah.jar \ 1.201 + $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javap.jar \ 1.202 + $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javadoc.jar 1.203 + 1.204 + 1.205 + endif 1.206 +endif