1.1 --- a/makefiles/Makefile Thu Oct 18 11:09:45 2012 -0700 1.2 +++ b/makefiles/Makefile Fri Oct 26 14:25:52 2012 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 # 1.5 -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 1.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 # 1.9 # This code is free software; you can redistribute it and/or modify it 1.10 @@ -23,183 +23,27 @@ 1.11 # questions. 1.12 # 1.13 1.14 -# This must be the first rule 1.15 -default: all 1.16 +# Locate this Makefile 1.17 +ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),) 1.18 + makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST)) 1.19 +else 1.20 + makefile_path:=$(lastword $(MAKEFILE_LIST)) 1.21 +endif 1.22 +repo_dir:=$(patsubst %/makefiles/Makefile,%,$(makefile_path)) 1.23 1.24 -include $(SPEC) 1.25 -include MakeBase.gmk 1.26 -include JavaCompilation.gmk 1.27 +# What is the name of this subsystem (langtools, corba, etc)? 1.28 +subsystem_name:=$(notdir $(repo_dir)) 1.29 1.30 -# The BOOT_JAVAC setup uses the bootdir compiler to compile the tools 1.31 -# and the bootstrap javac, to be run by the bootdir jvm. 1.32 -$(eval $(call SetupJavaCompiler,BOOT_JAVAC,\ 1.33 - JAVAC:=$(JAVAC),\ 1.34 - SERVER_DIR:=$(SJAVAC_SERVER_DIR),\ 1.35 - SERVER_JVM:=$(SJAVAC_SERVER_JAVA),\ 1.36 - FLAGS:=-XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror)) 1.37 +# Try to locate top-level makefile 1.38 +top_level_makefile:=$(repo_dir)/../common/makefiles/Makefile 1.39 +ifneq ($(wildcard $(top_level_makefile)),) 1.40 + $(info Will run $(subsystem_name) target on top-level Makefile) 1.41 + $(info WARNING: This is a non-recommended way of building!) 1.42 + $(info ===================================================) 1.43 +else 1.44 + $(info Cannot locate top-level Makefile. Is this repo not checked out as part of a complete forest?) 1.45 + $(error Build from top-level Makefile instead) 1.46 +endif 1.47 1.48 -# Now setup the compilation of the properties compilation tool. You can depend 1.49 -# upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we 1.50 -# add src/share/classes to the sourcepath. This is necessary since the GenStubs 1.51 -# program needs to be linked and run towards the new javac sources. 1.52 -$(eval $(call SetupJavaCompilation,BUILD_TOOLS,\ 1.53 - SETUP:=BOOT_JAVAC,\ 1.54 - DISABLE_SJAVAC:=true,\ 1.55 - ADD_JAVAC_FLAGS:=-Xprefer:source,\ 1.56 - SRC:=$(LANGTOOLS_TOPDIR)/make/tools $(LANGTOOLS_TOPDIR)/src/share/classes,\ 1.57 - INCLUDES:=compileproperties genstubs,\ 1.58 - BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses)) 1.59 - 1.60 -# The compileprops tools compiles a properties file into a resource bundle. 1.61 -TOOL_COMPILEPROPS_CMD:=$(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/btclasses compileproperties.CompileProperties -quiet 1.62 -# Lookup the properties that need to be compiled into resource bundles. 1.63 -PROPSOURCES:=$(shell find $(LANGTOOLS_TOPDIR)/src/share/classes -name "*.properties") 1.64 -# Strip away prefix and suffix, leaving for example only: "com/sun/tools/javac/resources/javac_zh_CN" 1.65 -PROPPATHS:=$(patsubst $(LANGTOOLS_TOPDIR)/src/share/classes/%.properties,%,$(PROPSOURCES)) 1.66 -# Generate the list of java files to be created. 1.67 -PROPJAVAS:=$(patsubst %,$(LANGTOOLS_OUTPUTDIR)/gensrc/%.java,$(PROPPATHS)) 1.68 -# Generate the package dirs for the tobe generated java files. 1.69 -PROPDIRS:=$(dir $(PROPJAVAS)) 1.70 -# Now generate a sequence of "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle" 1.71 -# suitable to be fed into the CompileProperties command. 1.72 -PROPCMDLINE:=$(subst _SPACE_,$(SPACE),$(join $(addprefix -compile_SPACE_,$(PROPSOURCES)), \ 1.73 - $(addsuffix _SPACE_java.util.ListResourceBundle,$(addprefix _SPACE_$(LANGTOOLS_OUTPUTDIR)/gensrc/,$(addsuffix .java,$(PROPPATHS)))))) 1.74 - 1.75 -# Now setup the rule for the generation of the resource bundles. 1.76 -$(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d : $(PROPSOURCES) $(BUILD_TOOLS) 1.77 - rm -rf $(@D)/* 1.78 - mkdir -p $(@D) $(PROPDIRS) 1.79 - printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties 1.80 - printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties 1.81 - printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties 1.82 - echo Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles 1.83 - $(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \ 1.84 - -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \ 1.85 - $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.java \ 1.86 - java.util.ListResourceBundle \ 1.87 - -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties \ 1.88 - $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.java \ 1.89 - java.util.ListResourceBundle \ 1.90 - -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \ 1.91 - $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \ 1.92 - java.util.ListResourceBundle 1.93 - echo PROPS_ARE_CREATED=yes > $@ 1.94 - 1.95 -# Trigger the generation of the resource bundles. After the resource bundles have 1.96 -# been compiled, then the makefile will restart and the newly created java files 1.97 -# will become part of the build further along in the makefile. 1.98 --include $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d 1.99 - 1.100 -ifeq ($(PROPS_ARE_CREATED),yes) 1.101 - # Setup the rules to build a dist/bootstrap/lib/javac.jar, ie a smaller intermediate javac 1.102 - # that can be compiled with an old javac. The intermediate javac is then used 1.103 - # to compile javac again and to build the complete new jdk. 1.104 - $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_LANGTOOLS,\ 1.105 - SETUP:=BOOT_JAVAC,\ 1.106 - DISABLE_SJAVAC:=true,\ 1.107 - SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\ 1.108 - EXCLUDES:=com/sun/tools/javac/nio,\ 1.109 - BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap)) 1.110 - 1.111 - $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAC,$(BUILD_BOOTSTRAP_LANGTOOLS),\ 1.112 - SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ 1.113 - JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar,\ 1.114 - JARMAIN:=com.sun.tools.javac.Main)) 1.115 - 1.116 - $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAH,$(BUILD_BOOTSTRAP_LANGTOOLS),\ 1.117 - SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ 1.118 - JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javah.jar,\ 1.119 - JARMAIN:=com.sun.tools.javah.Main)) 1.120 - 1.121 - $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAP,$(BUILD_BOOTSTRAP_LANGTOOLS),\ 1.122 - SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ 1.123 - JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javap.jar,\ 1.124 - JARMAIN:=com.sun.tools.javap.Main)) 1.125 - 1.126 - $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVADOC,$(BUILD_BOOTSTRAP_LANGTOOLS),\ 1.127 - SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\ 1.128 - JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javadoc.jar,\ 1.129 - JARMAIN:=com.sun.tools.javadoc.Main)) 1.130 - 1.131 - # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not 1.132 - # yet built. It is currently not needed but might be again in the future. The following 1.133 - # exercises the functionality to verify that it works. 1.134 - TOOL_GENSTUBS_CMD=$(JAVA) \ 1.135 - "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \ 1.136 - -classpath $(LANGTOOLS_OUTPUTDIR)/btclasses \ 1.137 - genstubs.GenStubs 1.138 - # We fetch source from the JDK... 1.139 - JDKS=$(JDK_TOPDIR)/src/share/classes 1.140 - # Build the list of classes to generate stubs from. java/util/Objects.java isn't 1.141 - # currently needed, but is used as a demo for now. 1.142 - STUBSOURCES:=$(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \ 1.143 - -e "$(JDKS)/java/util/Objects.java") 1.144 - # Rewrite the file names into class names because the GenStubs tool require this. 1.145 - STUBCLASSES:=$(subst /,.,$(patsubst $(JDKS)/%.java,%,$(STUBSOURCES))) 1.146 - 1.147 - # Now setup the build recipe for genstubs. 1.148 - $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d : $(STUBSOURCES) $(BUILD_TOOLS) \ 1.149 - $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ 1.150 - $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d 1.151 - mkdir -p $(@D) 1.152 - mkdir -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs 1.153 - echo Generating stubs from JDK sources. 1.154 - ($(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES) && echo STUBS_ARE_CREATED=yes > $@) 1.155 - if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs > /dev/null 2>&1; then \ 1.156 - echo No changes in the stubs!; \ 1.157 - rm -rf $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \ 1.158 - else \ 1.159 - echo Changes in stubs detected!; \ 1.160 - rm -rf $(@D); \ 1.161 - mv $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \ 1.162 - fi 1.163 - echo STUBS_ARE_CREATED=yes > $@ 1.164 - 1.165 - # Trigger a generation of the genstubs java source code and a restart 1.166 - # of the makefile to make sure that the following build setup use the 1.167 - # newly created java files. 1.168 - -include $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d 1.169 - 1.170 - ifeq ($(STUBS_ARE_CREATED),yes) 1.171 - # Setup a compiler configuration using the intermediate javac in dist/bootstrap/lib/javac.jar 1.172 - # that generates code for the new jdk that is being built. 1.173 - # The code compiled by this compiler setup, cannot necessarily be run with the bootstrap jvm. 1.174 - $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE,\ 1.175 - JVM:=$(JAVA),\ 1.176 - JAVAC:="-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \ 1.177 - -jar $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar,\ 1.178 - FLAGS:=-XDignore.symbol.file=true -Xlint:all$(COMMA)-deprecation -Werror,\ 1.179 - SERVER_DIR:=$(SJAVAC_SERVER_DIR),\ 1.180 - SERVER_JVM:=$(SJAVAC_SERVER_JAVA))) 1.181 - 1.182 - # javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied. 1.183 - RESOURCE_SUFFIXES:=.gif .xml .css javax.tools.JavaCompilerTool 1.184 - 1.185 - $(eval $(call SetupJavaCompilation,BUILD_FULL_JAVAC,\ 1.186 - SETUP:=GENERATE_NEWBYTECODE,\ 1.187 - SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc \ 1.188 - $(LANGTOOLS_OUTPUTDIR)/genstubs,\ 1.189 - EXCLUDES:=java/util java/io java/nio,\ 1.190 - COPY:=$(RESOURCE_SUFFIXES),\ 1.191 - BIN:=$(LANGTOOLS_OUTPUTDIR)/classes)) 1.192 - 1.193 - $(eval $(call SetupArchive,ARCHIVE_FULL_JAVAC,$(BUILD_FULL_JAVAC),\ 1.194 - SETUP:=GENERATE_NEWBYTECODE,\ 1.195 - SRCS:=$(LANGTOOLS_OUTPUTDIR)/classes,\ 1.196 - SUFFIXES:=.class $(RESOURCE_SUFFIXES),\ 1.197 - JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar)) 1.198 - 1.199 - $(eval $(call SetupZipArchive,ZIP_FULL_JAVAC_SOURCE,\ 1.200 - SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\ 1.201 - ZIP:=$(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip)) 1.202 - 1.203 - all: $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar \ 1.204 - $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip \ 1.205 - $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ 1.206 - $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javah.jar \ 1.207 - $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javap.jar \ 1.208 - $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javadoc.jar 1.209 - 1.210 - 1.211 - endif 1.212 -endif 1.213 +all: 1.214 + @$(MAKE) -f $(top_level_makefile) $(subsystem_name)