ohair@1369: # darcy@1732: # Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. ohair@1369: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@1369: # ohair@1369: # This code is free software; you can redistribute it and/or modify it ohair@1369: # under the terms of the GNU General Public License version 2 only, as ohair@1369: # published by the Free Software Foundation. Oracle designates this ohair@1369: # particular file as subject to the "Classpath" exception as provided ohair@1369: # by Oracle in the LICENSE file that accompanied this code. ohair@1369: # ohair@1369: # This code is distributed in the hope that it will be useful, but WITHOUT ohair@1369: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@1369: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@1369: # version 2 for more details (a copy is included in the LICENSE file that ohair@1369: # accompanied this code). ohair@1369: # ohair@1369: # You should have received a copy of the GNU General Public License version ohair@1369: # 2 along with this work; if not, write to the Free Software Foundation, ohair@1369: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@1369: # ohair@1369: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@1369: # or visit www.oracle.com if you need additional information or have any ohair@1369: # questions. ohair@1369: # ohair@1369: ohair@1369: # This must be the first rule ohair@1369: default: all ohair@1369: ohair@1369: include $(SPEC) ohair@1369: include MakeBase.gmk ohair@1369: include JavaCompilation.gmk ohair@1369: ohair@1369: # The BOOT_JAVAC setup uses the bootdir compiler to compile the tools ohair@1369: # and the bootstrap javac, to be run by the bootdir jvm. ihse@2094: $(eval $(call SetupJavaCompiler,BOOT_JAVAC, \ ihse@2094: JAVAC := $(JAVAC), \ ihse@2094: SERVER_DIR := $(SJAVAC_SERVER_DIR), \ ihse@2094: SERVER_JVM := $(SJAVAC_SERVER_JAVA), \ ihse@2094: FLAGS := -XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror)) ohair@1369: erikj@1424: # javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied. ihse@2094: RESOURCE_SUFFIXES := .gif .xml .css .js javax.tools.JavaCompilerTool erikj@1424: ohair@1369: # Now setup the compilation of the properties compilation tool. You can depend ohair@1369: # upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we ohair@1369: # add src/share/classes to the sourcepath. This is necessary since the GenStubs ohair@1369: # program needs to be linked and run towards the new javac sources. ihse@2094: $(eval $(call SetupJavaCompilation,BUILD_TOOLS, \ ihse@2094: SETUP := BOOT_JAVAC, \ ihse@2094: DISABLE_SJAVAC := true, \ ihse@2094: ADD_JAVAC_FLAGS := -Xprefer:source, \ ihse@2094: SRC := $(LANGTOOLS_TOPDIR)/make/tools $(LANGTOOLS_TOPDIR)/src/share/classes, \ ihse@2094: INCLUDES := compileproperties genstubs, \ ihse@2094: BIN := $(LANGTOOLS_OUTPUTDIR)/btclasses)) ohair@1369: ohair@1369: # The compileprops tools compiles a properties file into a resource bundle. ihse@2094: TOOL_COMPILEPROPS_CMD := $(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/btclasses compileproperties.CompileProperties -quiet ihse@2094: ohair@1369: # Lookup the properties that need to be compiled into resource bundles. ihse@2094: PROPSOURCES := $(shell $(FIND) $(LANGTOOLS_TOPDIR)/src/share/classes -name "*.properties") ihse@2094: ohair@1369: # Strip away prefix and suffix, leaving for example only: "com/sun/tools/javac/resources/javac_zh_CN" ihse@2094: PROPPATHS := $(patsubst $(LANGTOOLS_TOPDIR)/src/share/classes/%.properties, %, $(PROPSOURCES)) ihse@2094: ohair@1369: # Generate the list of java files to be created. ihse@2094: PROPJAVAS := $(patsubst %, $(LANGTOOLS_OUTPUTDIR)/gensrc/%.java, $(PROPPATHS)) ihse@2094: ohair@1369: # Generate the package dirs for the tobe generated java files. ihse@2094: PROPDIRS := $(dir $(PROPJAVAS)) ihse@2094: ohair@1369: # Now generate a sequence of "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle" ohair@1369: # suitable to be fed into the CompileProperties command. ihse@2094: PROPCMDLINE := $(subst _SPACE_, $(SPACE), $(join $(addprefix -compile_SPACE_, $(PROPSOURCES)), \ ihse@2094: $(addsuffix _SPACE_java.util.ListResourceBundle, $(addprefix _SPACE_$(LANGTOOLS_OUTPUTDIR)/gensrc/, $(addsuffix .java, $(PROPPATHS)))))) ohair@1369: ohair@1369: # Now setup the rule for the generation of the resource bundles. ihse@2094: $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d: $(PROPSOURCES) $(BUILD_TOOLS) erikj@1766: $(RM) -r $(@D)/* erikj@1766: $(MKDIR) -p $(@D) $(PROPDIRS) erikj@1766: $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties erikj@1766: $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties erikj@1766: $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties erikj@1766: $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties kizune@2198: $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties erikj@1766: $(ECHO) Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles ohair@1369: $(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \ ihse@2094: -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \ ihse@2094: $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.java \ ihse@2094: java.util.ListResourceBundle \ ihse@2094: -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties \ ihse@2094: $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.java \ ihse@2094: java.util.ListResourceBundle \ ihse@2094: -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \ ihse@2094: $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \ ihse@2094: java.util.ListResourceBundle \ ihse@2094: -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties \ ihse@2094: $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.java \ kizune@2198: java.util.ListResourceBundle \ kizune@2198: -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties \ kizune@2198: $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.java \ ihse@2094: java.util.ListResourceBundle ihse@2094: $(ECHO) PROPS_ARE_CREATED = yes > $@ ohair@1369: ohair@1369: # Trigger the generation of the resource bundles. After the resource bundles have ohair@1369: # been compiled, then the makefile will restart and the newly created java files ohair@1369: # will become part of the build further along in the makefile. ohair@1369: -include $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d ohair@1369: ihse@2094: ifeq ($(PROPS_ARE_CREATED), yes) ihse@2094: # Setup the rules to build a dist/bootstrap/lib/javac.jar, ie a smaller intermediate javac ihse@2094: # that can be compiled with an old javac. The intermediate javac is then used ihse@2094: # to compile javac again and to build the complete new jdk. ihse@2094: $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_LANGTOOLS, \ ihse@2094: SETUP := BOOT_JAVAC, \ ihse@2094: DISABLE_SJAVAC := true, \ ihse@2094: SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc, \ ihse@2094: EXCLUDES := com/sun/tools/javac/nio, \ ihse@2094: COPY := $(RESOURCE_SUFFIXES), \ ihse@2094: BIN := $(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap)) ohair@1369: ihse@2094: $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAC, $(BUILD_BOOTSTRAP_LANGTOOLS), \ ihse@2094: SRCS := $(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap, \ ihse@2094: JAR := $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar, \ ihse@2094: SUFFIXES := .class $(RESOURCE_SUFFIXES))) ohair@1369: ihse@2094: # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not ihse@2094: # yet built. It is currently not needed but might be again in the future. The following ihse@2094: # exercises the functionality to verify that it works. ihse@2094: TOOL_GENSTUBS_CMD = $(JAVA) \ ihse@2094: "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \ ihse@2094: -classpath $(LANGTOOLS_OUTPUTDIR)/btclasses \ ihse@2094: genstubs.GenStubs ohair@1369: ihse@2094: # We fetch source from the JDK... ihse@2094: JDKS = $(JDK_TOPDIR)/src/share/classes ohair@1369: ihse@2094: # Build the list of classes to generate stubs from. java/util/function/Predicate.java isn't ihse@2094: # currently needed, but is used as a demo for now. ohair@1369: ihse@2094: STUBSOURCES := $(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \ ihse@2094: -e "$(JDKS)/java/util/function/Predicate.java") ohair@1369: ihse@2094: # Rewrite the file names into class names because the GenStubs tool require this. ihse@2094: STUBCLASSES := $(subst /,., $(patsubst $(JDKS)/%.java, %, $(STUBSOURCES))) ohair@1369: ihse@2094: # Now setup the build recipe for genstubs. ihse@2094: $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d: $(STUBSOURCES) $(BUILD_TOOLS) \ ihse@2094: $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ ihse@2094: $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d ihse@2094: $(MKDIR) -p $(@D) ihse@2094: $(MKDIR) -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs ihse@2094: $(ECHO) $(LOG_INFO) Generating stubs from JDK sources. ihse@2094: ($(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES) && $(ECHO) STUBS_ARE_CREATED = yes > $@) ihse@2094: if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs > /dev/null 2>&1; then \ ihse@2094: $(ECHO) $(LOG_INFO) No changes in the stubs!; \ ihse@2094: $(RM) -r $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \ ihse@2094: else \ ihse@2094: $(ECHO) $(LOG_INFO) Changes in stubs detected!; \ ihse@2094: $(RM) -r $(@D); \ ihse@2094: $(MV) $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \ ihse@2094: fi ihse@2094: $(ECHO) STUBS_ARE_CREATED = yes > $@ ohair@1369: ihse@2094: # Trigger a generation of the genstubs java source code and a restart ihse@2094: # of the makefile to make sure that the following build setup use the ihse@2094: # newly created java files. ihse@2094: -include $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d ohair@1369: ihse@2094: ifeq ($(STUBS_ARE_CREATED), yes) ihse@2094: # Setup a compiler configuration using the intermediate javac in dist/bootstrap/lib/javac.jar ihse@2094: # that generates code for the new jdk that is being built. ihse@2094: # The code compiled by this compiler setup, cannot necessarily be run with the bootstrap jvm. ihse@2094: $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE, \ ihse@2094: JVM := $(JAVA), \ ihse@2094: JAVAC := "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \ ihse@2094: -cp $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ ihse@2094: com.sun.tools.javac.Main, \ ihse@2094: FLAGS := -XDignore.symbol.file=true -Xlint:all$(COMMA)-deprecation -Werror, \ ihse@2094: SERVER_DIR := $(SJAVAC_SERVER_DIR), \ ihse@2094: SERVER_JVM := $(SJAVAC_SERVER_JAVA))) ohair@1369: ihse@2094: $(eval $(call SetupJavaCompilation,BUILD_FULL_JAVAC, \ ihse@2094: SETUP := GENERATE_NEWBYTECODE, \ ihse@2094: SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc \ ihse@2094: $(LANGTOOLS_OUTPUTDIR)/genstubs, \ ihse@2094: EXCLUDES := java/util java/io java/nio, \ ihse@2094: COPY := $(RESOURCE_SUFFIXES), \ ihse@2094: BIN := $(LANGTOOLS_OUTPUTDIR)/classes)) ihse@2094: ihse@2094: $(eval $(call SetupArchive,ARCHIVE_FULL_JAVAC, $(BUILD_FULL_JAVAC), \ ihse@2094: SETUP := GENERATE_NEWBYTECODE, \ ihse@2094: SRCS := $(LANGTOOLS_OUTPUTDIR)/classes, \ ihse@2094: SUFFIXES := .class $(RESOURCE_SUFFIXES), \ ihse@2094: JAR := $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar)) ihse@2094: ihse@2094: $(eval $(call SetupZipArchive,ZIP_FULL_JAVAC_SOURCE, \ ihse@2094: SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc, \ ihse@2094: ZIP := $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip)) ihse@2094: ihse@2094: all: $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar \ ihse@2094: $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip \ ihse@2094: $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar ihse@2094: ihse@2094: endif ohair@1369: endif