jdk/makefiles/CompileJavaClasses.gmk
author naoto
Fri, 24 Aug 2012 10:13:58 -0700
changeset 13586 31ba61c73020
parent 13164 72c5d01a857d
child 13702 efd6a05935b2
permissions -rw-r--r--
7193601: Build breakage with the fix to 6336885 (build-infra build) Reviewed-by: mduigou

#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

default: all

include $(SPEC)
include MakeBase.gmk
include JavaCompilation.gmk

# Setup the java compilers for the JDK build.
include Setup.gmk

JARS :=
EXFILES :=
EXCLUDES :=

##########################################################################################

EXCLUDES +=	com/sun/pept \
		com/sun/tools/example/trace\
		com/sun/tools/example/debug/bdi\
		com/sun/tools/example/debug/event\
		com/sun/tools/example/debug/gui \
		com/oracle/security

ifeq ($(OPENJDK_TARGET_OS)-$(ARCH_DATA_MODEL),windows-64)
     EXCLUDES += sun/security/pkcs11
endif

ifdef OPENJDK
    EXCLUDES+=	sun/dc \
		com/sun/jmx/snmp \
		sun/management/snmp \
		com/sun/script
endif

ifndef OPENJDK
   # There exists two versions of this file...
   EXFILES := $(JDK_TOPDIR)/src/share/classes/javax/crypto/JarVerifier.java
endif

ifneq ($(OPENJDK_TARGET_OS),solaris)
   # Exclude Solaris nio and two security related files in src/share/classes
   EXFILES += SolarisAclFileAttributeView.java \
	SolarisFileStore.java \
	SolarisFileSystem.java \
	SolarisFileSystemProvider.java \
	SolarisNativeDispatcher.java \
	SolarisUserDefinedFileAttributeView.java \
	SolarisWatchService.java \
	SolarisAclFileAttributeView.java \
	SolarisLoginModule.java \
	SolarisSystem.java \
	sun/nio/ch/EventPortSelectorImpl.java \
	sun/nio/ch/EventPortSelectorProvider.java \
	sun/nio/ch/EventPortWrapper.java \
	sun/tools/attach/SolarisAttachProvider.java \
	sun/tools/attach/SolarisVirtualMachine.java
endif

# In the old build, this isn't excluded on macosx, even though it probably
# should be.
ifneq ($(OPENJDK_TARGET_OS),macosx)
	EXFILES+=WrapperGenerator.java
endif

ifneq ($(OPENJDK_TARGET_OS),windows)
    # Exclude Window security related files in src/share/classes
    EXFILES+=NTLoginModule.java \
             NTSystem.java

endif

ifeq ($(OPENJDK_TARGET_OS),windows)
    # Don't build GTK L&F on Windows
    EXCLUDES+=	com/sun/java/swing/plaf/gtk
endif

ifneq ($(OPENJDK_TARGET_OS),linux)
    EXFILES+=sun/tools/attach/LinuxAttachProvider.java \
	sun/tools/attach/LinuxVirtualMachine.java \
	sun/nio/fs/LinuxDosFileAttributeView.java \
	sun/nio/fs/LinuxFileStore.java \
	sun/nio/fs/LinuxFileSystem.java \
	sun/nio/fs/LinuxFileSystemProvider.java \
	sun/nio/fs/LinuxNativeDispatcher.java \
	sun/nio/fs/LinuxUserDefinedFileAttributeView.java \
	sun/nio/fs/LinuxWatchService.java
endif

ifneq ($(OPENJDK_TARGET_OS),macosx)
    EXFILES+=sun/nio/fs/BsdFileStore.java \
	     sun/nio/fs/BsdFileSystem.java \
             sun/nio/fs/BsdFileSystemProvider.java \
             sun/nio/fs/BsdNativeDispatcher.java \
             sun/tools/attach/BsdAttachProvider.java \
             sun/tools/attach/BsdVirtualMachine.java
endif

# Exclude BreakIterator classes that are just used in compile process to generate
# data files and shouldn't go in the product
EXFILES+=sun/text/resources/BreakIteratorRules.java \
	sun/text/resources/BreakIteratorRules_th.java

# TODO: Add BUILD_HEADLESS_ONLY to configure?
ifdef BUILD_HEADLESS_ONLY
    EXCLUDES+=sun/applet
endif

ifdef OPENJDK
    EXCLUDES+=sun/java2d/cmm/kcms
endif

# Used on windows and macosx
ifeq (,$(filter $(OPENJDK_TARGET_OS), windows macosx))
    EXFILES+=sun/awt/AWTCharset.java
endif

ifneq ($(OPENJDK_TARGET_OS), macosx)
#
# Not in rt.jar on solaris and linux...(windows not checked)
#     in rt.jar on macosx ??
EXFILES+=sun/awt/X11/ScreenFormat.java \
         sun/awt/X11/XArc.java \
         sun/awt/X11/XChar2b.java \
         sun/awt/X11/XCharStruct.java \
         sun/awt/X11/XClassHint.java \
         sun/awt/X11/XComposeStatus.java \
         sun/awt/X11/XExtCodes.java \
         sun/awt/X11/XFontProp.java \
         sun/awt/X11/XFontSetExtents.java \
         sun/awt/X11/XFontStruct.java \
         sun/awt/X11/XGCValues.java \
         sun/awt/X11/XHostAddress.java \
         sun/awt/X11/XIMCallback.java \
         sun/awt/X11/XIMHotKeyTrigger.java \
         sun/awt/X11/XIMHotKeyTriggers.java \
         sun/awt/X11/XIMPreeditCaretCallbackStruct.java \
         sun/awt/X11/XIMPreeditDrawCallbackStruct.java \
         sun/awt/X11/XIMPreeditStateNotifyCallbackStruct.java \
         sun/awt/X11/XIMStatusDrawCallbackStruct.java \
         sun/awt/X11/XIMStringConversionCallbackStruct.java \
         sun/awt/X11/XIMStringConversionText.java \
         sun/awt/X11/XIMStyles.java \
         sun/awt/X11/XIMText.java \
         sun/awt/X11/XIMValuesList.java \
         sun/awt/X11/XImage.java \
         sun/awt/X11/XKeyboardControl.java \
         sun/awt/X11/XKeyboardState.java \
         sun/awt/X11/XOMCharSetList.java \
         sun/awt/X11/XOMFontInfo.java \
         sun/awt/X11/XOMOrientation.java \
         sun/awt/X11/XPoint.java \
         sun/awt/X11/XRectangle.java \
         sun/awt/X11/XSegment.java \
         sun/awt/X11/XStandardColormap.java \
         sun/awt/X11/XTextItem.java \
         sun/awt/X11/XTextItem16.java \
         sun/awt/X11/XTextProperty.java \
         sun/awt/X11/XTimeCoord.java \
         sun/awt/X11/XWindowChanges.java \
         sun/awt/X11/XdbeSwapInfo.java \
         sun/awt/X11/XmbTextItem.java \
         sun/awt/X11/XwcTextItem.java
endif

# Exclude another implicitly not included file.
EXFILES+=sun/util/locale/AsciiUtil.java

ifeq (,$(filter $(OPENJDK_TARGET_OS), solaris macosx))
#
# only solaris and macosx
#
    EXFILES+=sun/nio/fs/PollingWatchService.java
endif

# TODO: Fix when converting NIO
# Exclude *-linux-arm.java and *-linux-ppc.java from closed.
EXFILES+=-linux-arm.java \
	 -linux-ppc.java

# TODO: Is this necessary?
ifeq ($(OPENJDK_TARGET_OS), windows)
    EXFILES+=sun/nio/ch/AbstractPollSelectorImpl.java \
	sun/nio/ch/DevPollArrayWrapper.java \
	sun/nio/ch/DevPollSelectorImpl.java \
        sun/nio/ch/DevPollSelectorProvider.java \
	sun/nio/ch/InheritedChannel.java \
        sun/nio/ch/PollSelectorProvider.java \
        sun/nio/ch/PollSelectorImpl.java \
	sun/nio/ch/Port.java \
	sun/nio/ch/SimpleAsynchronousFileChannelImpl.java \
	sun/nio/ch/SolarisAsynchronousChannelProvider.java \
	sun/nio/ch/SolarisEventPort.java \
	sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
	sun/nio/ch/UnixAsynchronousSocketChannelImpl.java
    EXFILES+=sun/net/sdp/SdpProvider.java
else
    EXFILES+=sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java
endif

ifdef DISABLE_NIMBUS
    # TODO: need to check when it happens
    # Exclude nimus if disabled
    EXCLUDES+=	javax/swing/plaf/nimbus \
		com/sun/java/swing/plaf/nimbus
else
#
# These are never put into rt.jar
#
EXFILES+=  javax/swing/plaf/nimbus/InternalFrameTitlePanePainter.java \
           javax/swing/plaf/nimbus/OptionPaneMessageAreaPainter.java \
           javax/swing/plaf/nimbus/ScrollBarPainter.java \
           javax/swing/plaf/nimbus/SliderPainter.java \
           javax/swing/plaf/nimbus/SpinnerPainter.java \
           javax/swing/plaf/nimbus/SplitPanePainter.java \
           javax/swing/plaf/nimbus/TabbedPanePainter.java
endif

# Acquire a list of files that should be copied straight over to the classes.
include CopyIntoClasses.gmk
# Now we have COPY_PATTERNS, COPY_FILES and COPY_EXTRA

ifndef OPENJDK
    CLOSED_SRC_DIRS:=$(JDK_TOPDIR)/src/closed/share/classes \
		     $(JDK_TOPDIR)/src/closed/$(LEGACY_OPENJDK_TARGET_OS_API)/classes
endif

MACOSX_SRC_DIRS :=
ifeq ($(OPENJDK_TARGET_OS),macosx)
     MACOSX_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/classes

     # this files are duplicated in MACOSX_SRC_DIRS
     EXFILES+= $(JDK_TOPDIR)/src/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java \
               $(JDK_TOPDIR)/src/solaris/classes/sun/java2d/BackBufferCapsProvider.java \
               $(JDK_TOPDIR)/src/solaris/classes/java/net/DefaultInterface.java \
               $(JDK_TOPDIR)/src/solaris/classes/java/lang/ClassLoaderHelper.java \
               $(JDK_TOPDIR)/src/solaris/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java

     # JObjC.jar contains 1.5 byte-code...so skip it here :-(
     # MACOSX_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/native/jobjc/src
     # EXCLUDES+= tests/java/com/apple/jobjc

     EXCLUDES+= com/apple/jobjc
endif

# The exception handling of swing beaninfo
# These resources violates the convention of having code and resources together under
# $(JDK_TOPDIR)/src/.../classes directories
$(JDK_OUTPUTDIR)/classes/javax/swing/beaninfo/images/%.gif: $(JDK_TOPDIR)/make/tools/swing-beans/beaninfo/images/%.gif
	$(MKDIR) -p $(@D)
	$(CP) $< $@

$(eval $(call SetupJavaCompilation,BUILD_JDK,\
                SETUP:=GENERATE_JDKBYTECODE,\
		SRC:=$(JDK_TOPDIR)/src/share/classes \
		     $(JDK_TOPDIR)/src/$(LEGACY_OPENJDK_TARGET_OS_API)/classes \
		     $(MACOSX_SRC_DIRS) \
		     $(JDK_OUTPUTDIR)/gensrc \
		     $(JDK_OUTPUTDIR)/gensrc_swing/javax/swing/beaninfo \
		     $(CLOSED_SRC_DIRS),\
		EXCLUDES:=$(EXCLUDES),\
		EXCLUDE_FILES:=$(EXFILES),\
		BIN:=$(JDK_OUTPUTDIR)/classes,\
		COPY:=$(COPY_PATTERNS),\
		COPY_FILES:=$(COPY_FILES),\
		HEADERS:=$(JDK_OUTPUTDIR)/gensrc_headers))

##########################################################################################
# Special handling of header file generation for classes in the jigsaw base module which
# currently can't add the annotaion GenerateNativeHeaders. For these specific classes the
# java file and the class have the same names which enables shortcutting the dependencies.

JDK_BASE_HEADER_CLASSES:=java.lang.Integer \
			 java.lang.Long \
			 java.net.SocketOptions \
			 sun.nio.ch.IOStatus

JDK_BASE_HEADER_JAVA_FILES:=$(patsubst %,$(JDK_TOPDIR)/src/share/classes/%.java,\
				$(subst .,/,$(JDK_BASE_HEADER_CLASSES)))

ifeq ($(OPENJDK_TARGET_OS),windows)
    JDK_BASE_HEADER_CLASSES_WINDOWS:=sun.nio.ch.PollArrayWrapper
    JDK_BASE_HEADER_CLASSES+=$(JDK_BASE_HEADER_CLASSES_WINDOWS)
    JDK_BASE_HEADER_JAVA_FILES+=$(patsubst %,$(JDK_TOPDIR)/src/windows/classes/%.java,\
				$(subst .,/,$(JDK_BASE_HEADER_CLASSES_WINDOWS)))
endif

# Set prereqs to the java files since make doesn't know about the class files. Add BUILD_JDK
# as an order only dependency to avoid race with the java compilation.
$(JDK_OUTPUTDIR)/classes/_the.jdk.base.headers: $(JDK_BASE_HEADER_JAVA_FILES) | $(BUILD_JDK)
	$(ECHO) Generating headers for jdk base classes
	$(JAVAH) -bootclasspath $(JDK_OUTPUTDIR)/classes -d $(JDK_OUTPUTDIR)/gensrc_headers \
		$(JDK_BASE_HEADER_CLASSES)
	$(TOUCH) $@

##########################################################################################

#
# This is an empty jar (only contains manifest) and fits poorly into framework...
#   create simple rule instead
#
MANAGEMENT_AGENT_JAR_DEPS := $(JDK_TOPDIR)/src/share/classes/sun/management/manifest

$(JDK_OUTPUTDIR)/lib/management-agent.jar : $(JDK_TOPDIR)/src/share/classes/sun/management/manifest
	$(JAR) cfm $@ $(JDK_TOPDIR)/src/share/classes/sun/management/manifest

JARS += $(JDK_OUTPUTDIR)/lib/management-agent.jar

##########################################################################################

ifndef OPENJDK

$(eval $(call SetupJavaCompilation,BUILD_ALTCLASSES_JAR,\
		SETUP:=GENERATE_JDKBYTECODE,\
		SRC:=$(JDK_TOPDIR)/src/closed/share/altclasses, \
		BIN:=$(JDK_OUTPUTDIR)/altclasses_classes,\
		JAR:=$(JDK_OUTPUTDIR)/lib/alt-rt.jar))

$(BUILD_ALTCLASSES_JAR): $(BUILD_JDK)
JARS += $(JDK_OUTPUTDIR)/lib/alt-rt.jar

endif

##########################################################################################

$(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin:
	$(MKDIR) -p $(@D)
	$(TOUCH) $@

##########################################################################################

ifeq ($(OPENJDK_TARGET_OS),macosx)
#
# JObjC.jar is compiled with BOOT_JAVAC which (may) not support the "-h" flag.
#   so we first compile classes with BOOT_JAVAC and then with JDK_JAVAC :-(
#
$(eval $(call SetupJavaCompiler,GENERATE_15BYTECODE,\
     JAVAC:=$(JAVAC),\
     FLAGS:=-source 1.5 -target 1.5 -g -bootclasspath $(BOOT_RTJAR) -cp $(JDK_OUTPUTDIR)/../langtools/dist/lib/classes.jar $(DISABLE_WARNINGS),\
     SERVER_DIR:=$(JAVAC_SERVERS),\
     SERVER_JVM:=$(SERVER_JAVA),\
     MODE:=$(JAVAC_USE_MODE),\
     USE_DEPS:=$(JAVAC_USE_DEPS)))

$(eval $(call SetupJavaCompilation,BUILD_JOBJC_JAR,\
		SETUP:=GENERATE_15BYTECODE,\
		SRC:=$(JDK_TOPDIR)/src/macosx/native/jobjc/src/core/java \
		     $(JDK_TOPDIR)/src/macosx/native/jobjc/src/runtime-additions/java \
		     $(JDK_OUTPUTDIR)/gensrc, \
		INCLUDES := com/apple/jobjc,\
                EXCLUDES := tests/java/com/apple/jobjc,\
		BIN:=$(JDK_OUTPUTDIR)/jobjc_classes,\
		JAR:=$(JDK_OUTPUTDIR)/lib/JObjC.jar, \
		JARINDEX := true))

$(BUILD_JOBJC_JAR) : $(BUILD_JDK)

JARS += $(JDK_OUTPUTDIR)/lib/JObjC.jar

$(eval $(call SetupJavaCompilation,BUILD_JOBJC_HEADERS_JAR,\
		SETUP:=GENERATE_JDKBYTECODE,\
		SRC:=$(JDK_TOPDIR)/src/macosx/native/jobjc/src/core/java \
		     $(JDK_TOPDIR)/src/macosx/native/jobjc/src/runtime-additions/java \
		     $(JDK_OUTPUTDIR)/gensrc, \
		INCLUDES := com/apple/jobjc,\
                EXCLUDES := tests/java/com/apple/jobjc,\
		BIN:=$(JDK_OUTPUTDIR)/jobjc_classes_headers,\
		JAR:=$(JDK_OUTPUTDIR)/jobjc_classes_headers/dummy.jar, \
		HEADERS:=$(JDK_OUTPUTDIR)/gensrc_headers))

$(BUILD_JOBJC_HEADERS_JAR) : $(BUILD_JDK)

JARS += $(JDK_OUTPUTDIR)/jobjc_classes_headers/dummy.jar

endif

##########################################################################################

# copy with -a to preserve timestamps so dependencies down the line aren't messed up
all: $(BUILD_JDK) $(JARS) $(COPY_EXTRA) $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin \
	$(JDK_OUTPUTDIR)/classes/_the.jdk.base.headers

.PHONY: all