1 #
   2 # Copyright (c) 2011, 2015, 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 default: all
  27 
  28 include $(SPEC)
  29 include MakeBase.gmk
  30 include JavaCompilation.gmk
  31 
  32 # Setup the java compilers for the JDK build.
  33 include Setup.gmk
  34 
  35 JARS :=
  36 EXFILES :=
  37 EXCLUDES :=
  38 
  39 ##########################################################################################
  40 # Include the corresponding custom file, if present.
  41 
  42 -include $(CUSTOM_MAKE_DIR)/CompileJavaClasses.gmk
  43 
  44 ##########################################################################################
  45 
  46 EXCLUDES += com/sun/pept \
  47     com/sun/tools/example/trace \
  48     com/sun/tools/example/debug/bdi \
  49     com/sun/tools/example/debug/event \
  50     com/sun/tools/example/debug/gui
  51 
  52 ifdef OPENJDK
  53   EXCLUDES += sun/dc \
  54       com/sun/jmx/snmp \
  55       sun/management/snmp \
  56       com/sun/script
  57 endif
  58 
  59 ifndef OPENJDK
  60   # There exists two versions of these files...
  61   EXFILES += $(JDK_TOPDIR)/src/share/classes/javax/crypto/JarVerifier.java
  62 
  63   ifeq ($(OPENJDK_TARGET_OS), windows)
  64     # This gets built on unix platforms implicitly in the old build even though
  65     # it's excluded in the closed build.
  66     EXCLUDES += sun/java2d/pisces
  67   endif
  68 endif
  69 
  70 ifeq ($(OPENJDK_TARGET_OS), windows)
  71     # AccessBridge is compiled separately below.
  72     EXFILES += AccessBridge.java AccessBridgeLoader.java
  73     # This seems to never be built
  74     EXCLUDES += com/sun/java/accessibility/extensions
  75   endif
  76 
  77 ifneq ($(OPENJDK_TARGET_OS), solaris)
  78   # Exclude Solaris nio and two security related files in src/share/classes
  79   EXFILES += SolarisAclFileAttributeView.java \
  80       SolarisFileStore.java \
  81       SolarisFileSystem.java \
  82       SolarisFileSystemProvider.java \
  83       SolarisNativeDispatcher.java \
  84       SolarisUserDefinedFileAttributeView.java \
  85       SolarisWatchService.java \
  86       SolarisAclFileAttributeView.java \
  87       SolarisLoginModule.java \
  88       SolarisSystem.java \
  89       sun/nio/ch/DevPollArrayWrapper.java \
  90       sun/nio/ch/DevPollSelectorImpl.java \
  91       sun/nio/ch/DevPollSelectorProvider.java \
  92       sun/nio/ch/EventPortSelectorImpl.java \
  93       sun/nio/ch/EventPortSelectorProvider.java \
  94       sun/nio/ch/EventPortWrapper.java \
  95       sun/nio/ch/SolarisAsynchronousChannelProvider.java \
  96       sun/nio/ch/SolarisEventPort.java \
  97       sun/tools/attach/SolarisAttachProvider.java \
  98       sun/tools/attach/SolarisVirtualMachine.java
  99 
 100   EXCLUDES += com/oracle/security
 101 endif
 102 
 103 EXFILES += WrapperGenerator.java
 104 
 105 ifneq ($(OPENJDK_TARGET_OS), windows)
 106   # Exclude Window security related files in src/share/classes
 107   EXFILES += NTLoginModule.java \
 108       NTSystem.java
 109 else
 110   EXFILES += UnixLoginModule.java \
 111       UnixSystem.java
 112 endif
 113 
 114 ifeq ($(OPENJDK_TARGET_OS), windows)
 115   # Don't build GTK L&F on Windows
 116   EXCLUDES += com/sun/java/swing/plaf/gtk
 117 endif
 118 
 119 ifneq ($(OPENJDK_TARGET_OS), linux)
 120   EXFILES += sun/tools/attach/LinuxAttachProvider.java \
 121       sun/tools/attach/LinuxVirtualMachine.java \
 122       sun/nio/ch/EPoll.java \
 123       sun/nio/ch/EPollArrayWrapper.java \
 124       sun/nio/ch/EPollPort.java \
 125       sun/nio/ch/EPollSelectorImpl.java \
 126       sun/nio/ch/EPollSelectorProvider.java \
 127       sun/nio/ch/LinuxAsynchronousChannelProvider.java \
 128       sun/nio/fs/LinuxDosFileAttributeView.java \
 129       sun/nio/fs/LinuxFileStore.java \
 130       sun/nio/fs/LinuxFileSystem.java \
 131       sun/nio/fs/LinuxFileSystemProvider.java \
 132       sun/nio/fs/MagicFileTypeDetector.java \
 133       sun/nio/fs/LinuxNativeDispatcher.java \
 134       sun/nio/fs/LinuxUserDefinedFileAttributeView.java \
 135       sun/nio/fs/LinuxWatchService.java
 136 endif
 137 
 138 ifneq ($(OPENJDK_TARGET_OS), macosx)
 139   EXFILES += sun/nio/ch/BsdAsynchronousChannelProvider.java \
 140       sun/nio/ch/KQueue.java \
 141       sun/nio/ch/KQueuePort.java \
 142       sun/nio/fs/BsdFileStore.java \
 143       sun/nio/fs/BsdFileSystem.java \
 144       sun/nio/fs/BsdFileSystemProvider.java \
 145       sun/nio/fs/BsdNativeDispatcher.java \
 146       sun/nio/fs/MacOSXFileSystemProvider.java \
 147       sun/nio/fs/MacOSXFileSystem.java \
 148       sun/nio/fs/MacOSXNativeDispatcher.java \
 149       sun/tools/attach/BsdAttachProvider.java \
 150       sun/tools/attach/BsdVirtualMachine.java
 151 endif
 152 
 153 ifneq ($(OPENJDK_TARGET_OS),aix)
 154     EXFILES+=sun/nio/ch/AixAsynchronousChannelProvider.java \
 155              sun/nio/ch/AixPollPort.java \
 156              sun/nio/fs/AixFileStore.java \
 157              sun/nio/fs/AixFileSystem.java \
 158              sun/nio/fs/AixFileSystemProvider.java \
 159              sun/nio/fs/AixNativeDispatcher.java \
 160              sun/tools/attach/AixAttachProvider.java \
 161              sun/tools/attach/AixVirtualMachine.java
 162 endif
 163 
 164 # Exclude BreakIterator classes that are just used in compile process to generate
 165 # data files and shouldn't go in the product
 166 EXFILES += sun/text/resources/BreakIteratorRules.java \
 167     sun/text/resources/BreakIteratorRules_th.java
 168 
 169 # TODO: Add BUILD_HEADLESS_ONLY to configure?
 170 ifdef BUILD_HEADLESS_ONLY
 171   EXCLUDES += sun/applet
 172 endif
 173 
 174 ifdef OPENJDK
 175   EXCLUDES += sun/java2d/cmm/kcms
 176 endif
 177 
 178 # Used on windows and macosx
 179 ifeq (, $(filter $(OPENJDK_TARGET_OS), windows macosx))
 180   EXFILES += sun/awt/AWTCharset.java
 181 endif
 182 
 183 ifeq ($(OPENJDK_TARGET_OS), macosx)
 184   # exclude all X11 on Mac, we can't exclude some like below or we'll have compilation errors
 185   EXCLUDES += sun/awt/X11
 186 else
 187   # TBD: figure out how to eliminate this long list
 188   EXFILES += sun/awt/X11/ScreenFormat.java \
 189       sun/awt/X11/XArc.java \
 190       sun/awt/X11/XChar2b.java \
 191       sun/awt/X11/XCharStruct.java \
 192       sun/awt/X11/XClassHint.java \
 193       sun/awt/X11/XComposeStatus.java \
 194       sun/awt/X11/XExtCodes.java \
 195       sun/awt/X11/XFontProp.java \
 196       sun/awt/X11/XFontSetExtents.java \
 197       sun/awt/X11/XFontStruct.java \
 198       sun/awt/X11/XGCValues.java \
 199       sun/awt/X11/XHostAddress.java \
 200       sun/awt/X11/XIMCallback.java \
 201       sun/awt/X11/XIMHotKeyTrigger.java \
 202       sun/awt/X11/XIMHotKeyTriggers.java \
 203       sun/awt/X11/XIMPreeditCaretCallbackStruct.java \
 204       sun/awt/X11/XIMPreeditDrawCallbackStruct.java \
 205       sun/awt/X11/XIMPreeditStateNotifyCallbackStruct.java \
 206       sun/awt/X11/XIMStatusDrawCallbackStruct.java \
 207       sun/awt/X11/XIMStringConversionCallbackStruct.java \
 208       sun/awt/X11/XIMStringConversionText.java \
 209       sun/awt/X11/XIMStyles.java \
 210       sun/awt/X11/XIMText.java \
 211       sun/awt/X11/XIMValuesList.java \
 212       sun/awt/X11/XImage.java \
 213       sun/awt/X11/XKeyboardControl.java \
 214       sun/awt/X11/XKeyboardState.java \
 215       sun/awt/X11/XOMCharSetList.java \
 216       sun/awt/X11/XOMFontInfo.java \
 217       sun/awt/X11/XOMOrientation.java \
 218       sun/awt/X11/XPoint.java \
 219       sun/awt/X11/XRectangle.java \
 220       sun/awt/X11/XSegment.java \
 221       sun/awt/X11/XStandardColormap.java \
 222       sun/awt/X11/XTextItem.java \
 223       sun/awt/X11/XTextItem16.java \
 224       sun/awt/X11/XTextProperty.java \
 225       sun/awt/X11/XTimeCoord.java \
 226       sun/awt/X11/XWindowChanges.java \
 227       sun/awt/X11/XdbeSwapInfo.java \
 228       sun/awt/X11/XmbTextItem.java \
 229       sun/awt/X11/XwcTextItem.java
 230 endif
 231 
 232 # Exclude another implicitly not included file.
 233 EXFILES += sun/util/locale/AsciiUtil.java
 234 
 235 ifeq (, $(filter $(OPENJDK_TARGET_OS), solaris macosx aix))
 236   #
 237   # only solaris, macosx and aix
 238   #
 239   EXFILES += sun/nio/fs/PollingWatchService.java
 240 endif
 241 
 242 # TODO: Fix when converting NIO
 243 # Exclude *-linux-arm.java and *-linux-ppc.java from closed.
 244 EXFILES += -linux-arm.java \
 245     -linux-ppc.java
 246 
 247 ifeq ($(OPENJDK_TARGET_OS), windows)
 248   EXFILES += sun/nio/ch/AbstractPollSelectorImpl.java \
 249       sun/nio/ch/PollSelectorProvider.java \
 250       sun/nio/ch/SimpleAsynchronousFileChannelImpl.java
 251 endif
 252 
 253 # These files do not appear in the build result of the old build. This
 254 # is because they are generated sources, but the AUTO_JAVA_FILES won't
 255 # pick them up since they aren't generated when the source dirs are
 256 # searched and they aren't referenced by any other classes so they won't
 257 # be picked up by implicit compilation. On a rebuild, they are picked up
 258 # and compiled. Exclude them here to produce the same rt.jar as the old
 259 # build does when building just once.
 260 EXFILES += javax/swing/plaf/nimbus/InternalFrameTitlePanePainter.java \
 261     javax/swing/plaf/nimbus/OptionPaneMessageAreaPainter.java \
 262     javax/swing/plaf/nimbus/ScrollBarPainter.java \
 263     javax/swing/plaf/nimbus/SliderPainter.java \
 264     javax/swing/plaf/nimbus/SpinnerPainter.java \
 265     javax/swing/plaf/nimbus/SplitPanePainter.java \
 266     javax/swing/plaf/nimbus/TabbedPanePainter.java
 267 
 268 # Acquire a list of files that should be copied straight over to the classes.
 269 include CopyIntoClasses.gmk
 270 # Now we have COPY_PATTERNS, COPY_FILES and COPY_EXTRA
 271 
 272 ifndef OPENJDK
 273   CLOSED_SRC_DIRS := $(JDK_TOPDIR)/src/closed/share/classes \
 274       $(wildcard $(JDK_TOPDIR)/src/closed/$(OPENJDK_TARGET_OS_API_DIR)/classes)
 275 endif
 276 
 277 MACOSX_SRC_DIRS :=
 278 ifeq ($(OPENJDK_TARGET_OS), macosx)
 279   MACOSX_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/classes
 280 
 281   # this files are duplicated in MACOSX_SRC_DIRS
 282   EXFILES += $(JDK_TOPDIR)/src/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java \
 283       $(JDK_TOPDIR)/src/solaris/classes/sun/java2d/BackBufferCapsProvider.java \
 284       $(JDK_TOPDIR)/src/solaris/classes/java/net/DefaultInterface.java \
 285       $(JDK_TOPDIR)/src/solaris/classes/java/lang/ClassLoaderHelper.java \
 286       $(JDK_TOPDIR)/src/solaris/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java \
 287       $(JDK_TOPDIR)/src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java \
 288       $(JDK_TOPDIR)/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java \
 289       $(JDK_TOPDIR)/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java \
 290       $(JDK_TOPDIR)/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java
 291 
 292 endif
 293 
 294 # The security classes should not end up in the classes directory as that will prevent them
 295 # from working when running the exploded jdk image. Compile them separately to a different
 296 # directory from where the jars can be created.
 297 SECURITY_PKGS := \
 298     com/oracle/security/ucrypto \
 299     com/sun/crypto/provider \
 300     javax/crypto \
 301     sun/security/ec \
 302     sun/security/internal \
 303     sun/security/mscapi \
 304     sun/security/pkcs11 \
 305     #
 306 
 307 AIX_SRC_DIRS :=
 308 ifeq ($(OPENJDK_TARGET_OS),aix)
 309      AIX_SRC_DIRS += $(JDK_TOPDIR)/src/aix/classes
 310 
 311   # these files are duplicated in AIX_SRC_DIRS
 312   EXFILES += $(JDK_TOPDIR)/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java \
 313       $(JDK_TOPDIR)/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java \
 314       $(JDK_TOPDIR)/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java
 315 endif
 316 
 317 # The exception handling of swing beaninfo
 318 # These resources violates the convention of having code and resources together under
 319 # $(JDK_TOPDIR)/src/.../classes directories
 320 $(JDK_OUTPUTDIR)/classes/javax/swing/beaninfo/images/%.gif: $(JDK_TOPDIR)/make/data/swingbeaninfo/images/%.gif
 321         $(call install-file)
 322 
 323 # The JDK_USER_DEFINED_FILTER is a poor man's incremental build: by specifying
 324 # JDK_FILTER at the make command line, only a subset of the JDK java files will
 325 # be recompiled. If multiple paths are separated by comma, convert that into a
 326 # space separated list.
 327 JDK_USER_DEFINED_FILTER := $(strip $(subst $(COMMA),$(SPACE), $(JDK_FILTER)))
 328 
 329 ifeq ($(ENABLE_SJAVAC),yes)
 330   # With sjavac enabled, excluded sources are not even considered for linking. 
 331   # Explicitly add the security sources to sourcepath for linking.
 332   BUILD_JDK_SOURCEPATH:=$(patsubst %,-i$(SPACE)%.*,$(subst /,.,$(SECURITY_PKGS))) \
 333       -sourcepath $(JDK_TOPDIR)/src/share/classes
 334 endif
 335 
 336 $(eval $(call SetupJavaCompilation,BUILD_JDK,\
 337     SETUP:=GENERATE_JDKBYTECODE,\
 338     SRC:=$(JDK_TOPDIR)/src/share/classes \
 339         $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes \
 340         $(MACOSX_SRC_DIRS) \
 341         $(AIX_SRC_DIRS) \
 342         $(JDK_OUTPUTDIR)/gensrc \
 343         $(JDK_OUTPUTDIR)/gensrc_no_srczip \
 344         $(CLOSED_SRC_DIRS),\
 345     INCLUDES:=$(JDK_USER_DEFINED_FILTER),\
 346     EXCLUDES:=$(EXCLUDES) $(SECURITY_PKGS),\
 347     EXCLUDE_FILES:=$(EXFILES),\
 348     BIN:=$(JDK_OUTPUTDIR)/classes,\
 349     COPY:=$(COPY_PATTERNS),\
 350     COPY_FILES:=$(COPY_FILES),\
 351     HEADERS:=$(JDK_OUTPUTDIR)/gensrc_headers,\
 352     ADD_JAVAC_FLAGS:=$(BUILD_JDK_SOURCEPATH)))
 353 
 354 ##########################################################################################
 355 
 356 $(eval $(call SetupJavaCompilation,BUILD_SECURITY, \
 357     SETUP := GENERATE_JDKBYTECODE, \
 358     SRC := $(JDK_TOPDIR)/src/share/classes \
 359         $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes \
 360         $(MACOSX_SRC_DIRS) \
 361         $(CLOSED_SRC_DIRS), \
 362     INCLUDES := $(SECURITY_PKGS), \
 363     EXCLUDES := $(EXCLUDES), \
 364     EXCLUDE_FILES := $(EXFILES), \
 365     BIN := $(JDK_OUTPUTDIR)/classes_security, \
 366     HEADERS := $(JDK_OUTPUTDIR)/gensrc_headers))
 367 
 368 $(BUILD_SECURITY): $(BUILD_JDK)
 369 
 370 ##########################################################################################
 371 
 372 $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin:
 373         $(MKDIR) -p $(@D)
 374         $(TOUCH) $@
 375 
 376 ##########################################################################################
 377 
 378 
 379 ##########################################################################################
 380 
 381   ifeq ($(OPENJDK_TARGET_OS), windows)
 382     ifeq ($(OPENJDK_TARGET_CPU_BITS), 32)
 383       $(eval $(call SetupJavaCompilation,BUILD_ACCESSBRIDGE_32, \
 384           SETUP := GENERATE_JDKBYTECODE, \
 385           JAVAC_FLAGS := -cp $(JDK_OUTPUTDIR)/classes, \
 386           SRC := $(JDK_OUTPUTDIR)/gensrc_ab/32bit, \
 387           BIN := $(JDK_OUTPUTDIR)/classes_ab/32bit, \
 388           HEADERS := $(JDK_OUTPUTDIR)/gensrc_headers))
 389 
 390       $(BUILD_ACCESSBRIDGE_32): $(BUILD_JDK)
 391 
 392       $(eval $(call SetupJavaCompilation,BUILD_ACCESSBRIDGE_LEGACY, \
 393           SETUP := GENERATE_JDKBYTECODE, \
 394           JAVAC_FLAGS := -cp $(JDK_OUTPUTDIR)/classes, \
 395           SRC := $(JDK_OUTPUTDIR)/gensrc_ab/legacy, \
 396           BIN := $(JDK_OUTPUTDIR)/classes_ab/legacy, \
 397           HEADERS := $(JDK_OUTPUTDIR)/gensrc_headers))
 398 
 399       $(BUILD_ACCESSBRIDGE_LEGACY): $(BUILD_JDK)
 400 
 401     else
 402 
 403       $(eval $(call SetupJavaCompilation,BUILD_ACCESSBRIDGE_64, \
 404           SETUP := GENERATE_JDKBYTECODE, \
 405           JAVAC_FLAGS := -cp $(JDK_OUTPUTDIR)/classes, \
 406           SRC := $(JDK_OUTPUTDIR)/gensrc_ab/64bit, \
 407           BIN := $(JDK_OUTPUTDIR)/classes_ab/64bit, \
 408           HEADERS := $(JDK_OUTPUTDIR)/gensrc_headers))
 409 
 410       $(BUILD_ACCESSBRIDGE_64): $(BUILD_JDK)
 411 
 412     endif
 413   endif
 414 
 415 ##########################################################################################
 416 
 417 all: $(BUILD_JDK) $(BUILD_SECURITY) $(COPY_EXTRA) \
 418     $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin \
 419     $(BUILD_ACCESSBRIDGE_32) $(BUILD_ACCESSBRIDGE_64) \
 420     $(BUILD_ACCESSBRIDGE_LEGACY)
 421 
 422 .PHONY: all