Fri, 15 Dec 2017 09:20:16 -0800
Merge
ohair@1369 | 1 | # |
darcy@1732 | 2 | # Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
ohair@1369 | 3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohair@1369 | 4 | # |
ohair@1369 | 5 | # This code is free software; you can redistribute it and/or modify it |
ohair@1369 | 6 | # under the terms of the GNU General Public License version 2 only, as |
ohair@1369 | 7 | # published by the Free Software Foundation. Oracle designates this |
ohair@1369 | 8 | # particular file as subject to the "Classpath" exception as provided |
ohair@1369 | 9 | # by Oracle in the LICENSE file that accompanied this code. |
ohair@1369 | 10 | # |
ohair@1369 | 11 | # This code is distributed in the hope that it will be useful, but WITHOUT |
ohair@1369 | 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohair@1369 | 13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohair@1369 | 14 | # version 2 for more details (a copy is included in the LICENSE file that |
ohair@1369 | 15 | # accompanied this code). |
ohair@1369 | 16 | # |
ohair@1369 | 17 | # You should have received a copy of the GNU General Public License version |
ohair@1369 | 18 | # 2 along with this work; if not, write to the Free Software Foundation, |
ohair@1369 | 19 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohair@1369 | 20 | # |
ohair@1369 | 21 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@1369 | 22 | # or visit www.oracle.com if you need additional information or have any |
ohair@1369 | 23 | # questions. |
ohair@1369 | 24 | # |
ohair@1369 | 25 | |
ohair@1369 | 26 | # This must be the first rule |
ohair@1369 | 27 | default: all |
ohair@1369 | 28 | |
ohair@1369 | 29 | include $(SPEC) |
ohair@1369 | 30 | include MakeBase.gmk |
ohair@1369 | 31 | include JavaCompilation.gmk |
ohair@1369 | 32 | |
ohair@1369 | 33 | # The BOOT_JAVAC setup uses the bootdir compiler to compile the tools |
ohair@1369 | 34 | # and the bootstrap javac, to be run by the bootdir jvm. |
ihse@2094 | 35 | $(eval $(call SetupJavaCompiler,BOOT_JAVAC, \ |
ihse@2094 | 36 | JAVAC := $(JAVAC), \ |
ihse@2094 | 37 | SERVER_DIR := $(SJAVAC_SERVER_DIR), \ |
ihse@2094 | 38 | SERVER_JVM := $(SJAVAC_SERVER_JAVA), \ |
ihse@2094 | 39 | FLAGS := -XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror)) |
ohair@1369 | 40 | |
erikj@1424 | 41 | # javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied. |
ihse@2094 | 42 | RESOURCE_SUFFIXES := .gif .xml .css .js javax.tools.JavaCompilerTool |
erikj@1424 | 43 | |
ohair@1369 | 44 | # Now setup the compilation of the properties compilation tool. You can depend |
ohair@1369 | 45 | # upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we |
ohair@1369 | 46 | # add src/share/classes to the sourcepath. This is necessary since the GenStubs |
ohair@1369 | 47 | # program needs to be linked and run towards the new javac sources. |
ihse@2094 | 48 | $(eval $(call SetupJavaCompilation,BUILD_TOOLS, \ |
ihse@2094 | 49 | SETUP := BOOT_JAVAC, \ |
ihse@2094 | 50 | DISABLE_SJAVAC := true, \ |
ihse@2094 | 51 | ADD_JAVAC_FLAGS := -Xprefer:source, \ |
ihse@2094 | 52 | SRC := $(LANGTOOLS_TOPDIR)/make/tools $(LANGTOOLS_TOPDIR)/src/share/classes, \ |
ihse@2094 | 53 | INCLUDES := compileproperties genstubs, \ |
ihse@2094 | 54 | BIN := $(LANGTOOLS_OUTPUTDIR)/btclasses)) |
ohair@1369 | 55 | |
ohair@1369 | 56 | # The compileprops tools compiles a properties file into a resource bundle. |
ihse@2094 | 57 | TOOL_COMPILEPROPS_CMD := $(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/btclasses compileproperties.CompileProperties -quiet |
ihse@2094 | 58 | |
ohair@1369 | 59 | # Lookup the properties that need to be compiled into resource bundles. |
ihse@2094 | 60 | PROPSOURCES := $(shell $(FIND) $(LANGTOOLS_TOPDIR)/src/share/classes -name "*.properties") |
ihse@2094 | 61 | |
ohair@1369 | 62 | # Strip away prefix and suffix, leaving for example only: "com/sun/tools/javac/resources/javac_zh_CN" |
ihse@2094 | 63 | PROPPATHS := $(patsubst $(LANGTOOLS_TOPDIR)/src/share/classes/%.properties, %, $(PROPSOURCES)) |
ihse@2094 | 64 | |
ohair@1369 | 65 | # Generate the list of java files to be created. |
ihse@2094 | 66 | PROPJAVAS := $(patsubst %, $(LANGTOOLS_OUTPUTDIR)/gensrc/%.java, $(PROPPATHS)) |
ihse@2094 | 67 | |
ohair@1369 | 68 | # Generate the package dirs for the tobe generated java files. |
ihse@2094 | 69 | PROPDIRS := $(dir $(PROPJAVAS)) |
ihse@2094 | 70 | |
ohair@1369 | 71 | # Now generate a sequence of "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle" |
ohair@1369 | 72 | # suitable to be fed into the CompileProperties command. |
ihse@2094 | 73 | PROPCMDLINE := $(subst _SPACE_, $(SPACE), $(join $(addprefix -compile_SPACE_, $(PROPSOURCES)), \ |
ihse@2094 | 74 | $(addsuffix _SPACE_java.util.ListResourceBundle, $(addprefix _SPACE_$(LANGTOOLS_OUTPUTDIR)/gensrc/, $(addsuffix .java, $(PROPPATHS)))))) |
ohair@1369 | 75 | |
ohair@1369 | 76 | # Now setup the rule for the generation of the resource bundles. |
ihse@2094 | 77 | $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d: $(PROPSOURCES) $(BUILD_TOOLS) |
erikj@1766 | 78 | $(RM) -r $(@D)/* |
erikj@1766 | 79 | $(MKDIR) -p $(@D) $(PROPDIRS) |
erikj@1766 | 80 | $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties |
erikj@1766 | 81 | $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties |
erikj@1766 | 82 | $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties |
erikj@1766 | 83 | $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties |
kizune@2198 | 84 | $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties |
erikj@1766 | 85 | $(ECHO) Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles |
ohair@1369 | 86 | $(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \ |
ihse@2094 | 87 | -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \ |
ihse@2094 | 88 | $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.java \ |
ihse@2094 | 89 | java.util.ListResourceBundle \ |
ihse@2094 | 90 | -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties \ |
ihse@2094 | 91 | $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.java \ |
ihse@2094 | 92 | java.util.ListResourceBundle \ |
ihse@2094 | 93 | -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \ |
ihse@2094 | 94 | $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \ |
ihse@2094 | 95 | java.util.ListResourceBundle \ |
ihse@2094 | 96 | -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties \ |
ihse@2094 | 97 | $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.java \ |
kizune@2198 | 98 | java.util.ListResourceBundle \ |
kizune@2198 | 99 | -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties \ |
kizune@2198 | 100 | $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.java \ |
ihse@2094 | 101 | java.util.ListResourceBundle |
ihse@2094 | 102 | $(ECHO) PROPS_ARE_CREATED = yes > $@ |
ohair@1369 | 103 | |
ohair@1369 | 104 | # Trigger the generation of the resource bundles. After the resource bundles have |
ohair@1369 | 105 | # been compiled, then the makefile will restart and the newly created java files |
ohair@1369 | 106 | # will become part of the build further along in the makefile. |
ohair@1369 | 107 | -include $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d |
ohair@1369 | 108 | |
ihse@2094 | 109 | ifeq ($(PROPS_ARE_CREATED), yes) |
ihse@2094 | 110 | # Setup the rules to build a dist/bootstrap/lib/javac.jar, ie a smaller intermediate javac |
ihse@2094 | 111 | # that can be compiled with an old javac. The intermediate javac is then used |
ihse@2094 | 112 | # to compile javac again and to build the complete new jdk. |
ihse@2094 | 113 | $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_LANGTOOLS, \ |
ihse@2094 | 114 | SETUP := BOOT_JAVAC, \ |
ihse@2094 | 115 | DISABLE_SJAVAC := true, \ |
ihse@2094 | 116 | SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc, \ |
ihse@2094 | 117 | EXCLUDES := com/sun/tools/javac/nio, \ |
ihse@2094 | 118 | COPY := $(RESOURCE_SUFFIXES), \ |
ihse@2094 | 119 | BIN := $(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap)) |
ohair@1369 | 120 | |
ihse@2094 | 121 | $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAC, $(BUILD_BOOTSTRAP_LANGTOOLS), \ |
ihse@2094 | 122 | SRCS := $(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap, \ |
ihse@2094 | 123 | JAR := $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar, \ |
ihse@2094 | 124 | SUFFIXES := .class $(RESOURCE_SUFFIXES))) |
ohair@1369 | 125 | |
ihse@2094 | 126 | # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not |
ihse@2094 | 127 | # yet built. It is currently not needed but might be again in the future. The following |
ihse@2094 | 128 | # exercises the functionality to verify that it works. |
ihse@2094 | 129 | TOOL_GENSTUBS_CMD = $(JAVA) \ |
ihse@2094 | 130 | "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \ |
ihse@2094 | 131 | -classpath $(LANGTOOLS_OUTPUTDIR)/btclasses \ |
ihse@2094 | 132 | genstubs.GenStubs |
ohair@1369 | 133 | |
ihse@2094 | 134 | # We fetch source from the JDK... |
ihse@2094 | 135 | JDKS = $(JDK_TOPDIR)/src/share/classes |
ohair@1369 | 136 | |
ihse@2094 | 137 | # Build the list of classes to generate stubs from. java/util/function/Predicate.java isn't |
ihse@2094 | 138 | # currently needed, but is used as a demo for now. |
ohair@1369 | 139 | |
ihse@2094 | 140 | STUBSOURCES := $(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \ |
ihse@2094 | 141 | -e "$(JDKS)/java/util/function/Predicate.java") |
ohair@1369 | 142 | |
ihse@2094 | 143 | # Rewrite the file names into class names because the GenStubs tool require this. |
ihse@2094 | 144 | STUBCLASSES := $(subst /,., $(patsubst $(JDKS)/%.java, %, $(STUBSOURCES))) |
ohair@1369 | 145 | |
ihse@2094 | 146 | # Now setup the build recipe for genstubs. |
ihse@2094 | 147 | $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d: $(STUBSOURCES) $(BUILD_TOOLS) \ |
ihse@2094 | 148 | $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ |
ihse@2094 | 149 | $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d |
ihse@2094 | 150 | $(MKDIR) -p $(@D) |
ihse@2094 | 151 | $(MKDIR) -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs |
ihse@2094 | 152 | $(ECHO) $(LOG_INFO) Generating stubs from JDK sources. |
ihse@2094 | 153 | ($(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES) && $(ECHO) STUBS_ARE_CREATED = yes > $@) |
ihse@2094 | 154 | if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs > /dev/null 2>&1; then \ |
ihse@2094 | 155 | $(ECHO) $(LOG_INFO) No changes in the stubs!; \ |
ihse@2094 | 156 | $(RM) -r $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \ |
ihse@2094 | 157 | else \ |
ihse@2094 | 158 | $(ECHO) $(LOG_INFO) Changes in stubs detected!; \ |
ihse@2094 | 159 | $(RM) -r $(@D); \ |
ihse@2094 | 160 | $(MV) $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \ |
ihse@2094 | 161 | fi |
ihse@2094 | 162 | $(ECHO) STUBS_ARE_CREATED = yes > $@ |
ohair@1369 | 163 | |
ihse@2094 | 164 | # Trigger a generation of the genstubs java source code and a restart |
ihse@2094 | 165 | # of the makefile to make sure that the following build setup use the |
ihse@2094 | 166 | # newly created java files. |
ihse@2094 | 167 | -include $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d |
ohair@1369 | 168 | |
ihse@2094 | 169 | ifeq ($(STUBS_ARE_CREATED), yes) |
ihse@2094 | 170 | # Setup a compiler configuration using the intermediate javac in dist/bootstrap/lib/javac.jar |
ihse@2094 | 171 | # that generates code for the new jdk that is being built. |
ihse@2094 | 172 | # The code compiled by this compiler setup, cannot necessarily be run with the bootstrap jvm. |
ihse@2094 | 173 | $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE, \ |
ihse@2094 | 174 | JVM := $(JAVA), \ |
ihse@2094 | 175 | JAVAC := "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \ |
ihse@2094 | 176 | -cp $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ |
ihse@2094 | 177 | com.sun.tools.javac.Main, \ |
ihse@2094 | 178 | FLAGS := -XDignore.symbol.file=true -Xlint:all$(COMMA)-deprecation -Werror, \ |
ihse@2094 | 179 | SERVER_DIR := $(SJAVAC_SERVER_DIR), \ |
ihse@2094 | 180 | SERVER_JVM := $(SJAVAC_SERVER_JAVA))) |
ohair@1369 | 181 | |
ihse@2094 | 182 | $(eval $(call SetupJavaCompilation,BUILD_FULL_JAVAC, \ |
ihse@2094 | 183 | SETUP := GENERATE_NEWBYTECODE, \ |
ihse@2094 | 184 | SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc \ |
ihse@2094 | 185 | $(LANGTOOLS_OUTPUTDIR)/genstubs, \ |
ihse@2094 | 186 | EXCLUDES := java/util java/io java/nio, \ |
ihse@2094 | 187 | COPY := $(RESOURCE_SUFFIXES), \ |
ihse@2094 | 188 | BIN := $(LANGTOOLS_OUTPUTDIR)/classes)) |
ihse@2094 | 189 | |
ihse@2094 | 190 | $(eval $(call SetupArchive,ARCHIVE_FULL_JAVAC, $(BUILD_FULL_JAVAC), \ |
ihse@2094 | 191 | SETUP := GENERATE_NEWBYTECODE, \ |
ihse@2094 | 192 | SRCS := $(LANGTOOLS_OUTPUTDIR)/classes, \ |
ihse@2094 | 193 | SUFFIXES := .class $(RESOURCE_SUFFIXES), \ |
ihse@2094 | 194 | JAR := $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar)) |
ihse@2094 | 195 | |
ihse@2094 | 196 | $(eval $(call SetupZipArchive,ZIP_FULL_JAVAC_SOURCE, \ |
ihse@2094 | 197 | SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc, \ |
ihse@2094 | 198 | ZIP := $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip)) |
ihse@2094 | 199 | |
ihse@2094 | 200 | all: $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar \ |
ihse@2094 | 201 | $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip \ |
ihse@2094 | 202 | $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar |
ihse@2094 | 203 | |
ihse@2094 | 204 | endif |
ohair@1369 | 205 | endif |