makefiles/Makefile

changeset 1369
741cce355ba6
parent 1318
463fea75b618
child 2094
343aeb2033f0
equal deleted inserted replaced
1355:b47bb81ba962 1369:741cce355ba6
1 # 1 #
2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 2 # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 # 4 #
5 # This code is free software; you can redistribute it and/or modify it 5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as 6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation. Oracle designates this 7 # published by the Free Software Foundation. Oracle designates this
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any 22 # or visit www.oracle.com if you need additional information or have any
23 # questions. 23 # questions.
24 # 24 #
25 25
26 # This must be the first rule 26 # Locate this Makefile
27 default: all 27 ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
28 makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
29 else
30 makefile_path:=$(lastword $(MAKEFILE_LIST))
31 endif
32 repo_dir:=$(patsubst %/makefiles/Makefile,%,$(makefile_path))
28 33
29 include $(SPEC) 34 # What is the name of this subsystem (langtools, corba, etc)?
30 include MakeBase.gmk 35 subsystem_name:=$(notdir $(repo_dir))
31 include JavaCompilation.gmk
32 36
33 # The BOOT_JAVAC setup uses the bootdir compiler to compile the tools 37 # Try to locate top-level makefile
34 # and the bootstrap javac, to be run by the bootdir jvm. 38 top_level_makefile:=$(repo_dir)/../common/makefiles/Makefile
35 $(eval $(call SetupJavaCompiler,BOOT_JAVAC,\ 39 ifneq ($(wildcard $(top_level_makefile)),)
36 JAVAC:=$(JAVAC),\ 40 $(info Will run $(subsystem_name) target on top-level Makefile)
37 SERVER_DIR:=$(SJAVAC_SERVER_DIR),\ 41 $(info WARNING: This is a non-recommended way of building!)
38 SERVER_JVM:=$(SJAVAC_SERVER_JAVA),\ 42 $(info ===================================================)
39 FLAGS:=-XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror)) 43 else
44 $(info Cannot locate top-level Makefile. Is this repo not checked out as part of a complete forest?)
45 $(error Build from top-level Makefile instead)
46 endif
40 47
41 # Now setup the compilation of the properties compilation tool. You can depend 48 all:
42 # upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we 49 @$(MAKE) -f $(top_level_makefile) $(subsystem_name)
43 # add src/share/classes to the sourcepath. This is necessary since the GenStubs
44 # program needs to be linked and run towards the new javac sources.
45 $(eval $(call SetupJavaCompilation,BUILD_TOOLS,\
46 SETUP:=BOOT_JAVAC,\
47 DISABLE_SJAVAC:=true,\
48 ADD_JAVAC_FLAGS:=-Xprefer:source,\
49 SRC:=$(LANGTOOLS_TOPDIR)/make/tools $(LANGTOOLS_TOPDIR)/src/share/classes,\
50 INCLUDES:=compileproperties genstubs,\
51 BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses))
52
53 # The compileprops tools compiles a properties file into a resource bundle.
54 TOOL_COMPILEPROPS_CMD:=$(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/btclasses compileproperties.CompileProperties -quiet
55 # Lookup the properties that need to be compiled into resource bundles.
56 PROPSOURCES:=$(shell find $(LANGTOOLS_TOPDIR)/src/share/classes -name "*.properties")
57 # Strip away prefix and suffix, leaving for example only: "com/sun/tools/javac/resources/javac_zh_CN"
58 PROPPATHS:=$(patsubst $(LANGTOOLS_TOPDIR)/src/share/classes/%.properties,%,$(PROPSOURCES))
59 # Generate the list of java files to be created.
60 PROPJAVAS:=$(patsubst %,$(LANGTOOLS_OUTPUTDIR)/gensrc/%.java,$(PROPPATHS))
61 # Generate the package dirs for the tobe generated java files.
62 PROPDIRS:=$(dir $(PROPJAVAS))
63 # Now generate a sequence of "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle"
64 # suitable to be fed into the CompileProperties command.
65 PROPCMDLINE:=$(subst _SPACE_,$(SPACE),$(join $(addprefix -compile_SPACE_,$(PROPSOURCES)), \
66 $(addsuffix _SPACE_java.util.ListResourceBundle,$(addprefix _SPACE_$(LANGTOOLS_OUTPUTDIR)/gensrc/,$(addsuffix .java,$(PROPPATHS))))))
67
68 # Now setup the rule for the generation of the resource bundles.
69 $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d : $(PROPSOURCES) $(BUILD_TOOLS)
70 rm -rf $(@D)/*
71 mkdir -p $(@D) $(PROPDIRS)
72 printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties
73 printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties
74 printf "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties
75 echo Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles
76 $(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \
77 -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \
78 $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.java \
79 java.util.ListResourceBundle \
80 -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties \
81 $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.java \
82 java.util.ListResourceBundle \
83 -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \
84 $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \
85 java.util.ListResourceBundle
86 echo PROPS_ARE_CREATED=yes > $@
87
88 # Trigger the generation of the resource bundles. After the resource bundles have
89 # been compiled, then the makefile will restart and the newly created java files
90 # will become part of the build further along in the makefile.
91 -include $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d
92
93 ifeq ($(PROPS_ARE_CREATED),yes)
94 # Setup the rules to build a dist/bootstrap/lib/javac.jar, ie a smaller intermediate javac
95 # that can be compiled with an old javac. The intermediate javac is then used
96 # to compile javac again and to build the complete new jdk.
97 $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_LANGTOOLS,\
98 SETUP:=BOOT_JAVAC,\
99 DISABLE_SJAVAC:=true,\
100 SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\
101 EXCLUDES:=com/sun/tools/javac/nio,\
102 BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap))
103
104 $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAC,$(BUILD_BOOTSTRAP_LANGTOOLS),\
105 SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\
106 JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar,\
107 JARMAIN:=com.sun.tools.javac.Main))
108
109 $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAH,$(BUILD_BOOTSTRAP_LANGTOOLS),\
110 SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\
111 JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javah.jar,\
112 JARMAIN:=com.sun.tools.javah.Main))
113
114 $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAP,$(BUILD_BOOTSTRAP_LANGTOOLS),\
115 SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\
116 JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javap.jar,\
117 JARMAIN:=com.sun.tools.javap.Main))
118
119 $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVADOC,$(BUILD_BOOTSTRAP_LANGTOOLS),\
120 SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\
121 JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javadoc.jar,\
122 JARMAIN:=com.sun.tools.javadoc.Main))
123
124 # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not
125 # yet built. It is currently not needed but might be again in the future. The following
126 # exercises the functionality to verify that it works.
127 TOOL_GENSTUBS_CMD=$(JAVA) \
128 "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
129 -classpath $(LANGTOOLS_OUTPUTDIR)/btclasses \
130 genstubs.GenStubs
131 # We fetch source from the JDK...
132 JDKS=$(JDK_TOPDIR)/src/share/classes
133 # Build the list of classes to generate stubs from. java/util/Objects.java isn't
134 # currently needed, but is used as a demo for now.
135 STUBSOURCES:=$(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \
136 -e "$(JDKS)/java/util/Objects.java")
137 # Rewrite the file names into class names because the GenStubs tool require this.
138 STUBCLASSES:=$(subst /,.,$(patsubst $(JDKS)/%.java,%,$(STUBSOURCES)))
139
140 # Now setup the build recipe for genstubs.
141 $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d : $(STUBSOURCES) $(BUILD_TOOLS) \
142 $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
143 $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d
144 mkdir -p $(@D)
145 mkdir -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs
146 echo Generating stubs from JDK sources.
147 ($(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES) && echo STUBS_ARE_CREATED=yes > $@)
148 if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs > /dev/null 2>&1; then \
149 echo No changes in the stubs!; \
150 rm -rf $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \
151 else \
152 echo Changes in stubs detected!; \
153 rm -rf $(@D); \
154 mv $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \
155 fi
156 echo STUBS_ARE_CREATED=yes > $@
157
158 # Trigger a generation of the genstubs java source code and a restart
159 # of the makefile to make sure that the following build setup use the
160 # newly created java files.
161 -include $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d
162
163 ifeq ($(STUBS_ARE_CREATED),yes)
164 # Setup a compiler configuration using the intermediate javac in dist/bootstrap/lib/javac.jar
165 # that generates code for the new jdk that is being built.
166 # The code compiled by this compiler setup, cannot necessarily be run with the bootstrap jvm.
167 $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE,\
168 JVM:=$(JAVA),\
169 JAVAC:="-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
170 -jar $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar,\
171 FLAGS:=-XDignore.symbol.file=true -Xlint:all$(COMMA)-deprecation -Werror,\
172 SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
173 SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
174
175 # javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied.
176 RESOURCE_SUFFIXES:=.gif .xml .css javax.tools.JavaCompilerTool
177
178 $(eval $(call SetupJavaCompilation,BUILD_FULL_JAVAC,\
179 SETUP:=GENERATE_NEWBYTECODE,\
180 SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc \
181 $(LANGTOOLS_OUTPUTDIR)/genstubs,\
182 EXCLUDES:=java/util java/io java/nio,\
183 COPY:=$(RESOURCE_SUFFIXES),\
184 BIN:=$(LANGTOOLS_OUTPUTDIR)/classes))
185
186 $(eval $(call SetupArchive,ARCHIVE_FULL_JAVAC,$(BUILD_FULL_JAVAC),\
187 SETUP:=GENERATE_NEWBYTECODE,\
188 SRCS:=$(LANGTOOLS_OUTPUTDIR)/classes,\
189 SUFFIXES:=.class $(RESOURCE_SUFFIXES),\
190 JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar))
191
192 $(eval $(call SetupZipArchive,ZIP_FULL_JAVAC_SOURCE,\
193 SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\
194 ZIP:=$(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip))
195
196 all: $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar \
197 $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip \
198 $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
199 $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javah.jar \
200 $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javap.jar \
201 $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javadoc.jar
202
203
204 endif
205 endif

mercurial