CompileJavaModules.gmk revision 1203:5673f89cd541
1#
2# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
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
7# published by the Free Software Foundation.  Oracle designates this
8# particular file as subject to the "Classpath" exception as provided
9# by Oracle in the LICENSE file that accompanied this code.
10#
11# This code is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14# version 2 for more details (a copy is included in the LICENSE file that
15# accompanied this code).
16#
17# You should have received a copy of the GNU General Public License version
18# 2 along with this work; if not, write to the Free Software Foundation,
19# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20#
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
23# questions.
24#
25
26# This must be the first rule
27default: all
28
29include $(SPEC)
30include MakeBase.gmk
31include Modules.gmk
32include JavaCompilation.gmk
33include SetupJavaCompilers.gmk
34
35# Hook to include the corresponding custom file, if present.
36$(eval $(call IncludeCustomExtension, , CompileJavaModules.gmk))
37
38################################################################################
39# Module specific build settings
40
41java.activation_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
42
43################################################################################
44
45java.base_COPY := .icu .dat .spp content-types.properties
46java.base_CLEAN := intrinsic.properties
47
48java.base_EXCLUDES += java/lang/doc-files
49
50# Exclude BreakIterator classes that are just used in compile process to generate
51# data files and shouldn't go in the product
52java.base_EXCLUDE_FILES += sun/text/resources/BreakIteratorRules.java
53
54ifeq ($(OPENJDK_TARGET_OS), macosx)
55  JAVA_BASE_UNIX_DIR := $(JDK_TOPDIR)/src/java.base/unix/classes
56  # TODO: make JavaCompilation handle overrides automatically instead of excluding here
57  # These files are overridden in macosx
58  java.base_EXCLUDE_FILES += \
59      $(JAVA_BASE_UNIX_DIR)/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java \
60      $(JAVA_BASE_UNIX_DIR)/java/net/DefaultInterface.java \
61      $(JAVA_BASE_UNIX_DIR)/java/lang/ClassLoaderHelper.java \
62      $(JAVA_BASE_UNIX_DIR)/sun/nio/ch/DefaultSelectorProvider.java \
63      #
64  # This is just skipped on macosx
65  java.base_EXCLUDE_FILES += $(JAVA_BASE_UNIX_DIR)/sun/nio/fs/GnomeFileTypeDetector.java
66endif
67
68ifneq ($(OPENJDK_TARGET_OS), solaris)
69  java.base_EXCLUDE_FILES += \
70      SolarisLoginModule.java \
71      SolarisSystem.java \
72      #
73endif
74
75ifeq ($(filter $(OPENJDK_TARGET_OS), solaris macosx aix), )
76  #
77  # only solaris, macosx and aix
78  #
79  java.base_EXCLUDE_FILES += sun/nio/fs/PollingWatchService.java
80endif
81
82ifeq ($(OPENJDK_TARGET_OS), windows)
83  java.base_EXCLUDE_FILES += \
84      sun/nio/ch/AbstractPollSelectorImpl.java \
85      sun/nio/ch/PollSelectorProvider.java \
86      sun/nio/ch/SimpleAsynchronousFileChannelImpl.java \
87      #
88endif
89
90################################################################################
91
92java.desktop_COPY := .gif .png .wav .txt .xml .css flavormap.properties .pf
93java.desktop_CLEAN := iio-plugin.properties
94
95java.desktop_EXCLUDES += \
96    java/awt/doc-files \
97    javax/swing/doc-files \
98    javax/swing/text/doc-files \
99    javax/swing/plaf/synth/doc-files \
100    javax/swing/undo/doc-files \
101    sun/awt/X11/doc-files \
102    #
103
104# The exception handling of swing beaninfo
105# These resources violates the convention of having code and resources together under
106# $(JDK_TOPDIR)/src/.../classes directories
107$(eval $(call SetupCopyFiles,COPY_BEANINFO, \
108    SRC := $(JDK_TOPDIR)/make/data/swingbeaninfo/images, \
109    DEST := $(JDK_OUTPUTDIR)/modules/java.desktop/javax/swing/beaninfo/images, \
110    FILES := $(wildcard $(JDK_TOPDIR)/make/data/swingbeaninfo/images/*.gif)))
111
112java.desktop_COPY_EXTRA += $(COPY_BEANINFO)
113
114java.desktop_EXCLUDE_FILES += \
115    javax/swing/plaf/nimbus/InternalFrameTitlePanePainter.java \
116    javax/swing/plaf/nimbus/OptionPaneMessageAreaPainter.java \
117    javax/swing/plaf/nimbus/ScrollBarPainter.java \
118    javax/swing/plaf/nimbus/SliderPainter.java \
119    javax/swing/plaf/nimbus/SpinnerPainter.java \
120    javax/swing/plaf/nimbus/SplitPanePainter.java \
121    javax/swing/plaf/nimbus/TabbedPanePainter.java \
122    sun/awt/resources/security-icon-bw16.png \
123    sun/awt/resources/security-icon-bw24.png \
124    sun/awt/resources/security-icon-bw32.png \
125    sun/awt/resources/security-icon-bw48.png \
126    sun/awt/resources/security-icon-interim16.png \
127    sun/awt/resources/security-icon-interim24.png \
128    sun/awt/resources/security-icon-interim32.png \
129    sun/awt/resources/security-icon-interim48.png \
130    sun/awt/resources/security-icon-yellow16.png \
131    sun/awt/resources/security-icon-yellow24.png \
132    sun/awt/resources/security-icon-yellow32.png \
133    sun/awt/resources/security-icon-yellow48.png \
134    sun/awt/X11/java-icon16.png \
135    sun/awt/X11/java-icon24.png \
136    sun/awt/X11/java-icon32.png \
137    sun/awt/X11/java-icon48.png \
138    .template \
139    #
140
141ifeq ($(OPENJDK_TARGET_OS), macosx)
142  # exclude all X11 on Mac.
143  java.desktop_EXCLUDES += sun/awt/X11
144  java.desktop_EXCLUDE_FILES += \
145      $(JDK_TOPDIR)/src/java.desktop/unix/classes/sun/java2d/BackBufferCapsProvider.java \
146      #
147else
148  # TBD: figure out how to eliminate this long list
149  java.desktop_EXCLUDE_FILES += \
150      sun/awt/X11/ScreenFormat.java \
151      sun/awt/X11/XArc.java \
152      sun/awt/X11/XChar2b.java \
153      sun/awt/X11/XCharStruct.java \
154      sun/awt/X11/XClassHint.java \
155      sun/awt/X11/XComposeStatus.java \
156      sun/awt/X11/XExtCodes.java \
157      sun/awt/X11/XFontProp.java \
158      sun/awt/X11/XFontSetExtents.java \
159      sun/awt/X11/XFontStruct.java \
160      sun/awt/X11/XGCValues.java \
161      sun/awt/X11/XHostAddress.java \
162      sun/awt/X11/XIMCallback.java \
163      sun/awt/X11/XIMHotKeyTrigger.java \
164      sun/awt/X11/XIMHotKeyTriggers.java \
165      sun/awt/X11/XIMPreeditCaretCallbackStruct.java \
166      sun/awt/X11/XIMPreeditDrawCallbackStruct.java \
167      sun/awt/X11/XIMPreeditStateNotifyCallbackStruct.java \
168      sun/awt/X11/XIMStatusDrawCallbackStruct.java \
169      sun/awt/X11/XIMStringConversionCallbackStruct.java \
170      sun/awt/X11/XIMStringConversionText.java \
171      sun/awt/X11/XIMStyles.java \
172      sun/awt/X11/XIMText.java \
173      sun/awt/X11/XIMValuesList.java \
174      sun/awt/X11/XImage.java \
175      sun/awt/X11/XKeyboardControl.java \
176      sun/awt/X11/XKeyboardState.java \
177      sun/awt/X11/XOMCharSetList.java \
178      sun/awt/X11/XOMFontInfo.java \
179      sun/awt/X11/XOMOrientation.java \
180      sun/awt/X11/XPoint.java \
181      sun/awt/X11/XRectangle.java \
182      sun/awt/X11/XSegment.java \
183      sun/awt/X11/XStandardColormap.java \
184      sun/awt/X11/XTextItem.java \
185      sun/awt/X11/XTextItem16.java \
186      sun/awt/X11/XTextProperty.java \
187      sun/awt/X11/XTimeCoord.java \
188      sun/awt/X11/XWindowChanges.java \
189      sun/awt/X11/XdbeSwapInfo.java \
190      sun/awt/X11/XmbTextItem.java \
191      sun/awt/X11/XwcTextItem.java
192endif
193
194ifeq ($(OPENJDK_TARGET_OS), windows)
195  java.desktop_EXCLUDES += com/sun/java/swing/plaf/gtk
196endif
197
198ifdef BUILD_HEADLESS_ONLY
199  java.desktop_EXCLUDES += sun/applet
200endif
201
202# Why is this in the open source tree?
203ifdef OPENJDK
204  java.desktop_EXCLUDES += sun/dc
205endif
206
207# Used on windows and macosx
208ifeq ($(filter $(OPENJDK_TARGET_OS), windows macosx), )
209  java.desktop_EXCLUDE_FILES += sun/awt/AWTCharset.java
210endif
211
212# These files do not appear in the build result of the old build. This
213# is because they are generated sources, but the AUTO_JAVA_FILES won't
214# pick them up since they aren't generated when the source dirs are
215# searched and they aren't referenced by any other classes so they won't
216# be picked up by implicit compilation. On a rebuild, they are picked up
217# and compiled. Exclude them here to produce the same rt.jar as the old
218# build does when building just once.
219java.desktop_EXCLUDE_FILES += \
220    javax/swing/plaf/nimbus/InternalFrameTitlePanePainter.java \
221    javax/swing/plaf/nimbus/OptionPaneMessageAreaPainter.java \
222    javax/swing/plaf/nimbus/ScrollBarPainter.java \
223    javax/swing/plaf/nimbus/SliderPainter.java \
224    javax/swing/plaf/nimbus/SpinnerPainter.java \
225    javax/swing/plaf/nimbus/SplitPanePainter.java \
226    javax/swing/plaf/nimbus/TabbedPanePainter.java \
227    #
228
229ifeq ($(OPENJDK_TARGET_OS), macosx)
230  # These files are duplicated in MACOSX_SRC_DIRS
231  java.desktop_EXCLUDE_FILES += \
232      $(JDK_TOPDIR)/src/java.desktop/unix/classes/sun/java2d/BackBufferCapsProvider.java \
233      #
234endif
235
236################################################################################
237
238java.sql_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
239
240################################################################################
241
242java.sql.rowset_CLEAN_FILES := $(wildcard \
243    $(JDK_TOPDIR)/src/java.sql.rowset/share/classes/com/sun/rowset/*.properties \
244    $(JDK_TOPDIR)/src/java.sql.rowset/share/classes/javax/sql/rowset/*.properties)
245
246################################################################################
247# Exclude building of IIOP transport for RMI Connector
248java.management_EXCLUDES := com/sun/jmx/remote/protocol/iiop
249
250ifeq ($(RMICONNECTOR_IIOP), false)
251  java.management_EXCLUDES += com/sun/jmx/remote/protocol/iiop
252endif
253
254################################################################################
255
256java.rmi_CLEAN_FILES := $(wildcard \
257    $(JDK_TOPDIR)/src/java.rmi/share/classes/sun/rmi/registry/resources/*.properties \
258    $(JDK_TOPDIR)/src/java.rmi/share/classes/sun/rmi/server/resources/*.properties)
259
260################################################################################
261
262java.corba_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
263
264java.corba_COPY := .prp
265java.corba_CLEAN := .properties
266
267java.corba_EXCLUDES := \
268    com/sun/corba/se/PortableActivationIDL \
269    com/sun/tools/corba/se/logutil \
270    #
271java.corba_EXCLUDE_FILES := \
272    com/sun/corba/se/impl/presentation/rmi/JNDIStateFactoryImpl.java \
273    com/sun/corba/se/spi/presentation/rmi/StubWrapper.java \
274    com/sun/org/omg/CORBA/IDLTypeOperations.java \
275    com/sun/org/omg/CORBA/IRObjectOperations.java \
276    org/omg/PortableInterceptor/UNKNOWN.java \
277    com/sun/tools/corba/se/idl/ResourceBundleUtil.java \
278    com/sun/corba/se/impl/presentation/rmi/jndi.properties \
279    #
280
281################################################################################
282
283java.xml_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
284java.xml_CLEAN := .properties
285
286################################################################################
287
288java.xml.bind_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
289java.xml.bind_CLEAN := .properties
290
291################################################################################
292
293java.xml.soap_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
294java.xml.soap_CLEAN := .properties
295
296################################################################################
297
298java.xml.ws_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
299java.xml.ws_COPY := .xml
300java.xml.ws_CLEAN := .properties
301
302################################################################################
303
304java.naming_CLEAN := jndiprovider.properties
305
306################################################################################
307
308java.security.saaj_CLEAN := .properties
309
310################################################################################
311
312java.xml.crypto_COPY := .dtd .xml
313java.xml.crypto_CLEAN := .properties
314
315################################################################################
316
317jdk.charsets_COPY := .dat
318
319################################################################################
320
321jdk.compiler_COPY := javax.tools.JavaCompilerTool
322
323################################################################################
324
325jdk.jcmd_COPY := _options 
326
327################################################################################
328
329jdk.javadoc_COPY := .xml .css .js
330
331################################################################################
332
333jdk.rmic_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
334jdk.rmic_CLEAN := .properties
335
336################################################################################
337
338# No SCTP implementation on Mac OS X or AIX. These classes should be excluded.
339SCTP_IMPL_CLASSES = \
340    $(JDK_TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/AssociationChange.java \
341    $(JDK_TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/AssociationImpl.java \
342    $(JDK_TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/PeerAddrChange.java \
343    $(JDK_TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/ResultContainer.java \
344    $(JDK_TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpChannelImpl.java \
345    $(JDK_TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java \
346    $(JDK_TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java \
347    $(JDK_TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNotification.java \
348    $(JDK_TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java \
349    $(JDK_TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SendFailed.java \
350    $(JDK_TOPDIR)/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/Shutdown.java
351
352ifeq ($(OPENJDK_TARGET_OS), macosx)
353  jdk.sctp_EXCLUDE_FILES := $(SCTP_IMPL_CLASSES)
354endif
355
356ifeq ($(OPENJDK_TARGET_OS),aix)
357  # These files are duplicated in AIX_SRC_DIRS
358  jdk.sctp_EXCLUDE_FILES := $(SCTP_IMPL_CLASSES)
359endif
360
361################################################################################
362
363jdk.jconsole_COPY := .gif .png
364
365jdk.jconsole_CLEAN_FILES := $(wildcard \
366    $(JDK_TOPDIR)/src/jdk.jconsole/share/classes/sun/tools/jconsole/resources/*.properties)
367
368################################################################################
369
370jdk.compiler_CLEAN_FILES := $(wildcard \
371    $(patsubst %, $(JDK_TOPDIR)/src/jdk.compiler/share/classes/%/*.properties, \
372        sun/tools/serialver/resources))
373
374################################################################################
375
376jdk.jdi_EXCLUDES := \
377    com/sun/tools/example/debug/bdi \
378    com/sun/tools/example/debug/event \
379    com/sun/tools/example/debug/gui \
380    com/sun/jdi/doc-files \
381    #
382
383jdk.jdi_EXCLUDE_FILES += jdi-overview.html
384
385################################################################################
386
387jdk.dev_CLEAN_FILES := $(wildcard \
388    $(patsubst %, $(JDK_TOPDIR)/src/jdk.dev/share/classes/%/*.properties, \
389        com/sun/tools/script/shell))
390
391jdk.dev_COPY := .js oqlhelp.html .txt
392
393################################################################################
394
395jdk.jvmstat_COPY := aliasmap
396
397################################################################################
398
399jdk.xml.bind_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
400jdk.xml.bind_CLEAN := .properties
401jdk.xml.bind_COPY := .xsd JAXBContextFactory.java ZeroOneBooleanAdapter.java
402
403################################################################################
404
405jdk.xml.ws_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
406jdk.xml.ws_CLEAN := .properties
407
408################################################################################
409
410sun.charsets_COPY := .dat
411
412################################################################################
413
414jdk.localedata_COPY := _dict _th
415# Exclude BreakIterator classes that are just used in compile process to generate
416# data files and shouldn't go in the product
417jdk.localedata_EXCLUDE_FILES := sun/text/resources/th/BreakIteratorRules_th.java
418
419################################################################################
420# Setup the compilation of each module
421#
422# Do not include nashorn src here since it needs to be compiled separately due
423# to nasgen.
424#
425# Order src dirs in order of override with the most important first. Generated
426# source before static source and platform specific source before shared.
427#
428# To use this variable, use $(call ALL_SRC_DIRS,module) with no space.
429GENERATED_SRC_DIRS += \
430    $(JDK_OUTPUTDIR)/gensrc/$1 \
431    $(LANGTOOLS_OUTPUTDIR)/gensrc/$1 \
432    $(CORBA_OUTPUTDIR)/gensrc/$1 \
433    $(JDK_OUTPUTDIR)/gensrc_no_srczip/$1 \
434    #
435
436OS_SRC_DIRS += $(JDK_TOPDIR)/src/$1/$(OPENJDK_TARGET_OS)/classes
437ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_API_DIR))
438OS_API_SRC_DIRS += $(JDK_TOPDIR)/src/$1/$(OPENJDK_TARGET_OS_API_DIR)/classes
439endif
440
441SHARE_SRC_DIRS += \
442    $(JDK_TOPDIR)/src/$1/share/classes \
443    $(LANGTOOLS_TOPDIR)/src/$1/share/classes \
444    $(CORBA_TOPDIR)/src/$1/share/classes \
445    $(JAXP_TOPDIR)/src/$1/share/classes \
446    $(JAXWS_TOPDIR)/src/$1/share/classes \
447    #
448
449ALL_SRC_DIRS = \
450    $(GENERATED_SRC_DIRS) \
451    $(OS_SRC_DIRS) \
452    $(OS_API_SRC_DIRS) \
453    $(SHARE_SRC_DIRS) \
454    #
455
456# Find all modules with java sources. Filter out nashorn since it needs to be
457# compiled separately.
458ALL_JAVA_MODULES := $(filter-out jdk.scripting.nashorn, $(call FindJavaModules))
459JAVA_MODULES := $(ALL_JAVA_MODULES)
460
461# The JDK_USER_DEFINED_FILTER is a poor man's incremental build: by specifying
462# JDK_FILTER at the make command line, only a subset of the JDK java files will
463# be recompiled. If multiple paths are separated by comma, convert that into a
464# space separated list.
465JDK_USER_DEFINED_FILTER := $(strip $(subst $(COMMA),$(SPACE), $(JDK_FILTER)))
466
467# This macro sets up compilation of a module and declares dependencies for it.
468# Param 1 - module name
469define SetupModuleCompilation
470  # Find the module dependencies by parsing modules.list file
471  $1_DEPS := $$(call FindDepsForModule, $1)
472
473  $1_CLASSPATH := $$(addprefix $(JDK_OUTPUTDIR)/modules/,$$($1_DEPS))
474  # When crypto classes are prebuilt, need to look for classes already in 
475  # output dir.
476  ifneq ($(BUILD_CRYPTO), true)
477    $1_CLASSPATH += $(JDK_OUTPUTDIR)/modules/$1
478  endif
479  ifeq ($1, jdk.hotspot.agent)
480    ## The source of this module is compiled elsewhere, hotspot, and imported.
481    ## Service types are required in the classpath when compiing module-info
482    $1_CLASSPATH := $$($1_CLASSPATH) $$(addprefix $(JDK_OUTPUTDIR)/modules/,jdk.hotspot.agent)
483  endif
484  $1_CLASSPATH := $$(subst $$(SPACE),$$(PATH_SEP),$$($1_CLASSPATH))
485  $1_JAVAC_FLAGS := -bootclasspath "$$($1_CLASSPATH)"
486
487  $$(eval $$(call SetupJavaCompilation,$1, \
488      SETUP := $$(if $$($1_SETUP), $$($1_SETUP), GENERATE_JDKBYTECODE), \
489      SRC := $$(wildcard $$(call ALL_SRC_DIRS,$1)), \
490      INCLUDES:=$(JDK_USER_DEFINED_FILTER),\
491      BIN := $(JDK_OUTPUTDIR)/modules/$1, \
492      HEADERS := $(JDK_OUTPUTDIR)/gensrc_headers/$1, \
493      ADD_JAVAC_FLAGS := $$($1_JAVAC_FLAGS)))
494
495  $1: $$($1) $$($1_COPY_EXTRA)
496
497  # Declare dependencies between java compilation of different modules.
498  # Since not all modules have been declared yet, or might be declared
499  # in different invocations of this file, use the macro to find the 
500  # correct target file to depend on.
501  # Only the javac compilation actually depends on other modules so limit
502  # dependency declaration to that by using the *_COMPILE_TARGET variable.
503  $$($1_COMPILE_TARGETS): $$(foreach d,$$($1_DEPS), \
504      $$(call SetupJavaCompilationCompileTarget, $$d, $(JDK_OUTPUTDIR)/modules/$$d))
505endef
506
507# Setup compilation for each module
508$(foreach m,$(JAVA_MODULES),$(eval $(call SetupModuleCompilation,$m)))
509
510################################################################################
511# Copy zh_HK properties files from zh_TW
512
513$(JDK_OUTPUTDIR)/modules/%_zh_HK.properties: $(JDK_OUTPUTDIR)/modules/%_zh_TW.properties
514	$(install-file)
515
516define CreateHkTargets
517  $(patsubst $(JDK_TOPDIR)/src/%, $(JDK_OUTPUTDIR)/modules/%, \
518    $(subst /share/classes,, \
519      $(subst _zh_TW,_zh_HK, $(filter %_zh_TW.properties, $1))))
520endef
521
522java.sql.rowset: $(call CreateHkTargets, $(java.sql.rowset_CLEAN_FILES))
523java.rmi: $(call CreateHkTargets, $(java.rmi_CLEAN_FILES))
524
525all: $(JAVA_MODULES)
526
527.PHONY: all $(JAVA_MODULES)
528